Class DocViewProperty2


  • public class DocViewProperty2
    extends Object
    Helper class that represents a JCR property in the FileVault (enhanced) document view format. It contains formatting and parsing methods for writing/reading enhanced docview properties.
    The string representation adheres to the following grammar:
     prop:= [ "{" type "}" ] ( value | "[" [ value { "," value } ] "]" )
     type := PropertyType.nameFromValue(int) | BINARY_REF
     value := is a string representation of the value where the following characters are escaped: ',\[{' with a leading '\'
     
     
    Since:
    3.6.0
    See Also:
    FileVault Document View Format
    • Constructor Detail

      • DocViewProperty2

        public DocViewProperty2​(@NotNull
                                @NotNull Name name,
                                @NotNull
                                @NotNull String value,
                                int type)
        Creates a new single-value property.
        Parameters:
        name - name of the property
        value - value
        type - type of the property
      • DocViewProperty2

        public DocViewProperty2​(@NotNull
                                @NotNull Name name,
                                @NotNull
                                @NotNull String value)
        Creates a new single-value property with an undefined type.
        Parameters:
        name - name of the property
        value - value
      • DocViewProperty2

        public DocViewProperty2​(@NotNull
                                @NotNull Name name,
                                @NotNull
                                @NotNull List<String> values,
                                int type)
        Creates a new multi-value property.
        Parameters:
        name - name of the property
        values - values
        type - type of the property
      • DocViewProperty2

        public DocViewProperty2​(@NotNull
                                @NotNull Name name,
                                @NotNull
                                @NotNull List<String> values)
        Creates a new multi-value property with an undefined type.
        Parameters:
        name - name of the property
        values - values
      • DocViewProperty2

        protected DocViewProperty2​(@NotNull
                                   @NotNull Name name,
                                   @NotNull
                                   @NotNull List<String> values,
                                   boolean isMultiValue,
                                   int type,
                                   boolean isRef)
        Creates a new property.
        Parameters:
        name - name of the property
        values - string representation of values
        isMultiValue - indicates if this is a multi-value property
        type - type of the property
        isRef - true to indicate that this is a binary reference property
        Throws:
        IllegalArgumentException - if single value property and not exactly 1 value is given
    • Method Detail

      • fromValues

        @NotNull
        public static @NotNull DocViewProperty2 fromValues​(@NotNull
                                                           @NotNull Name name,
                                                           @NotNull
                                                           @NotNull javax.jcr.Value[] values,
                                                           int type,
                                                           boolean isMulti,
                                                           boolean sort,
                                                           boolean useBinaryReferences)
                                                    throws javax.jcr.RepositoryException
        Creates a new property based on an array of Values
        Parameters:
        name - the name of the property
        values - the values (always an array, may be empty), must not contain null items
        type - the type of the property
        isMulti - true in case this is a multivalue property
        sort - true in case the value array should be sorted first
        useBinaryReferences - to use the binary reference as value (if available)
        Returns:
        the new property
        Throws:
        javax.jcr.RepositoryException
      • fromProperty

        @NotNull
        public static @NotNull DocViewProperty2 fromProperty​(@NotNull
                                                             @NotNull javax.jcr.Property prop,
                                                             boolean sort,
                                                             boolean useBinaryReferences)
                                                      throws javax.jcr.RepositoryException
        Creates a new property based on a JCR Property object.
        Parameters:
        prop - the JCR property
        sort - if true multi-value properties should be sorted
        useBinaryReferences - true to use binary references
        Returns:
        the new property
        Throws:
        IllegalArgumentException - if single value property and not exactly 1 value is given.
        javax.jcr.RepositoryException - if another error occurs
      • parse

        @NotNull
        public static @NotNull DocViewProperty2 parse​(String name,
                                                      String value,
                                                      NameResolver nameResolver)
                                               throws IllegalNameException,
                                                      javax.jcr.NamespaceException
        Parses a enhanced docview property string and returns the property.
        Parameters:
        name - name of the property (either in qualified or extended form)
        value - (attribute) value
        Returns:
        a property
        Throws:
        IllegalArgumentException - in case the given value does not follow the doc view property grammar
        javax.jcr.NamespaceException
        IllegalNameException
      • parse

        @NotNull
        public static @NotNull DocViewProperty2 parse​(Name name,
                                                      String value)
                                               throws IllegalNameException,
                                                      javax.jcr.NamespaceException
        Parses a enhanced docview property string and returns the property.
        Parameters:
        name - name of the property
        value - (attribute) value
        Returns:
        a property
        Throws:
        IllegalArgumentException - in case the given value does not follow the doc view property grammar
        javax.jcr.NamespaceException
        IllegalNameException
      • format

        @NotNull
        public static @NotNull String format​(@NotNull
                                             @NotNull javax.jcr.Property prop)
                                      throws javax.jcr.RepositoryException
        Formats (serializes) the given JCR property value according to the enhanced docview syntax.
        Parameters:
        prop - the JCR property
        Returns:
        the formatted string of the property value
        Throws:
        javax.jcr.RepositoryException - if a repository error occurs
      • format

        @NotNull
        public static @NotNull String format​(@NotNull
                                             @NotNull javax.jcr.Property prop,
                                             boolean sort,
                                             boolean useBinaryReferences)
                                      throws javax.jcr.RepositoryException
        Formats (serializes) the given JCR property value to the enhanced docview syntax.
        Parameters:
        prop - the JCR property
        sort - if true multi-value properties are sorted
        useBinaryReferences - true to use binary references
        Returns:
        the formatted string of the property value
        Throws:
        javax.jcr.RepositoryException - if a repository error occurs
      • formatValue

        @NotNull
        public @NotNull String formatValue()
        Generates string representation of this DocView property value.
        Returns:
        the string representation of the value
      • escape

        @Deprecated
        protected static void escape​(StringBuffer buf,
                                     String value,
                                     boolean isMultiValue)
        Deprecated.
        Escapes the value
        Parameters:
        buf - buffer to append to
        value - value to escape
        isMultiValue - indicates multi-value property
      • escape

        protected static String escape​(String value,
                                       boolean isMultiValue)
        Escapes the value
        Parameters:
        value - value to escape
        isMultiValue - indicates multi-value property
        Returns:
        the escaped value
      • apply

        public boolean apply​(@NotNull
                             @NotNull javax.jcr.Node node)
                      throws javax.jcr.RepositoryException
        Sets this property on the given node.
        Parameters:
        node - the node
        Returns:
        true if the value was modified.
        Throws:
        javax.jcr.RepositoryException - if a repository error occurs
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getName

        @NotNull
        public @NotNull Name getName()
      • isMultiValue

        public boolean isMultiValue()
      • isReferenceProperty

        public boolean isReferenceProperty()
      • getType

        public int getType()
        Returns:
        one of the values defined in PropertyType
      • getStringValue

        @NotNull
        public @NotNull Optional<String> getStringValue()
      • getStringValues

        @NotNull
        public @NotNull List<String> getStringValues()