Class VocabUtil


  • public final class VocabUtil
    extends java.lang.Object
    Utilities related to property values, vocabularies, and prefix declarations.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  VocabUtil.EMPTY  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private VocabUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​Vocab> parsePrefixDeclaration​(java.lang.String value, java.util.Map<java.lang.String,​? extends Vocab> predefined, java.util.Map<java.lang.String,​? extends Vocab> known, java.util.Set<java.lang.String> forbidden, Report report, EPUBLocation location)
      Parses a prefix attribute value and returns a map of prefixes to vocabularies, given a pre-existing set of reserved prefixes, known vocabularies, and default vocabularies that cannot be re-declared.
      private static java.util.Set<Property> parseProperties​(java.lang.String value, java.util.Map<java.lang.String,​? extends Vocab> vocabs, boolean isList, ValidationContext context, EPUBLocation location)  
      static com.google.common.base.Optional<Property> parseProperty​(java.lang.String value, java.util.Map<java.lang.String,​Vocab> vocabs, ValidationContext context, EPUBLocation location)
      Parses a single property value and report validation errors on the fly.
      static java.util.Set<Property> parsePropertyList​(java.lang.String value, java.util.Map<java.lang.String,​? extends Vocab> vocabs, ValidationContext context, EPUBLocation location)
      Parses a space-separated list of property values, and report validation errors on the fly.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY_VOCAB

        public static Vocab EMPTY_VOCAB
      • propertyPattern

        private static java.util.regex.Pattern propertyPattern
      • whitespaceSplitter

        private static com.google.common.base.Splitter whitespaceSplitter
    • Constructor Detail

      • VocabUtil

        private VocabUtil()
    • Method Detail

      • parseProperty

        public static com.google.common.base.Optional<Property> parseProperty​(java.lang.String value,
                                                                              java.util.Map<java.lang.String,​Vocab> vocabs,
                                                                              ValidationContext context,
                                                                              EPUBLocation location)
        Parses a single property value and report validation errors on the fly.
        Parameters:
        value - the value to parse.
        vocabs - a map of prefix to vocabularies.
        context - the validation context (report, locale, path, etc).
        location - the location in the validated file.
        Returns:
        an Optional containing the property if it was parsed successfully or nothing if there was a parsing error
      • parsePropertyList

        public static java.util.Set<Property> parsePropertyList​(java.lang.String value,
                                                                java.util.Map<java.lang.String,​? extends Vocab> vocabs,
                                                                ValidationContext context,
                                                                EPUBLocation location)
        Parses a space-separated list of property values, and report validation errors on the fly.
        Parameters:
        value - the value to parse.
        vocabs - a map of prefix to vocabularies.
        context - the validation context (report, locale, path, etc).
        location - the location in the validated file.
        Returns:
      • parseProperties

        private static java.util.Set<Property> parseProperties​(java.lang.String value,
                                                               java.util.Map<java.lang.String,​? extends Vocab> vocabs,
                                                               boolean isList,
                                                               ValidationContext context,
                                                               EPUBLocation location)
      • parsePrefixDeclaration

        public static java.util.Map<java.lang.String,​Vocab> parsePrefixDeclaration​(java.lang.String value,
                                                                                         java.util.Map<java.lang.String,​? extends Vocab> predefined,
                                                                                         java.util.Map<java.lang.String,​? extends Vocab> known,
                                                                                         java.util.Set<java.lang.String> forbidden,
                                                                                         Report report,
                                                                                         EPUBLocation location)
        Parses a prefix attribute value and returns a map of prefixes to vocabularies, given a pre-existing set of reserved prefixes, known vocabularies, and default vocabularies that cannot be re-declared.
        Parameters:
        value - the prefix declaration to parse.
        predefined - a map of reserved prefixes to associated vocabularies.
        known - a map of known URIs to known vocabularies.
        forbidden - a set of URIs of default vocabularies that cannot be re-declared.
        report - to report errors on the fly.
        location - the location of the attribute in the source file.
        Returns: