Class Value

    • Field Detail

      • VALUE_TYPE_NONE

        public static final int VALUE_TYPE_NONE
        Value type indicating that the value has no type set.
        See Also:
        Constant Field Values
      • VALUE_TYPE_NUMBER

        public static final int VALUE_TYPE_NUMBER
        Value type indicating that the value contains a floating point double precision number.
        See Also:
        Constant Field Values
      • VALUE_TYPE_STRING

        public static final int VALUE_TYPE_STRING
        Value type indicating that the value contains a text String.
        See Also:
        Constant Field Values
      • VALUE_TYPE_DATE

        public static final int VALUE_TYPE_DATE
        Value type indicating that the value contains a Date.
        See Also:
        Constant Field Values
      • VALUE_TYPE_BOOLEAN

        public static final int VALUE_TYPE_BOOLEAN
        Value type indicating that the value contains a boolean.
        See Also:
        Constant Field Values
      • VALUE_TYPE_INTEGER

        public static final int VALUE_TYPE_INTEGER
        Value type indicating that the value contains a long integer.
        See Also:
        Constant Field Values
      • VALUE_TYPE_BIGNUMBER

        public static final int VALUE_TYPE_BIGNUMBER
        Value type indicating that the value contains a floating point precision number with arbitrary precision.
        See Also:
        Constant Field Values
      • VALUE_TYPE_SERIALIZABLE

        public static final int VALUE_TYPE_SERIALIZABLE
        Value type indicating that the value contains an Object.
        See Also:
        Constant Field Values
      • VALUE_TYPE_BINARY

        public static final int VALUE_TYPE_BINARY
        Value type indicating that the value contains binary data: BLOB, CLOB, ...
        See Also:
        Constant Field Values
    • Constructor Detail

      • Value

        public Value()
        Constructs a new Value of type EMPTY
      • Value

        public Value​(String name)
        Constructs a new Value with a name.
        Parameters:
        name - Sets the name of the Value
      • Value

        public Value​(String name,
                     int val_type)
        Constructs a new Value with a name and a type.
        Parameters:
        name - Sets the name of the Value
        val_type - Sets the type of the Value (Value.VALUE_TYPE_*)
      • Value

        public Value​(String name,
                     int valType,
                     int length,
                     int precision)
        Constructs a new Value with a name, a type, length and precision.
        Parameters:
        name - Sets the name of the Value
        valType - Sets the type of the Value (Value.VALUE_TYPE_*)
        length - The length of the value
        precision - The precision of the value
      • Value

        public Value​(String name,
                     BigDecimal bignum)
        Constructs a new Value of Type VALUE_TYPE_BIGNUMBER, with a name, containing a BigDecimal number
        Parameters:
        name - Sets the name of the Value
        bignum - The number to store in this Value
      • Value

        public Value​(String name,
                     double num)
        Constructs a new Value of Type VALUE_TYPE_NUMBER, with a name, containing a number
        Parameters:
        name - Sets the name of the Value
        num - The number to store in this Value
      • Value

        public Value​(String name,
                     StringBuffer str)
        Constructs a new Value of Type VALUE_TYPE_STRING, with a name, containing a String
        Parameters:
        name - Sets the name of the Value
        str - The text to store in this Value
      • Value

        public Value​(String name,
                     StringBuilder str)
        Constructs a new Value of Type VALUE_TYPE_STRING, with a name, containing a String
        Parameters:
        name - Sets the name of the Value
        str - The text to store in this Value
      • Value

        public Value​(String name,
                     String str)
        Constructs a new Value of Type VALUE_TYPE_STRING, with a name, containing a String
        Parameters:
        name - Sets the name of the Value
        str - The text to store in this Value
      • Value

        public Value​(String name,
                     Date dat)
        Constructs a new Value of Type VALUE_TYPE_DATE, with a name, containing a Date
        Parameters:
        name - Sets the name of the Value
        dat - The date to store in this Value
      • Value

        public Value​(String name,
                     boolean bool)
        Constructs a new Value of Type VALUE_TYPE_BOOLEAN, with a name, containing a boolean value
        Parameters:
        name - Sets the name of the Value
        bool - The boolean to store in this Value
      • Value

        public Value​(String name,
                     long l)
        Constructs a new Value of Type VALUE_TYPE_INTEGER, with a name, containing an integer number
        Parameters:
        name - Sets the name of the Value
        l - The integer to store in this Value
      • Value

        public Value​(String name,
                     Value v)
        Constructs a new Value as a copy of another value and renames it...
        Parameters:
        name - The new name of the copied Value
        v - The value to be copied
      • Value

        public Value​(String name,
                     byte[] b)
        Constructs a new Value of Type VALUE_TYPE_BINARY, with a name, containing a bytes value
        Parameters:
        name - Sets the name of the Value
        b - The bytes to store in this Value
      • Value

        public Value​(Value v)
        Constructs a new Value as a copy of another value
        Parameters:
        v - The Value to be copied
      • Value

        public Value​(InputStream is)
              throws KettleFileException
        Read the Value, including meta-data from a DataInputStream
        Parameters:
        is - The InputStream to read the value from
        Throws:
        KettleFileException - when the Value couldn't be created by reading it from the DataInputStream.
      • Value

        public Value​(Value metaData,
                     DataInputStream dis)
              throws KettleFileException
        Read the data of a Value from a DataInputStream, the meta-data of the value has to be set before calling this method!
        Parameters:
        dis - the DataInputStream to read from
        Throws:
        KettleFileException - when the value couldn't be read from the DataInputStream
      • Value

        public Value​(Node valnode)
        Construct a new Value and read the data from XML
        Parameters:
        valnode - The XML Node to read from.
    • Method Detail

      • Clone

        public Value Clone()
        Build a copy of this Value
        Returns:
        a copy of another value
      • clearValue

        public void clearValue()
        Clears the content and name of a Value
      • setName

        public void setName​(String name)
        Sets the name of a Value
        Parameters:
        name - The new name of the value
      • getName

        public String getName()
        Obtain the name of a Value
        Returns:
        The name of the Value
      • setOrigin

        public void setOrigin​(String step_of_origin)
        This method allows you to set the origin of the Value by means of the name of the originating step.
        Parameters:
        step_of_origin - The step of origin.
      • getOrigin

        public String getOrigin()
        Obtain the origin of the step.
        Returns:
        The name of the originating step
      • setValue

        public void setValue​(BigDecimal num)
        Sets the value to a BigDecimal number value.
        Parameters:
        num - The number value to set the value to
      • setValue

        public void setValue​(double num)
        Sets the value to a double Number value.
        Parameters:
        num - The number value to set the value to
      • setValue

        public void setValue​(StringBuffer str)
        Sets the Value to a String text
        Parameters:
        str - The StringBuffer to get the text from
      • setValue

        public void setValue​(StringBuilder str)
        Sets the Value to a String text
        Parameters:
        str - The StringBuilder to get the text from
      • setValue

        public void setValue​(String str)
        Sets the Value to a String text
        Parameters:
        str - The String to get the text from
      • setSerializedValue

        public void setSerializedValue​(Serializable ser)
      • setValue

        public void setValue​(Date dat)
        Sets the Value to a Date
        Parameters:
        dat - The Date to set the Value to
      • setValue

        public void setValue​(boolean bool)
        Sets the Value to a boolean
        Parameters:
        bool - The boolean to set the Value to
      • setValue

        public void setValue​(Boolean b)
      • setValue

        public void setValue​(byte b)
        Sets the Value to a long integer
        Parameters:
        b - The byte to convert to a long integer to which the Value is set.
      • setValue

        public void setValue​(int i)
        Sets the Value to a long integer
        Parameters:
        i - The integer to convert to a long integer to which the Value is set.
      • setValue

        public void setValue​(long l)
        Sets the Value to a long integer
        Parameters:
        l - The long integer to which the Value is set.
      • setValue

        public void setValue​(byte[] b)
        Sets the Value to a byte array
        Parameters:
        b - The byte array to which the Value has to be set.
      • setValue

        public void setValue​(Value v)
        Copy the Value from another Value. It doesn't copy the name.
        Parameters:
        v - The Value to copy the settings and value from
      • getBigNumber

        public BigDecimal getBigNumber()
        Get the BigDecimal number of this Value. If the value is not of type BIG_NUMBER, a conversion is done first.
        Returns:
        the double precision floating point number of this Value.
      • getNumber

        public double getNumber()
        Get the double precision floating point number of this Value. If the value is not of type NUMBER, a conversion is done first.
        Returns:
        the double precision floating point number of this Value.
      • getString

        public String getString()
        Get the String text representing this value. If the value is not of type STRING, a conversion if done first.
        Returns:
        the String text representing this value.
      • getStringLength

        public int getStringLength()
        Get the length of the String representing this value.
        Returns:
        the length of the String representing this value.
      • getDate

        public Date getDate()
        Get the Date of this Value. If the Value is not of type DATE, a conversion is done first.
        Returns:
        the Date of this Value.
      • getSerializable

        public Serializable getSerializable()
        Get the Serializable of this Value. If the Value is not of type Serializable, it returns null.
        Returns:
        the Serializable of this Value.
      • getBoolean

        public boolean getBoolean()
        Get the boolean value of this Value. If the Value is not of type BOOLEAN, it will be converted.

        Strings: "YES", "Y", "TRUE" (case insensitive) to true, the rest false

        Number: 0.0 is false, the rest is true.

        Integer: 0 is false, the rest is true.

        Date: always false.

        Returns:
        the boolean representation of this Value.
      • getInteger

        public long getInteger()
        Get the long integer representation of this value. If the Value is not of type INTEGER, it will be converted:

        String: try to convert to a long value, 0L if it didn't work.

        Number: round the double value and return the resulting long integer.

        Date: return the number of miliseconds after 1970:01:01 00:00:00

        Date: always false.

        Returns:
        the long integer representation of this value.
      • getBytes

        public byte[] getBytes()
      • setType

        public void setType​(int val_type)
        Set the type of this Value
        Parameters:
        val_type - The type to which the Value will be set.
      • getType

        public int getType()
        Returns the type of this Value
        Returns:
        the type of this Value
      • isEmpty

        public boolean isEmpty()
        Checks whether or not this Value is empty. A value is empty if it has the type VALUE_TYPE_EMPTY
        Returns:
        true if the value is empty.
      • isString

        public boolean isString()
        Checks wheter or not the value is a String.
        Returns:
        true if the value is a String.
      • isDate

        public boolean isDate()
        Checks whether or not this value is a Date
        Returns:
        true if the value is a Date
      • isBigNumber

        public boolean isBigNumber()
        Checks whether or not the value is a Big Number
        Returns:
        true is this value is a big number
      • isNumber

        public boolean isNumber()
        Checks whether or not the value is a Number
        Returns:
        true is this value is a number
      • isBoolean

        public boolean isBoolean()
        Checks whether or not this value is a boolean
        Returns:
        true if this value has type boolean.
      • isSerializableType

        public boolean isSerializableType()
        Checks whether or not this value is of type Serializable
        Returns:
        true if this value has type Serializable
      • isBinary

        public boolean isBinary()
        Checks whether or not this value is of type Binary
        Returns:
        true if this value has type Binary
      • isInteger

        public boolean isInteger()
        Checks whether or not this value is an Integer
        Returns:
        true if this value is an integer
      • isNumeric

        public boolean isNumeric()
        Checks whether or not this Value is Numeric A Value is numeric if it is either of type Number or Integer
        Returns:
        true if the value is either of type Number or Integer
      • isNumeric

        public static final boolean isNumeric​(int t)
        Checks whether or not the specified type is either Integer or Number
        Parameters:
        t - the type to check
        Returns:
        true if the type is Integer or Number
      • toString

        public String toString()
        Returns a padded to length String text representation of this Value
        Overrides:
        toString in class Object
        Returns:
        a padded to length String text representation of this Value
      • toString

        public String toString​(boolean pad)
        a String text representation of this Value, optionally padded to the specified length
        Parameters:
        pad - true if you want to pad the resulting String
        Returns:
        a String text representation of this Value, optionally padded to the specified length
      • toStringMeta

        public String toStringMeta()
        a String text representation of this Value, optionally padded to the specified length
        Returns:
        a String text representation of this Value, optionally padded to the specified length
      • setLength

        public void setLength​(int l)
        Sets the length of the Number, Integer or String to the specified length Note: no truncation of the value takes place, this is meta-data only!
        Parameters:
        l - the length to which you want to set the Value.
      • setLength

        public void setLength​(int l,
                              int p)
        Sets the length and the precision of the Number, Integer or String to the specified length & precision Note: no truncation of the value takes place, this is meta-data only!
        Parameters:
        l - the length to which you want to set the Value.
        p - the precision to which you want to set this Value
      • getLength

        public int getLength()
        Get the length of this Value.
        Returns:
        the length of this Value.
      • getPrecision

        public int getPrecision()
        get the precision of this Value
        Returns:
        the precision of this Value.
      • setPrecision

        public void setPrecision​(int p)
        Sets the precision of this Value Note: no rounding or truncation takes place, this is meta-data only!
        Parameters:
        p - the precision to which you want to set this Value.
      • getTypeDesc

        public String getTypeDesc()
        Return the type of a value in a textual form: "String", "Number", "Integer", "Boolean", "Date", ...
        Returns:
        A String describing the type of value.
      • getTypeDesc

        public static final String getTypeDesc​(int t)
        Return the type of a value in a textual form: "String", "Number", "Integer", "Boolean", "Date", ... given a certain integer type
        Parameters:
        t - the type to convert to text.
        Returns:
        A String describing the type of a certain value.
      • getType

        public static final int getType​(String desc)
        Convert the String description of a type to an integer type.
        Parameters:
        desc - The description of the type to convert
        Returns:
        The integer type of the given String. (Value.VALUE_TYPE_...)
      • getTypes

        public static final String[] getTypes()
        get an array of String describing the possible types a Value can have.
        Returns:
        an array of String describing the possible types a Value can have.
      • getAllTypes

        public static final String[] getAllTypes()
        Get an array of String describing the possible types a Value can have.
        Returns:
        an array of String describing the possible types a Value can have.
      • setNull

        public void setNull()
        Sets the Value to null, no type is being changed.
      • setNull

        public void setNull​(boolean n)
        Sets or unsets a value to null, no type is being changed.
        Parameters:
        n - true if you want the value to be null, false if you don't want this to be the case.
      • isNull

        public boolean isNull()
        Checks wheter or not a value is null.
        Returns:
        true if the Value is null.
      • write

        public void write​(OutputStream outputStream)
                   throws KettleFileException
        Write the value, including the meta-data to a DataOutputStream
        Parameters:
        outputStream - the OutputStream to write to .
        Throws:
        KettleFileException - if something goes wrong.
      • readObj

        public void readObj​(DataInputStream dis)
                     throws IOException
        Read the metadata and data for this Value object from the specified data input stream
        Parameters:
        dis -
        Throws:
        IOException
      • writeData

        public boolean writeData​(DataOutputStream dos)
                          throws KettleFileException
        Write the data of this Value, without the meta-data to a DataOutputStream
        Parameters:
        dos - The DataOutputStream to write the data to
        Returns:
        true if all went well, false if something went wrong.
        Throws:
        KettleFileException
      • compare

        public int compare​(Value v)
        Compare 2 values of the same or different type! The comparison of Strings is case insensitive
        Parameters:
        v - the value to compare with.
        Returns:
        -1 if The value was smaller, 1 bigger and 0 if both values are equal.
      • compare

        public int compare​(Value v,
                           boolean caseInsensitive)
        Compare 2 values of the same or different type!
        Parameters:
        v - the value to compare with.
        caseInsensitive - True if you want the comparison to be case insensitive
        Returns:
        -1 if The value was smaller, 1 bigger and 0 if both values are equal.
      • isEqualTo

        public boolean isEqualTo​(String string)
        Check whether this value is equal to the String supplied.
        Parameters:
        string - The string to check for equality
        Returns:
        true if the String representation of the value is equal to string. (ignoring case)
      • isEqualTo

        public boolean isEqualTo​(BigDecimal number)
        Check whether this value is equal to the BigDecimal supplied.
        Parameters:
        number - The BigDecimal to check for equality
        Returns:
        true if the BigDecimal representation of the value is equal to number.
      • isEqualTo

        public boolean isEqualTo​(double number)
        Check whether this value is equal to the Number supplied.
        Parameters:
        number - The Number to check for equality
        Returns:
        true if the Number representation of the value is equal to number.
      • isEqualTo

        public boolean isEqualTo​(long number)
        Check whether this value is equal to the Integer supplied.
        Parameters:
        number - The Integer to check for equality
        Returns:
        true if the Integer representation of the value is equal to number.
      • isEqualTo

        public boolean isEqualTo​(int number)
        Check whether this value is equal to the Integer supplied.
        Parameters:
        number - The Integer to check for equality
        Returns:
        true if the Integer representation of the value is equal to number.
      • isEqualTo

        public boolean isEqualTo​(byte number)
        Check whether this value is equal to the Integer supplied.
        Parameters:
        number - The Integer to check for equality
        Returns:
        true if the Integer representation of the value is equal to number.
      • isEqualTo

        public boolean isEqualTo​(Date date)
        Check whether this value is equal to the Date supplied.
        Parameters:
        date - The Date to check for equality
        Returns:
        true if the Date representation of the value is equal to date.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • bool_not

        public Value bool_not()
      • greater_equal

        public Value greater_equal​(Value v)
      • smaller_equal

        public Value smaller_equal​(Value v)
      • plus

        public Value plus​(double v)
      • plus

        public Value plus​(long v)
      • plus

        public Value plus​(int v)
      • plus

        public Value plus​(byte v)
      • initcap

        public Value initcap()
      • lower

        public Value lower()
      • lpad

        public Value lpad​(int len)
      • lpad

        public Value lpad​(int len,
                          String padstr)
      • ltrim

        public Value ltrim()
      • round

        public Value round​(int decimalPlaces)
                    throws KettleValueException
        Rounds the Number value to a certain number decimal places.
        Parameters:
        decimalPlaces -
        Returns:
        The rounded Number Value
        Throws:
        KettleValueException - in case it's not a number (or other problem).
      • rpad

        public Value rpad​(int len)
      • rpad

        public Value rpad​(int len,
                          String padstr)
      • rtrim

        public Value rtrim()
      • substr

        public Value substr​(int from)
      • substr

        public Value substr​(int from,
                            int to)
      • rightstr

        public Value rightstr​(int len)
      • leftstr

        public Value leftstr​(int len)
      • startsWith

        public Value startsWith​(Value string)
      • startsWith

        public Value startsWith​(String string)
      • sysdate

        public Value sysdate()
      • trim

        public Value trim()
        Performs a right and left trim of spaces in the string. If the value is not a string a conversion to String is performed first.
        Returns:
        The trimmed string value.
      • upper

        public Value upper()
      • add_days

        public Value add_days​(long days)
                       throws KettleValueException
        Add a number of days to a Date value.
        Parameters:
        days - The number of days to add to the current date value
        Returns:
        The resulting value
        Throws:
        KettleValueException
      • byteToHexEncode

        public Value byteToHexEncode()
        Change a string into its hexadecimal representation. E.g. if Value contains string "a" afterwards it would contain value "61". Note that transformations happen in groups of 2 hex characters, so the value of a characters is always in the range 0-255.
        Returns:
        Value itself
        Throws:
        KettleValueException
      • hexToByteDecode

        public Value hexToByteDecode()
                              throws KettleValueException
        Change a hexadecimal string into normal ASCII representation. E.g. if Value contains string "61" afterwards it would contain value "a". If the hexadecimal string is of odd length a leading zero will be used. Note that only the low byte of a character will be processed, this is for binary transformations.
        Returns:
        Value itself
        Throws:
        KettleValueException
      • charToHexEncode

        public Value charToHexEncode()
        Change a string into its hexadecimal representation. E.g. if Value contains string "a" afterwards it would contain value "0061". Note that transformations happen in groups of 4 hex characters, so the value of a characters is always in the range 0-65535.
        Returns:
        Value itself
        Throws:
        KettleValueException
      • hexToCharDecode

        public Value hexToCharDecode()
                              throws KettleValueException
        Change a hexadecimal string into normal ASCII representation. E.g. if Value contains string "61" afterwards it would contain value "a". If the hexadecimal string is of a wrong length leading zeroes will be used. Note that transformations happen in groups of 4 hex characters, so the value of a characters is always in the range 0-65535.
        Returns:
        Value itself
        Throws:
        KettleValueException
      • getInstance

        public static final Value getInstance()
      • getClassName

        public String getClassName()
      • jsConstructor

        public void jsConstructor()
      • jsConstructor

        public void jsConstructor​(String name)
      • jsConstructor

        public void jsConstructor​(String name,
                                  String value)
      • getXML

        public String getXML()
        Produce the XML representation of this value.
        Specified by:
        getXML in interface XMLInterface
        Returns:
        a String containing the XML to represent this Value.
      • loadXML

        public boolean loadXML​(Node valnode)
        Read the data for this Value from an XML Node
        Parameters:
        valnode - The XML Node to read from
        Returns:
        true if all went well, false if something went wrong.
      • convertString

        public void convertString​(int newtype)
                           throws KettleValueException
        Convert this Value from type String to another type
        Parameters:
        newtype - The Value type to convert to.
        Throws:
        KettleValueException
      • equalValueType

        public boolean equalValueType​(Value v)
      • equalValueType

        public boolean equalValueType​(Value v,
                                      boolean checkTypeOnly)
        Returns whether "types" of the values are exactly the same: type, name, length, precision.
        Parameters:
        v - Value to compare type against.
        Returns:
        == true when types are the same == false when the types differ
      • setValueInterface

        public void setValueInterface​(ValueInterface valueInterface)
      • merge

        public void merge​(Value other)
        Merges another Value. That means, that if the other Value has got the same name and is of the same type as this Value, it's real field value is set as this this' value, if our value is null or empty
        Parameters:
        other - The other value