001/* 002 * Copyright 2020 Global Biodiversity Information Facility (GBIF) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.gbif.api.model.registry.eml; 017 018import java.io.Serializable; 019import java.net.URI; 020import java.util.Objects; 021import java.util.StringJoiner; 022 023/** 024 * Describes the format of externally available data on a URL. 025 */ 026public class DataDescription implements Serializable { 027 028 private static final long serialVersionUID = 6872006284909021347L; 029 030 private String name; 031 private String charset; 032 private URI url; 033 private String format; 034 private String formatVersion; 035 036 public DataDescription() { 037 } 038 039 public DataDescription(String name, String charset, URI url, String format, String formatVersion) { 040 this.name = name; 041 this.charset = charset; 042 this.url = url; 043 this.format = format; 044 this.formatVersion = formatVersion; 045 } 046 047 /** 048 * The name of the character encoding. This is typically ASCII or UTF-8, or one of the other common encodings. 049 * 050 * @return the character encoding 051 */ 052 public String getCharset() { 053 return charset; 054 } 055 056 public void setCharset(String charset) { 057 this.charset = charset; 058 } 059 060 /** 061 * The name of the format of the data object, e.g., Microsoft Excel. 062 * 063 * @return the data format 064 */ 065 public String getFormat() { 066 return format; 067 } 068 069 public void setFormat(String format) { 070 this.format = format; 071 } 072 073 /** 074 * The version of the format of the data object, e.g., 2000 (9.0.2720). 075 * 076 * @return the data format version 077 */ 078 public String getFormatVersion() { 079 return formatVersion; 080 } 081 082 public void setFormatVersion(String formatVersion) { 083 this.formatVersion = formatVersion; 084 } 085 086 /** 087 * The name representing the data object being described. 088 * 089 * @return the data object name 090 */ 091 public String getName() { 092 return name; 093 } 094 095 public void setName(String name) { 096 this.name = name; 097 } 098 099 /** 100 * The URL to download the resource in the mentioned format. 101 * 102 * @return the download URL 103 */ 104 public URI getUrl() { 105 return url; 106 } 107 108 public void setUrl(URI url) { 109 this.url = url; 110 } 111 112 @Override 113 public boolean equals(Object o) { 114 if (this == o) { 115 return true; 116 } 117 if (o == null || getClass() != o.getClass()) { 118 return false; 119 } 120 DataDescription that = (DataDescription) o; 121 return Objects.equals(name, that.name) && 122 Objects.equals(charset, that.charset) && 123 Objects.equals(url, that.url) && 124 Objects.equals(format, that.format) && 125 Objects.equals(formatVersion, that.formatVersion); 126 } 127 128 @Override 129 public int hashCode() { 130 return Objects.hash(name, charset, url, format, formatVersion); 131 } 132 133 @Override 134 public String toString() { 135 return new StringJoiner(", ", DataDescription.class.getSimpleName() + "[", "]") 136 .add("name='" + name + "'") 137 .add("charset='" + charset + "'") 138 .add("url=" + url) 139 .add("format='" + format + "'") 140 .add("formatVersion='" + formatVersion + "'") 141 .toString(); 142 } 143}