Package org.apache.jackrabbit.vault.util
Class DocViewProperty2
- java.lang.Object
 - 
- org.apache.jackrabbit.vault.util.DocViewProperty2
 
 
- 
public class DocViewProperty2 extends java.lang.ObjectImmutable helper class that represents a JCR property in the FileVault (enhanced) document view format. It contains formatting and parsing methods for serializing/deserializing enhanced docview properties.
The string representation adheres to the following grammar:prop:= [ "{" type "}" ] ( value | "[" [ value { "," value } ] "]" ) type :=PropertyType.nameFromValue(int)|BINARY_REFvalue := 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
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBINARY_REF 
- 
Constructor Summary
Constructors Constructor Description DocViewProperty2(@NotNull Name name, @NotNull java.lang.String value)Creates a new single-value property with an undefined type.DocViewProperty2(@NotNull Name name, @NotNull java.lang.String value, int type)Creates a new single-value property.DocViewProperty2(@NotNull Name name, @NotNull java.util.List<java.lang.String> values)Creates a new multi-value property with an undefined type.DocViewProperty2(@NotNull Name name, @NotNull java.util.List<java.lang.String> values, int type)Creates a new multi-value property. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(@NotNull javax.jcr.Node node)Sets this property on the given node.booleanequals(java.lang.Object obj)static @NotNull java.lang.Stringformat(@NotNull javax.jcr.Property prop)Formats (serializes) the given JCR property value according to the enhanced docview syntax.static @NotNull java.lang.Stringformat(@NotNull javax.jcr.Property prop, boolean sort, boolean useBinaryReferences)Formats (serializes) the given JCR property value to the enhanced docview syntax.@NotNull java.lang.StringformatValue()Generates string representation of this DocView property value.static @NotNull DocViewProperty2fromProperty(@NotNull javax.jcr.Property prop, boolean sort, boolean useBinaryReferences)Creates a new property based on a JCRPropertyobject.static @NotNull DocViewProperty2fromValues(@NotNull Name name, @NotNull javax.jcr.Value[] values, int type, boolean isMulti, boolean sort, boolean useBinaryReferences)Creates a new property based on an array ofValues@NotNull NamegetName()@NotNull java.util.Optional<java.lang.String>getStringValue()@NotNull java.util.List<java.lang.String>getStringValues()intgetType()@NotNull java.util.Optional<javax.jcr.Value>getValue(@NotNull javax.jcr.ValueFactory valueFactory)@NotNull java.util.List<javax.jcr.Value>getValues(@NotNull javax.jcr.ValueFactory valueFactory)inthashCode()booleanisMultiValue()booleanisReferenceProperty()static @NotNull DocViewProperty2parse(java.lang.String name, java.lang.String value, NameResolver nameResolver)Parses a enhanced docview property string and returns the property.static @NotNull DocViewProperty2parse(Name name, java.lang.String value)Parses a enhanced docview property string and returns the property.java.lang.StringtoString()This does not return the string representation of the enhanced docview property value but rather a descriptive string including the property name for debugging purposes. 
 - 
 
- 
- 
Field Detail
- 
BINARY_REF
public static final java.lang.String BINARY_REF
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
DocViewProperty2
public DocViewProperty2(@NotNull @NotNull Name name, @NotNull @NotNull java.lang.String value, int type)Creates a new single-value property.- Parameters:
 name- name of the propertyvalue- valuetype- type of the property
 
- 
DocViewProperty2
public DocViewProperty2(@NotNull @NotNull Name name, @NotNull @NotNull java.lang.String value)Creates a new single-value property with an undefined type.- Parameters:
 name- name of the propertyvalue- value
 
- 
DocViewProperty2
public DocViewProperty2(@NotNull @NotNull Name name, @NotNull @NotNull java.util.List<java.lang.String> values, int type)Creates a new multi-value property.- Parameters:
 name- name of the propertyvalues- valuestype- type of the property
 
- 
DocViewProperty2
public DocViewProperty2(@NotNull @NotNull Name name, @NotNull @NotNull java.util.List<java.lang.String> values)Creates a new multi-value property with an undefined type.- Parameters:
 name- name of the propertyvalues- values
 
 - 
 
