Class MetadataSet

java.lang.Object
com.adobe.epubcheck.opf.MetadataSet

public final class MetadataSet extends Object
Represents a set of metadata as declared in the metadata element in an EPUB Publication document (OPF).

The graph of refines is resolved when building the metadata set.

  • Field Details

  • Constructor Details

  • Method Details

    • getPrimary

      public Set<MetadataSet.Metadata> getPrimary()
      Returns a set of all primary metadata expressions.
      Returns:
      an immutable set (possibly empty) of all primary metadata expressions.
    • getAll

      public Set<MetadataSet.Metadata> getAll()
      Returns a set of all metadata expressions (primary+subexpressions).
      Returns:
      an immutable set (possibly empty) of all metadata expressions.
    • containsPrimary

      public boolean containsPrimary(Property property)
      Returns true if this metadata set contains a primary expression for the given property
      Parameters:
      property - a property from a metadata vocabulary
      Returns:
      true if this metadata set contains a primary expression for the given property
    • containsPrimary

      public boolean containsPrimary(Property property, String value)
      Returns true if this metadata set contains a primary expression for the given property and the given value
      Parameters:
      property - a property from a metadata vocabulary
      value - the value to search
      Returns:
      true if this metadata set contains a primary expression for the given property and value
    • containsAny

      public boolean containsAny(Property property)
      Returns true if this metadata set contains an expression (primary or subexpression) for the given property
      Parameters:
      property - a property from a metadata vocabulary
      Returns:
      true if this metadata set contains an expression for the given property
    • getPrimary

      public Set<MetadataSet.Metadata> getPrimary(Property property)
      Returns the set of metadata primary expressions for the given property.
      Parameters:
      property - a property from a metadata vocabulary
      Returns:
      the set of metadata primary expressions for the given property, or an empty set if none exist.
    • getAny

      public Set<MetadataSet.Metadata> getAny(Property property)
      Returns the set of all metadata expressions (primary and subexpressions) for the given property.
      Parameters:
      property - a property from a metadata vocabulary
      Returns:
      the set of all metadata expressions for the given property, or an empty set if none exist.
    • getRefinedBy

      public com.google.common.base.Optional<MetadataSet.Metadata> getRefinedBy(MetadataSet.Metadata meta)
      Returns an optional metadata expression refined by the given metadata expression.
      Parameters:
      meta - a metadata expression
      Returns:
      Optional.absent() if the given metadata expression does not refine another metadata expression or a
      invalid reference
      Optional#of(Metadata)
      containing the refined metadata expression
    • getRefining

      public Set<MetadataSet.Metadata> getRefining(String id)
      Returns the set of all metadata subexpressions refining the metadata or resource identified by the given ID.
      Parameters:
      id - a string ID
      Returns:
      the set of all metadata subexpressions refining the given ID, or an empty set if none exist.
    • tryFindInRefines

      public static com.google.common.base.Optional<MetadataSet.Metadata> tryFindInRefines(Set<MetadataSet.Metadata> metas, Property property, com.google.common.base.Optional<String> value)
      Search all refining expressions of the given metadata expressions, and return the first one that matches the given property and value (if present).

      If value is Optional.absent()

      , only the property is used in the lookup.
      Parameters:
      metas - A set of metadata expressions to search
      property - The property of the searched expression
      value - The value of the searched expression, can be absent if the value is not relevant in the search
      Returns:
      an Optional containing an expression refining one of the expressions in metas and matching the given property and value, or Optional.absent() if none is found.
    • tryFind

      public static com.google.common.base.Optional<MetadataSet.Metadata> tryFind(Set<MetadataSet.Metadata> metas, Property property, com.google.common.base.Optional<String> value)
      Search all the given expressions and return the first one that matches the given property and value (if present).

      If value is Optional.absent()

      , only the property is used in the lookup.
      Parameters:
      metas - A set of metadata expressions to search
      property - The property of the searched expression
      value - The value of the searched expression, can be absent if the value is not relevant in the search
      Returns:
      an Optional containing an expression in the metas set matching the given property and value, or Optional.absent() if none is found.
    • builder

      public static MetadataSet.Builder builder()
      Creates a new builder. Calling this method is identical to calling the empty MetadataSet.Builder constructor.
      Returns:
      a newly created builder.