Package org.apache.jackrabbit.value
Class ValueHelper
java.lang.Object
org.apache.jackrabbit.value.ValueHelper
The
ValueHelper class provides several Value
related utility methods.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckSupportedConversion(int fromType, int toType) static Value[]convert(InputStream[] srcValues, int targetType, ValueFactory factory) static Valueconvert(InputStream srcValue, int targetType, ValueFactory factory) static Value[]convert(String[] srcValues, int targetType, ValueFactory factory) Same asconvert(String[], int, ValueFactory)usingValueFactoryImpl.static Valueconvert(String srcValue, int targetType, ValueFactory factory) static Value[]convert(Value[] srcValues, int targetType, ValueFactory factory) static Valueconvert(Value srcValue, int targetType, ValueFactory factory) Converts the given value to a value of the specified target type.static Value[]copy(Value[] srcValues, ValueFactory factory) static Valuecopy(Value srcValue, ValueFactory factory) static Valuedeserialize(Reader reader, int type, boolean decodeBlanks, ValueFactory factory) Deserializes the string data read from the given reader to aValueof the given type.static Valuedeserialize(String value, int type, boolean decodeBlanks, ValueFactory factory) Deserializes the given string to aValueof the given type.static intDetermine thePropertyTypeof the passed values if all are of the same type.static booleanisSupportedConversion(int fromType, int toType) static StringSerializes the given value to aString.static voidOutputs the serialized value to aWriter.
-
Method Details
-
isSupportedConversion
public static boolean isSupportedConversion(int fromType, int toType) -
checkSupportedConversion
- Throws:
ValueFormatException
-
convert
public static Value convert(String srcValue, int targetType, ValueFactory factory) throws ValueFormatException, IllegalArgumentException - Parameters:
srcValue-targetType-factory-- Throws:
ValueFormatExceptionIllegalArgumentException- See Also:
-
convert
public static Value convert(InputStream srcValue, int targetType, ValueFactory factory) throws ValueFormatException, IllegalArgumentException - Parameters:
srcValue-targetType-factory-- Throws:
ValueFormatExceptionIllegalArgumentException
-
convert
public static Value[] convert(String[] srcValues, int targetType, ValueFactory factory) throws ValueFormatException, IllegalArgumentException Same asconvert(String[], int, ValueFactory)usingValueFactoryImpl.- Parameters:
srcValues-targetType-- Throws:
ValueFormatExceptionIllegalArgumentException- See Also:
-
convert
public static Value[] convert(InputStream[] srcValues, int targetType, ValueFactory factory) throws ValueFormatException, IllegalArgumentException - Parameters:
srcValues-targetType-- Throws:
ValueFormatExceptionIllegalArgumentException- See Also:
-
convert
public static Value[] convert(Value[] srcValues, int targetType, ValueFactory factory) throws ValueFormatException, IllegalArgumentException - Parameters:
srcValues-targetType-factory-- Throws:
ValueFormatExceptionIllegalArgumentException- See Also:
-
convert
public static Value convert(Value srcValue, int targetType, ValueFactory factory) throws ValueFormatException, IllegalStateException, IllegalArgumentException Converts 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:
ValueFormatExceptionIllegalStateExceptionIllegalArgumentException
-
copy
- Parameters:
srcValue-factory-- Throws:
IllegalStateException
-
copy
- Parameters:
srcValues-factory-- Throws:
IllegalStateException
-
serialize
public static String serialize(Value value, boolean encodeBlanks) throws IllegalStateException, RepositoryException Serializes 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:
IllegalStateException- if the given value is in an illegal stateRepositoryException- if an error occured during the serialization.
-
serialize
public static void serialize(Value value, boolean encodeBlanks, boolean enforceBase64, Writer writer) throws IllegalStateException, IOException, RepositoryException Outputs 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:
IllegalStateException- if the given value is in an illegal stateIOException- if an i/o error occured during the serializationRepositoryException- if an error occured during the serialization.
-
deserialize
public static Value deserialize(String value, int type, boolean decodeBlanks, ValueFactory factory) throws ValueFormatException, RepositoryException Deserializes 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:
ValueFormatException- if the string data is not of the required formatRepositoryException- if an error occured during the deserialization.
-
deserialize
public static Value deserialize(Reader reader, int type, boolean decodeBlanks, ValueFactory factory) throws IOException, ValueFormatException, RepositoryException Deserializes 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:
IOException- if an i/o error occured during the serializationValueFormatException- if the string data is not of the required formatRepositoryException- if an error occured during the deserialization.
-
getType
Determine 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:
ValueFormatException- if not allvaluesare of the same type
-