Class ValueHelper


  • public class ValueHelper
    extends java.lang.Object
    The ValueHelper class provides several Value related utility methods.
    • Method Detail

      • isSupportedConversion

        public static boolean isSupportedConversion​(int fromType,
                                                    int toType)
      • convert

        public static Value convert​(java.io.InputStream srcValue,
                                    int targetType,
                                    ValueFactory factory)
                             throws ValueFormatException,
                                    java.lang.IllegalArgumentException
        Parameters:
        srcValue -
        targetType -
        factory -
        Throws:
        ValueFormatException
        java.lang.IllegalArgumentException
      • convert

        public static Value convert​(Value srcValue,
                                    int targetType,
                                    ValueFactory factory)
                             throws ValueFormatException,
                                    java.lang.IllegalStateException,
                                    java.lang.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:
        ValueFormatException
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
      • copy

        public static Value copy​(Value srcValue,
                                 ValueFactory factory)
                          throws java.lang.IllegalStateException
        Parameters:
        srcValue -
        factory -
        Throws:
        java.lang.IllegalStateException
      • copy

        public static Value[] copy​(Value[] srcValues,
                                   ValueFactory factory)
                            throws java.lang.IllegalStateException
        Parameters:
        srcValues -
        factory -
        Throws:
        java.lang.IllegalStateException
      • serialize

        public static java.lang.String serialize​(Value value,
                                                 boolean encodeBlanks)
                                          throws java.lang.IllegalStateException,
                                                 RepositoryException
        Serializes the given value to a String. The serialization format is the same as used by Document & System View XML, i.e. binary values will be Base64-encoded whereas for all others Value.getString() will be used.
        Parameters:
        value - the value to be serialized
        encodeBlanks - if true space 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 state
        RepositoryException - if an error occured during the serialization.
      • serialize

        public static void serialize​(Value value,
                                     boolean encodeBlanks,
                                     boolean enforceBase64,
                                     java.io.Writer writer)
                              throws java.lang.IllegalStateException,
                                     java.io.IOException,
                                     RepositoryException
        Outputs the serialized value to a Writer. The serialization format is the same as used by Document & System View XML, i.e. binary values will be Base64-encoded whereas for all others Value.getString() will be used for serialization.
        Parameters:
        value - the value to be serialized
        encodeBlanks - if true space characters will be encoded as "_x0020_" within he output string.
        enforceBase64 - if true, base64 encoding will always be used
        writer - writer to output the encoded data
        Throws:
        java.lang.IllegalStateException - if the given value is in an illegal state
        java.io.IOException - if an i/o error occured during the serialization
        RepositoryException - if an error occured during the serialization.
      • deserialize

        public static Value deserialize​(java.lang.String value,
                                        int type,
                                        boolean decodeBlanks,
                                        ValueFactory factory)
                                 throws ValueFormatException,
                                        RepositoryException
        Deserializes the given string to a Value of the given type.
        Parameters:
        value - string to be deserialized
        type - type of value
        decodeBlanks - if true "_x0020_" character sequences will be decoded to single space characters each.
        factory - ValueFactory used to build the Value object.
        Returns:
        the deserialized Value
        Throws:
        ValueFormatException - if the string data is not of the required format
        RepositoryException - if an error occured during the deserialization.
      • deserialize

        public static Value deserialize​(java.io.Reader reader,
                                        int type,
                                        boolean decodeBlanks,
                                        ValueFactory factory)
                                 throws java.io.IOException,
                                        ValueFormatException,
                                        RepositoryException
        Deserializes the string data read from the given reader to a Value of the given type.
        Parameters:
        reader - reader for the string data to be deserialized
        type - type of value
        decodeBlanks - if true "_x0020_" character sequences will be decoded to single space characters each.
        factory - ValueFactory used to build the Value object.
        Returns:
        the deserialized Value
        Throws:
        java.io.IOException - if an i/o error occured during the serialization
        ValueFormatException - if the string data is not of the required format
        RepositoryException - if an error occured during the deserialization.