- 
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 ofValues- Parameters:
 name- the name of the propertyvalues- the values (always an array, may be empty), must not containnullitemstype- the type of the propertyisMulti-truein case this is a multivalue propertysort-truein case the value array should be sorted firstuseBinaryReferences- 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 JCRPropertyobject.- Parameters:
 prop- the JCR propertysort- iftruemulti-value properties should be sorteduseBinaryReferences-trueto use binary references- Returns:
 - the new property
 - Throws:
 java.lang.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(java.lang.String name, java.lang.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:
 java.lang.IllegalArgumentException- in case the given value does not follow the doc view property grammarjavax.jcr.NamespaceExceptionIllegalNameException
 
- 
parse
@NotNull public static @NotNull DocViewProperty2 parse(Name name, java.lang.String value) throws IllegalNameException, javax.jcr.NamespaceException
Parses a enhanced docview property string and returns the property.- Parameters:
 name- name of the propertyvalue- (attribute) value- Returns:
 - a property
 - Throws:
 java.lang.IllegalArgumentException- in case the given value does not follow the doc view property grammarjavax.jcr.NamespaceExceptionIllegalNameException
 
- 
format
@NotNull public static @NotNull java.lang.String format(@NotNull @NotNull javax.jcr.Property prop) throws javax.jcr.RepositoryExceptionFormats (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 java.lang.String format(@NotNull @NotNull javax.jcr.Property prop, boolean sort, boolean useBinaryReferences) throws javax.jcr.RepositoryExceptionFormats (serializes) the given JCR property value to the enhanced docview syntax.- Parameters:
 prop- the JCR propertysort- iftruemulti-value properties are sorteduseBinaryReferences-trueto use binary references- Returns:
 - the formatted string of the property value
 - Throws:
 javax.jcr.RepositoryException- if a repository error occurs
 
- 
formatValue
@NotNull public @NotNull java.lang.String formatValue()
Generates string representation of this DocView property value.- Returns:
 - the string representation of the value
 
 
- 
apply
public boolean apply(@NotNull @NotNull javax.jcr.Node node) throws javax.jcr.RepositoryExceptionSets this property on the given node.- Parameters:
 node- the node- Returns:
 trueif the value was modified.- Throws:
 javax.jcr.RepositoryException- if a repository error occurs
 
- 
hashCode
public int hashCode()
- Overrides:
 hashCodein classjava.lang.Object
 
- 
equals
public boolean equals(java.lang.Object obj)
- Overrides:
 equalsin classjava.lang.Object
 
- 
toString
public java.lang.String toString()
This does not return the string representation of the enhanced docview property value but rather a descriptive string including the property name for debugging purposes. UseformatValue(),format(Property)orformat(Property, boolean, boolean)to get the enhanced docview string representation of the value.- Overrides:
 toStringin classjava.lang.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 java.util.Optional<java.lang.String> getStringValue()
 
- 
getStringValues
@NotNull public @NotNull java.util.List<java.lang.String> getStringValues()
 
- 
getValue
@NotNull public @NotNull java.util.Optional<javax.jcr.Value> getValue(@NotNull @NotNull javax.jcr.ValueFactory valueFactory) throws javax.jcr.ValueFormatException- Parameters:
 valueFactory- the value factory to use for converting the underlying string to the JCR value- Returns:
 - the value or empty if no value set. For multi value only the first item is returned
 - Throws:
 javax.jcr.ValueFormatException- Since:
 - 3.7.0
 
 
- 
getValues
@NotNull public @NotNull java.util.List<javax.jcr.Value> getValues(@NotNull @NotNull javax.jcr.ValueFactory valueFactory) throws javax.jcr.ValueFormatException- Parameters:
 valueFactory- the value factory to use for converting the underlying string to the JCR value- Returns:
 - the list of values, may be empty. In case of single value entry just a single value list.
 - Throws:
 javax.jcr.ValueFormatException- Since:
 - 3.7.0
 
 
 - 
 
 -