Class DocViewProperty


  • public class DocViewProperty
    extends Object
    Helper class that represents a (jcr) property in the document view format. It contains formatting and parsing methods for writing/reading enhanced docview properties. prop:= [ "{" type "}" ] ( value | "[" [ value { "," value } ] "]" )
    • Field Detail

      • name

        public final String name
        name of the property
      • values

        public final String[] values
        value(s) of the property. always contains at least one value if this is not a mv property.
      • isMulti

        public final boolean isMulti
        indicates a MV property
      • type

        public final int type
        type of this property (can be undefined)
      • isReferenceProperty

        public final boolean isReferenceProperty
        indicates a binary ref property
    • Constructor Detail

      • DocViewProperty

        public DocViewProperty​(String name,
                               String[] values,
                               boolean multi,
                               int type)
        Creates a new property.
        Parameters:
        name - name of the property
        values - values.
        multi - multiple flag
        type - type of the property
        Throws:
        IllegalArgumentException - if single value property and not exactly 1 value is given.
      • DocViewProperty

        public DocViewProperty​(String name,
                               String[] values,
                               boolean multi,
                               int type,
                               boolean isRef)
        Creates a new property.
        Parameters:
        name - name of the property
        values - values.
        multi - multiple flag
        type - type of the property
        isRef - true to indicated that this is a binary reference property
        Throws:
        IllegalArgumentException - if single value property and not exactly 1 value is given.
    • Method Detail

      • parse

        public static DocViewProperty parse​(String name,
                                            String value)
        Parses a enhanced docview property string and returns the property.
        Parameters:
        name - name of the property
        value - (attribute) value
        Returns:
        a property
      • format

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

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

        public static boolean isAmbiguous​(Property prop)
                                   throws RepositoryException
        Checks if the type of the given property is ambiguous in respect to it's property definition. the current implementation just checks some well known properties.
        Parameters:
        prop - the property
        Returns:
        type
        Throws:
        RepositoryException - if a repository error occurs
      • apply

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

        public int hashCode()
        Overrides:
        hashCode in class Object