Package org.apache.jackrabbit.test.api
Class PropertyUtil
- java.lang.Object
-
- org.apache.jackrabbit.test.api.PropertyUtil
-
public class PropertyUtil extends Object
This class provides various utility methods that are used by the property test cases.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBASE_CHARstatic StringCOMBINING_CHARstatic StringDIGITstatic StringEXTENDERstatic StringIDEOGRAPHICstatic StringLETTERstatic StringNC_NAMEstatic PatternPATTERN_DATEstatic PatternPATTERN_NAMEstatic PatternPATTERN_PATHstatic StringPATTERNSTRING_DATEstatic StringPATTERNSTRING_NAMEstatic StringPATTERNSTRING_PATHstatic StringPATTERNSTRING_PATH_ELEMENTstatic StringPATTERNSTRING_PATH_WITHOUT_LAST_SLASHstatic StringSIMPLENAME_CHAR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancheckGetType(Property prop, int propType)Helper method to test the type received with Value.getType() and Property.getType() .static booleancheckNameFormat(String name, Session session)checks if the given name follows the NAME syntax rules and if a present prefix is mapped to a registered namespacestatic booleancheckPathFormat(String jcrPath, Session session)Checks if the given path follows the path syntax rules.static longcountBytes(Value val)Counts the number of bytes of a Binary value.static booleanequalValues(Value val1, Value val2)Helper method to compare the equality of two values for equality with the fulfilling of the equality conditions.static ValuegetValue(Property prop)Returns the value of a property.static booleanisDateFormat(String str)Checks if the String is a valid date in string format.static booleannullValues(Node node)Helper method to assure that no property with a null value exist.static PropertysearchMultivalProp(Node node)Helper method to find a multivalue property.static PropertysearchMultivalProp(Node node, int type)Helper method to find a multivalue property of a given type.static PropertysearchProp(Session session, Node node, int type, Boolean multiple)Traverses a tree below a given node searching for a property with a given typestatic PropertysearchSingleValuedProperty(Node node)Retrieve a single valued property from the given node.
-
-
-
Field Detail
-
BASE_CHAR
public static final String BASE_CHAR
- See Also:
- Constant Field Values
-
IDEOGRAPHIC
public static final String IDEOGRAPHIC
- See Also:
- Constant Field Values
-
COMBINING_CHAR
public static final String COMBINING_CHAR
- See Also:
- Constant Field Values
-
DIGIT
public static final String DIGIT
- See Also:
- Constant Field Values
-
EXTENDER
public static final String EXTENDER
- See Also:
- Constant Field Values
-
LETTER
public static final String LETTER
- See Also:
- Constant Field Values
-
NC_NAME
public static final String NC_NAME
- See Also:
- Constant Field Values
-
SIMPLENAME_CHAR
public static final String SIMPLENAME_CHAR
- See Also:
- Constant Field Values
-
PATTERNSTRING_NAME
public static final String PATTERNSTRING_NAME
- See Also:
- Constant Field Values
-
PATTERN_NAME
public static final Pattern PATTERN_NAME
-
PATTERNSTRING_PATH_ELEMENT
public static final String PATTERNSTRING_PATH_ELEMENT
- See Also:
- Constant Field Values
-
PATTERNSTRING_PATH_WITHOUT_LAST_SLASH
public static final String PATTERNSTRING_PATH_WITHOUT_LAST_SLASH
- See Also:
- Constant Field Values
-
PATTERNSTRING_PATH
public static final String PATTERNSTRING_PATH
- See Also:
- Constant Field Values
-
PATTERN_PATH
public static final Pattern PATTERN_PATH
-
PATTERNSTRING_DATE
public static final String PATTERNSTRING_DATE
- See Also:
- Constant Field Values
-
PATTERN_DATE
public static final Pattern PATTERN_DATE
-
-
Method Detail
-
searchProp
public static Property searchProp(Session session, Node node, int type, Boolean multiple) throws RepositoryException, ValueFormatException
Traverses a tree below a given node searching for a property with a given type- Parameters:
node- the node to start traversetype- the property type to search formultiple- whether the property should be multivalued (null: does not matter)- Returns:
- the property found or null if no property is found
- Throws:
RepositoryExceptionValueFormatException
-
getValue
public static Value getValue(Property prop) throws RepositoryException
Returns the value of a property. Ifpropis multi valued this method returns the first value.- Parameters:
prop- the property from which to return the value.- Returns:
- the value of the property.
- Throws:
RepositoryException
-
checkNameFormat
public static boolean checkNameFormat(String name, Session session) throws RepositoryException
checks if the given name follows the NAME syntax rules and if a present prefix is mapped to a registered namespace- Parameters:
name- the string to test- Throws:
RepositoryException
-
checkPathFormat
public static boolean checkPathFormat(String jcrPath, Session session) throws RepositoryException
Checks if the given path follows the path syntax rules.- Parameters:
jcrPath- the string to test- Throws:
RepositoryException
-
isDateFormat
public static boolean isDateFormat(String str)
Checks if the String is a valid date in string format.- Parameters:
str- the string to test.- Returns:
trueifstris a valid date format.
-
countBytes
public static long countBytes(Value val)
Counts the number of bytes of a Binary value.- Parameters:
val- the binary value.- Returns:
- the number of bytes or -1 in case of any exception
-
checkGetType
public static boolean checkGetType(Property prop, int propType) throws RepositoryException
Helper method to test the type received with Value.getType() and Property.getType() .- Throws:
RepositoryException
-
equalValues
public static boolean equalValues(Value val1, Value val2) throws RepositoryException
Helper method to compare the equality of two values for equality with the fulfilling of the equality conditions. These conditions for the values are to have the same type and the same string representation.- Parameters:
val1- first valueval2- second value- Returns:
- true if the equals method is equivalent to the normative definition of value equality, false in the other case.
- Throws:
RepositoryException
-
nullValues
public static boolean nullValues(Node node) throws RepositoryException
Helper method to assure that no property with a null value exist.- Parameters:
node- the node to start the search from.- Returns:
trueif a null value property is found;falsein the other case.- Throws:
RepositoryException
-
searchMultivalProp
public static Property searchMultivalProp(Node node) throws RepositoryException
Helper method to find a multivalue property.- Parameters:
node- the node to start the search from.- Returns:
- a multivalue property or null if not found any.
- Throws:
RepositoryException
-
searchMultivalProp
public static Property searchMultivalProp(Node node, int type) throws RepositoryException
Helper method to find a multivalue property of a given type.- Parameters:
node- the node to start the search from.type- the property type.- Returns:
- a multivalue property or null if not found any.
- Throws:
RepositoryException
-
searchSingleValuedProperty
public static Property searchSingleValuedProperty(Node node) throws RepositoryException, ValueFormatException
Retrieve a single valued property from the given node.- Parameters:
node-- Returns:
- the property found or null if no property is found.
- Throws:
RepositoryExceptionValueFormatException
-
-