Package org.apache.jackrabbit.value
Class ValueHelper
- java.lang.Object
-
- org.apache.jackrabbit.value.ValueHelper
-
public class ValueHelper extends java.lang.ObjectTheValueHelperclass provides severalValuerelated utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckSupportedConversion(int fromType, int toType)static javax.jcr.Value[]convert(java.io.InputStream[] srcValues, int targetType, javax.jcr.ValueFactory factory)static javax.jcr.Valueconvert(java.io.InputStream srcValue, int targetType, javax.jcr.ValueFactory factory)static javax.jcr.Value[]convert(java.lang.String[] srcValues, int targetType, javax.jcr.ValueFactory factory)Same asconvert(String[], int, ValueFactory)usingValueFactoryImpl.static javax.jcr.Valueconvert(java.lang.String srcValue, int targetType, javax.jcr.ValueFactory factory)static javax.jcr.Value[]convert(javax.jcr.Value[] srcValues, int targetType, javax.jcr.ValueFactory factory)static javax.jcr.Valueconvert(javax.jcr.Value srcValue, int targetType, javax.jcr.ValueFactory factory)Converts the given value to a value of the specified target type.static javax.jcr.Value[]copy(javax.jcr.Value[] srcValues, javax.jcr.ValueFactory factory)static javax.jcr.Valuecopy(javax.jcr.Value srcValue, javax.jcr.ValueFactory factory)static javax.jcr.Valuedeserialize(java.io.Reader reader, int type, boolean decodeBlanks, javax.jcr.ValueFactory factory)Deserializes the string data read from the given reader to aValueof the given type.static javax.jcr.Valuedeserialize(java.lang.String value, int type, boolean decodeBlanks, javax.jcr.ValueFactory factory)Deserializes the given string to aValueof the given type.static intgetType(javax.jcr.Value[] values)Determine thePropertyTypeof the passed values if all are of the same type.static booleanisSupportedConversion(int fromType, int toType)static java.lang.Stringserialize(javax.jcr.Value value, boolean encodeBlanks)Serializes the given value to aString.static voidserialize(javax.jcr.Value value, boolean encodeBlanks, boolean enforceBase64, java.io.Writer writer)Outputs the serialized value to aWriter.
-
-
-
Method Detail
-
isSupportedConversion
public static boolean isSupportedConversion(int fromType, int toType)
-
checkSupportedConversion
public static void checkSupportedConversion(int fromType, int toType) throws javax.jcr.ValueFormatException- Throws:
javax.jcr.ValueFormatException
-
convert
public static javax.jcr.Value convert(java.lang.String srcValue, int targetType, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, java.lang.IllegalArgumentException- Parameters:
srcValue-targetType-factory-- Throws:
javax.jcr.ValueFormatExceptionjava.lang.IllegalArgumentException- See Also:
convert(Value, int, ValueFactory)
-
convert
public static javax.jcr.Value convert(java.io.InputStream srcValue, int targetType, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, java.lang.IllegalArgumentException- Parameters:
srcValue-targetType-factory-- Throws:
javax.jcr.ValueFormatExceptionjava.lang.IllegalArgumentException
-
convert
public static javax.jcr.Value[] convert(java.lang.String[] srcValues, int targetType, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, java.lang.IllegalArgumentExceptionSame asconvert(String[], int, ValueFactory)usingValueFactoryImpl.- Parameters:
srcValues-targetType-- Throws:
javax.jcr.ValueFormatExceptionjava.lang.IllegalArgumentException- See Also:
convert(Value, int, ValueFactory)
-
convert
public static javax.jcr.Value[] convert(java.io.InputStream[] srcValues, int targetType, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, java.lang.IllegalArgumentException- Parameters:
srcValues-targetType-- Throws:
javax.jcr.ValueFormatExceptionjava.lang.IllegalArgumentException- See Also:
convert(Value, int, ValueFactory)
-
convert
public static javax.jcr.Value[] convert(javax.jcr.Value[] srcValues, int targetType, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, java.lang.IllegalArgumentException- Parameters:
srcValues-targetType-factory-- Throws:
javax.jcr.ValueFormatExceptionjava.lang.IllegalArgumentException- See Also:
convert(Value, int, ValueFactory)
-
convert
public static javax.jcr.Value convert(javax.jcr.Value srcValue, int targetType, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, java.lang.IllegalStateException, java.lang.IllegalArgumentExceptionConverts the given value to a value of the specified target type. The conversion is performed according to the rules described in "3.6.4 Property Type Conversion" in the JSR 283 specification.- Parameters:
srcValue-targetType-factory-- Throws:
javax.jcr.ValueFormatExceptionjava.lang.IllegalStateExceptionjava.lang.IllegalArgumentException
-
copy
public static javax.jcr.Value copy(javax.jcr.Value srcValue, javax.jcr.ValueFactory factory) throws java.lang.IllegalStateException- Parameters:
srcValue-factory-- Throws:
java.lang.IllegalStateException
-
copy
public static javax.jcr.Value[] copy(javax.jcr.Value[] srcValues, javax.jcr.ValueFactory factory) throws java.lang.IllegalStateException- Parameters:
srcValues-factory-- Throws:
java.lang.IllegalStateException
-
serialize
public static java.lang.String serialize(javax.jcr.Value value, boolean encodeBlanks) throws java.lang.IllegalStateException, javax.jcr.RepositoryExceptionSerializes the given value to aString. The serialization format is the same as used by Document & System View XML, i.e. binary values will be Base64-encoded whereas for all otherswill be used.Value.getString()- Parameters:
value- the value to be serializedencodeBlanks- iftruespace characters will be encoded as"_x0020_"within he output string.- Returns:
- a string representation of the given value.
- Throws:
java.lang.IllegalStateException- if the given value is in an illegal statejavax.jcr.RepositoryException- if an error occured during the serialization.
-
serialize
public static void serialize(javax.jcr.Value value, boolean encodeBlanks, boolean enforceBase64, java.io.Writer writer) throws java.lang.IllegalStateException, java.io.IOException, javax.jcr.RepositoryExceptionOutputs the serialized value to aWriter. The serialization format is the same as used by Document & System View XML, i.e. binary values will be Base64-encoded whereas for all otherswill be used for serialization.Value.getString()- Parameters:
value- the value to be serializedencodeBlanks- iftruespace characters will be encoded as"_x0020_"within he output string.enforceBase64- iftrue, base64 encoding will always be usedwriter- writer to output the encoded data- Throws:
java.lang.IllegalStateException- if the given value is in an illegal statejava.io.IOException- if an i/o error occured during the serializationjavax.jcr.RepositoryException- if an error occured during the serialization.
-
deserialize
public static javax.jcr.Value deserialize(java.lang.String value, int type, boolean decodeBlanks, javax.jcr.ValueFactory factory) throws javax.jcr.ValueFormatException, javax.jcr.RepositoryExceptionDeserializes the given string to aValueof the given type.- Parameters:
value- string to be deserializedtype- type of valuedecodeBlanks- iftrue"_x0020_"character sequences will be decoded to single space characters each.factory- ValueFactory used to build theValueobject.- Returns:
- the deserialized
Value - Throws:
javax.jcr.ValueFormatException- if the string data is not of the required formatjavax.jcr.RepositoryException- if an error occured during the deserialization.
-
deserialize
public static javax.jcr.Value deserialize(java.io.Reader reader, int type, boolean decodeBlanks, javax.jcr.ValueFactory factory) throws java.io.IOException, javax.jcr.ValueFormatException, javax.jcr.RepositoryExceptionDeserializes the string data read from the given reader to aValueof the given type.- Parameters:
reader- reader for the string data to be deserializedtype- type of valuedecodeBlanks- iftrue"_x0020_"character sequences will be decoded to single space characters each.factory- ValueFactory used to build theValueobject.- Returns:
- the deserialized
Value - Throws:
java.io.IOException- if an i/o error occured during the serializationjavax.jcr.ValueFormatException- if the string data is not of the required formatjavax.jcr.RepositoryException- if an error occured during the deserialization.
-
getType
public static int getType(javax.jcr.Value[] values) throws javax.jcr.ValueFormatExceptionDetermine thePropertyTypeof the passed values if all are of the same type.- Parameters:
values- array of values of the same type- Returns:
PropertyType.UNDEFINEDifvaluesis empty,values[0].getType()otherwise.- Throws:
javax.jcr.ValueFormatException- if not allvaluesare of the same type
-
-