com.day.jcr.vault.util
Class DocViewProperty

java.lang.Object
  extended by com.day.jcr.vault.util.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 Summary
 boolean isMulti
          indicates a MV property
 String name
          name of the property
 int type
          type of this property (can be undefined)
 String[] values
          value(s) of the property.
 
Constructor Summary
DocViewProperty(String name, String[] values, boolean multi, int type)
          Creates a new property.
 
Method Summary
 boolean apply(Node node)
          Sets this property on the given node
protected static void escape(StringBuffer buf, String value, boolean isMulti)
          Escapes the value
static String format(Property prop)
          Formats the given jcr property to the enhanced docview syntax.
static String format(Property prop, boolean sort)
          Formats the given jcr property to the enhanced docview syntax.
static boolean isAmbiguous(Property prop)
          Checks if the type of the given property is ambiguous in respect to it's property definition.
static DocViewProperty parse(String name, String value)
          Parses a enhanced docview property string and returns the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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)

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.
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)
                     throws RepositoryException
Formats the given jcr property to the enhanced docview syntax.

Parameters:
prop - the jcr property
sort - if true multivalue properties are sorted
Returns:
the formatted string
Throws:
RepositoryException - if a repository error occurs

escape

protected static void escape(StringBuffer buf,
                             String value,
                             boolean isMulti)
Escapes the value

Parameters:
buf - buffer to append to
value - value to escape
isMulti - indicates multi value property

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


Copyright © 2011-2013 Adobe Systems Incorporated. All Rights Reserved.