Package com.adobe.epubcheck.opf
Class MetadataSet
- java.lang.Object
-
- com.adobe.epubcheck.opf.MetadataSet
-
public final class MetadataSet extends java.lang.ObjectRepresents a set of metadata as declared in themetadataelement in an EPUB Publication document (OPF).The graph of refines is resolved when building the metadata set.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetadataSet.BuilderA builder for sets of metadata expressions.static classMetadataSet.MetadataRepresents a metadata expression.
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.SetMultimap<Property,MetadataSet.Metadata>allprivate com.google.common.base.Supplier<java.util.Set<MetadataSet.Metadata>>allSetprivate com.google.common.collect.SetMultimap<Property,MetadataSet.Metadata>primaryprivate com.google.common.base.Supplier<java.util.Set<MetadataSet.Metadata>>primarySetprivate com.google.common.collect.SetMultimap<java.lang.String,MetadataSet.Metadata>refinersprivate java.util.Map<MetadataSet.Metadata,MetadataSet.Metadata>refines
-
Constructor Summary
Constructors Modifier Constructor Description privateMetadataSet(com.google.common.collect.Multimap<Property,MetadataSet.Metadata> all, com.google.common.collect.Multimap<Property,MetadataSet.Metadata> primary, java.util.Map<MetadataSet.Metadata,MetadataSet.Metadata> refines, com.google.common.collect.Multimap<java.lang.String,MetadataSet.Metadata> refiners)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MetadataSet.Builderbuilder()Creates a new builder.booleancontainsAny(Property property)Returnstrueif this metadata set contains an expression (primary or subexpression) for the given propertybooleancontainsPrimary(Property property)Returnstrueif this metadata set contains a primary expression for the given propertybooleancontainsPrimary(Property property, java.lang.String value)Returnstrueif this metadata set contains a primary expression for the given property and the given valuejava.util.Set<MetadataSet.Metadata>getAll()Returns a set of all metadata expressions (primary+subexpressions).java.util.Set<MetadataSet.Metadata>getAny(Property property)Returns the set of all metadata expressions (primary and subexpressions) for the given property.java.util.Set<MetadataSet.Metadata>getPrimary()Returns a set of all primary metadata expressions.java.util.Set<MetadataSet.Metadata>getPrimary(Property property)Returns the set of metadata primary expressions for the given property.com.google.common.base.Optional<MetadataSet.Metadata>getRefinedBy(MetadataSet.Metadata meta)Returns an optional metadata expression refined by the given metadata expression.java.util.Set<MetadataSet.Metadata>getRefining(java.lang.String id)Returns the set of all metadata subexpressions refining the metadata or resource identified by the given ID.static com.google.common.base.Optional<MetadataSet.Metadata>tryFind(java.util.Set<MetadataSet.Metadata> metas, Property property, com.google.common.base.Optional<java.lang.String> value)Search all the given expressions and return the first one that matches the given property and value (if present).static com.google.common.base.Optional<MetadataSet.Metadata>tryFindInRefines(java.util.Set<MetadataSet.Metadata> metas, Property property, com.google.common.base.Optional<java.lang.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).
-
-
-
Field Detail
-
all
private final com.google.common.collect.SetMultimap<Property,MetadataSet.Metadata> all
-
primary
private final com.google.common.collect.SetMultimap<Property,MetadataSet.Metadata> primary
-
refiners
private final com.google.common.collect.SetMultimap<java.lang.String,MetadataSet.Metadata> refiners
-
refines
private final java.util.Map<MetadataSet.Metadata,MetadataSet.Metadata> refines
-
allSet
private final com.google.common.base.Supplier<java.util.Set<MetadataSet.Metadata>> allSet
-
primarySet
private final com.google.common.base.Supplier<java.util.Set<MetadataSet.Metadata>> primarySet
-
-
Constructor Detail
-
MetadataSet
private MetadataSet(com.google.common.collect.Multimap<Property,MetadataSet.Metadata> all, com.google.common.collect.Multimap<Property,MetadataSet.Metadata> primary, java.util.Map<MetadataSet.Metadata,MetadataSet.Metadata> refines, com.google.common.collect.Multimap<java.lang.String,MetadataSet.Metadata> refiners)
-
-
Method Detail
-
getPrimary
public java.util.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 java.util.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)
Returnstrueif this metadata set contains a primary expression for the given property- Parameters:
property- a property from a metadata vocabulary- Returns:
trueif this metadata set contains a primary expression for the given property
-
containsPrimary
public boolean containsPrimary(Property property, java.lang.String value)
Returnstrueif this metadata set contains a primary expression for the given property and the given value- Parameters:
property- a property from a metadata vocabularyvalue- the value to search- Returns:
trueif this metadata set contains a primary expression for the given property and value
-
containsAny
public boolean containsAny(Property property)
Returnstrueif this metadata set contains an expression (primary or subexpression) for the given property- Parameters:
property- a property from a metadata vocabulary- Returns:
trueif this metadata set contains an expression for the given property
-
getPrimary
public java.util.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 java.util.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 aOptional#of(Metadata)containing the refined metadata expression
-
getRefining
public java.util.Set<MetadataSet.Metadata> getRefining(java.lang.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(java.util.Set<MetadataSet.Metadata> metas, Property property, com.google.common.base.Optional<java.lang.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
, only the property is used in the lookup.valueisOptional.absent()- Parameters:
metas- A set of metadata expressions to searchproperty- The property of the searched expressionvalue- The value of the searched expression, can be absent if the value is not relevant in the search- Returns:
- an
Optionalcontaining an expression refining one of the expressions inmetasand matching the given property and value, orOptional.absent()if none is found.
-
tryFind
public static com.google.common.base.Optional<MetadataSet.Metadata> tryFind(java.util.Set<MetadataSet.Metadata> metas, Property property, com.google.common.base.Optional<java.lang.String> value)
Search all the given expressions and return the first one that matches the given property and value (if present).If
, only the property is used in the lookup.valueisOptional.absent()- Parameters:
metas- A set of metadata expressions to searchproperty- The property of the searched expressionvalue- The value of the searched expression, can be absent if the value is not relevant in the search- Returns:
- an
Optionalcontaining an expression in themetasset matching the given property and value, orOptional.absent()if none is found.
-
builder
public static MetadataSet.Builder builder()
Creates a new builder. Calling this method is identical to calling the emptyMetadataSet.Builderconstructor.- Returns:
- a newly created builder.
-
-