001/*
002 * Copyright 2014 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;
020
021import com.google.common.base.Objects;
022
023
024/**
025 * Describes the format of externally available data on a URL.
026 */
027public class DataDescription implements Serializable {
028
029  private static final long serialVersionUID = 6872006284909021347L;
030
031  private String name;
032  private String charset;
033  private URI url;
034  private String format;
035  private String formatVersion;
036
037  public DataDescription() {
038  }
039
040  public DataDescription(String name, String charset, URI url, String format, String formatVersion) {
041    this.name = name;
042    this.charset = charset;
043    this.url = url;
044    this.format = format;
045    this.formatVersion = formatVersion;
046  }
047
048  /**
049   * The name of the character encoding. This is typically ASCII or UTF-8, or one of the other common encodings.
050   *
051   * @return the character encoding
052   */
053  public String getCharset() {
054    return charset;
055  }
056
057  public void setCharset(String charset) {
058    this.charset = charset;
059  }
060
061  /**
062   * The name of the format of the data object, e.g., Microsoft Excel.
063   *
064   * @return the data format
065   */
066  public String getFormat() {
067    return format;
068  }
069
070  public void setFormat(String format) {
071    this.format = format;
072  }
073
074  /**
075   * The version of the format of the data object, e.g., 2000 (9.0.2720).
076   *
077   * @return the data format version
078   */
079  public String getFormatVersion() {
080    return formatVersion;
081  }
082
083  public void setFormatVersion(String formatVersion) {
084    this.formatVersion = formatVersion;
085  }
086
087  /**
088   * The name representing the data object being described.
089   *
090   * @return the data object name
091   */
092  public String getName() {
093    return name;
094  }
095
096  public void setName(String name) {
097    this.name = name;
098  }
099
100  /**
101   * The URL to download the resource in the mentioned format.
102   *
103   * @return the download URL
104   */
105  public URI getUrl() {
106    return url;
107  }
108
109  public void setUrl(URI url) {
110    this.url = url;
111  }
112
113  @Override
114  public boolean equals(Object obj) {
115    if (this == obj) {
116      return true;
117    }
118    if (!(obj instanceof DataDescription)) {
119      return false;
120    }
121
122    DataDescription that = (DataDescription) obj;
123    return Objects.equal(this.name, that.name)
124           && Objects.equal(this.charset, that.charset)
125           && Objects.equal(this.url, that.url)
126           && Objects.equal(this.format, that.format)
127           && Objects.equal(this.formatVersion, that.formatVersion);
128  }
129
130  @Override
131  public int hashCode() {
132    return Objects.hashCode(name, charset, url, format, formatVersion);
133  }
134
135  @Override
136  public String toString() {
137    return Objects.toStringHelper(this)
138      .add("name", name)
139      .add("charset", charset)
140      .add("url", url)
141      .add("format", format)
142      .add("formatVersion", formatVersion)
143      .toString();
144  }
145
146}