Package org.apache.jackrabbit.vault.util
Class DocViewProperty2
java.lang.Object
org.apache.jackrabbit.vault.util.DocViewProperty2
Immutable 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:
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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionDocViewProperty2(@NotNull Name name, @NotNull String value) Creates a new single-value property with an undefined type.DocViewProperty2(@NotNull Name name, @NotNull String value, int type) Creates a new single-value property.DocViewProperty2(@NotNull Name name, @NotNull List<String> values) Creates a new multi-value property with an undefined type.protectedDocViewProperty2(@NotNull Name name, @NotNull List<String> values, boolean isMultiValue, int type, boolean isRef) Creates a new property.DocViewProperty2(@NotNull Name name, @NotNull List<String> values, int type) Creates a new multi-value property. -
Method Summary
Modifier and TypeMethodDescriptionbooleanSets this property on the given node.booleanprotected static voidescape(StringBuffer buf, String value, boolean isMultiValue) Deprecated.protected static StringEscapes the valuestatic @NotNull StringFormats (serializes) the given JCR property value according to the enhanced docview syntax.static @NotNull StringFormats (serializes) the given JCR property value to the enhanced docview syntax.@NotNull StringGenerates string representation of this DocView property value.static @NotNull DocViewProperty2fromProperty(@NotNull Property prop, boolean sort, boolean useBinaryReferences) Creates a new property based on a JCRPropertyobject.static @NotNull DocViewProperty2fromValues(@NotNull Name name, @NotNull Value[] values, int type, boolean isMulti, boolean sort, boolean useBinaryReferences) Creates a new property based on an array ofValues@NotNull NamegetName()intgetType()getValue(@NotNull ValueFactory valueFactory) getValues(@NotNull ValueFactory valueFactory) inthashCode()booleanbooleanstatic @NotNull DocViewProperty2parse(String name, String value, NameResolver nameResolver) Parses a enhanced docview property string and returns the property.static @NotNull DocViewProperty2Parses a enhanced docview property string and returns the property.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.
-
Field Details
-
BINARY_REF
- See Also:
-
-
Constructor Details
-
DocViewProperty2
Creates a new single-value property.- Parameters:
name- name of the propertyvalue- valuetype- type of the property
-
DocViewProperty2
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 List<String> values, int type) Creates a new multi-value property.- Parameters:
name- name of the propertyvalues- valuestype- type of the property
-
DocViewProperty2
Creates a new multi-value property with an undefined type.- Parameters:
name- name of the propertyvalues- 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 propertyvalues- string representation of valuesisMultiValue- indicates if this is a multi-value propertytype- type of the propertyisRef-trueto indicate that this is a binary reference property- Throws:
IllegalArgumentException- if single value property and not exactly 1 value is given
-
-
Method Details
-
fromValues
@NotNull public static @NotNull DocViewProperty2 fromValues(@NotNull @NotNull Name name, @NotNull @NotNull Value[] values, int type, boolean isMulti, boolean sort, boolean useBinaryReferences) throws 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:
RepositoryException
-
fromProperty
@NotNull public static @NotNull DocViewProperty2 fromProperty(@NotNull @NotNull Property prop, boolean sort, boolean useBinaryReferences) throws 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:
IllegalArgumentException- if single value property and not exactly 1 value is given.RepositoryException- if another error occurs
-
parse
@NotNull public static @NotNull DocViewProperty2 parse(String name, String value, NameResolver nameResolver) throws IllegalNameException, 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 grammarNamespaceExceptionIllegalNameException
-
parse
@NotNull public static @NotNull DocViewProperty2 parse(Name name, String value) throws IllegalNameException, NamespaceException Parses a enhanced docview property string and returns the property.- Parameters:
name- name of the propertyvalue- (attribute) value- Returns:
- a property
- Throws:
IllegalArgumentException- in case the given value does not follow the doc view property grammarNamespaceExceptionIllegalNameException
-
format
@NotNull public static @NotNull String format(@NotNull @NotNull Property prop) throws 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:
RepositoryException- if a repository error occurs
-
format
@NotNull public static @NotNull String format(@NotNull @NotNull Property prop, boolean sort, boolean useBinaryReferences) throws RepositoryException Formats (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:
RepositoryException- if a repository error occurs
-
formatValue
Generates string representation of this DocView property value.- Returns:
- the string representation of the value
-
escape
Deprecated.Rather useescape(String, boolean)Escapes the value- Parameters:
buf- buffer to append tovalue- value to escapeisMultiValue- indicates multi-value property
-
escape
Escapes the value- Parameters:
value- value to escapeisMultiValue- indicates multi-value property- Returns:
- the escaped value
-
apply
Sets this property on the given node.- Parameters:
node- the node- Returns:
trueif the value was modified.- Throws:
RepositoryException- if a repository error occurs
-
hashCode
public int hashCode() -
equals
-
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. -
getName
-
isMultiValue
public boolean isMultiValue() -
isReferenceProperty
public boolean isReferenceProperty() -
getType
public int getType()- Returns:
- one of the values defined in
PropertyType
-
getStringValue
-
getStringValues
-
getValue
@NotNull public @NotNull Optional<Value> getValue(@NotNull @NotNull ValueFactory valueFactory) throws 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:
ValueFormatException- Since:
- 3.7.0
-
getValues
@NotNull public @NotNull List<Value> getValues(@NotNull @NotNull ValueFactory valueFactory) throws 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:
ValueFormatException- Since:
- 3.7.0
-
escape(String, boolean)