001/*
002 * Copyright 2021 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.dwc.terms;
017
018import java.io.Serializable;
019import java.net.URI;
020
021/**
022 * All Dublin Core terms with namespace http://purl.org/dc/terms/. A small subset of 15 terms exist as DcElement under
023 * a different namespace, but DcTerm values must be a member of a specific class and therefore given by URI, whereas
024 * DcElement values are allowed to be free text.
025 */
026public enum DcTerm implements Term, AlternativeNames, Serializable {
027  abstract_,
028  accessRights,
029  accrualMethod,
030  accrualPeriodicity,
031  accrualPolicy,
032  alternative,
033  audience,
034  available,
035  bibliographicCitation,
036  conformsTo,
037  contributor,
038  coverage,
039  created,
040  creator,
041  date,
042  dateAccepted,
043  dateCopyrighted,
044  dateSubmitted,
045  description,
046  educationLevel,
047  extent,
048  format,
049  hasFormat,
050  hasPart,
051  hasVersion,
052  identifier("ID"),
053  instructionalMethod,
054  isFormatOf,
055  isPartOf,
056  isReferencedBy,
057  isReplacedBy,
058  isRequiredBy,
059  isVersionOf,
060  issued,
061  language,
062  license,
063  mediator,
064  medium,
065  modified,
066  provenance,
067  publisher,
068  references,
069  relation,
070  replaces,
071  requires,
072  rights,
073  rightsHolder,
074  source,
075  spatial,
076  subject,
077  tableOfContents,
078  temporal,
079  title,
080  type,
081  valid,
082  Location;
083
084  private static final String PREFIX = "dcterms";
085  private static final String NS = "http://purl.org/dc/terms/";
086  private static final URI NS_URI = URI.create(NS);
087  public final String[] alternatives;
088
089  @Override
090  public String toString() {
091    return prefixedName();
092  }
093
094  @Override
095  public String simpleName() {
096    if (this == abstract_) {
097      return "abstract";
098    }
099    return name();
100  }
101
102  @Override
103  public String[] alternativeNames() {
104    return alternatives;
105  }
106
107  /**
108   * @return true if the dc term is defining a class instead of a property, e.g. Location
109   */
110  @Override
111  public boolean isClass() {
112    return Character.isUpperCase(simpleName().charAt(0));
113  }
114
115  @Override
116  public String prefix() {
117    return PREFIX;
118  }
119
120  @Override
121  public URI namespace() {
122    return NS_URI;
123  }
124
125  DcTerm(String... alternatives) {
126    this.alternatives = alternatives;
127  }
128
129}