Package org.pentaho.di.compatibility
Class Value
- java.lang.Object
-
- org.pentaho.di.compatibility.Value
-
- All Implemented Interfaces:
Serializable
,Cloneable
,XMLInterface
public class Value extends Object implements Cloneable, XMLInterface, Serializable
This class is one of the core classes of the Kettle framework. It contains everything you need to manipulate atomic data (Values/Fields/...) and to describe it in the form of meta-data. (name, length, precision, etc.)- Since:
- Beginning 2003
- Author:
- Matt
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
VALUE_TYPE_BIGNUMBER
Value type indicating that the value contains a floating point precision number with arbitrary precision.static int
VALUE_TYPE_BINARY
Value type indicating that the value contains binary data: BLOB, CLOB, ...static int
VALUE_TYPE_BOOLEAN
Value type indicating that the value contains a boolean.static int
VALUE_TYPE_DATE
Value type indicating that the value contains a Date.static int
VALUE_TYPE_INTEGER
Value type indicating that the value contains a long integer.static int
VALUE_TYPE_NONE
Value type indicating that the value has no type set.static int
VALUE_TYPE_NUMBER
Value type indicating that the value contains a floating point double precision number.static int
VALUE_TYPE_SERIALIZABLE
Value type indicating that the value contains an Object.static int
VALUE_TYPE_STRING
Value type indicating that the value contains a text String.static String
XML_TAG
-
Constructor Summary
Constructors Constructor Description Value()
Constructs a new Value of type EMPTYValue(InputStream is)
Read the Value, including meta-data from a DataInputStreamValue(String name)
Constructs a new Value with a name.Value(String name, boolean bool)
Constructs a new Value of Type VALUE_TYPE_BOOLEAN, with a name, containing a boolean valueValue(String name, byte[] b)
Constructs a new Value of Type VALUE_TYPE_BINARY, with a name, containing a bytes valueValue(String name, double num)
Constructs a new Value of Type VALUE_TYPE_NUMBER, with a name, containing a numberValue(String name, int val_type)
Constructs a new Value with a name and a type.Value(String name, int valType, int length, int precision)
Constructs a new Value with a name, a type, length and precision.Value(String name, long l)
Constructs a new Value of Type VALUE_TYPE_INTEGER, with a name, containing an integer numberValue(String name, String str)
Constructs a new Value of Type VALUE_TYPE_STRING, with a name, containing a StringValue(String name, StringBuffer str)
Constructs a new Value of Type VALUE_TYPE_STRING, with a name, containing a StringValue(String name, StringBuilder str)
Constructs a new Value of Type VALUE_TYPE_STRING, with a name, containing a StringValue(String name, BigDecimal bignum)
Constructs a new Value of Type VALUE_TYPE_BIGNUMBER, with a name, containing a BigDecimal numberValue(String name, Date dat)
Constructs a new Value of Type VALUE_TYPE_DATE, with a name, containing a DateValue(String name, Value v)
Constructs a new Value as a copy of another value and renames it...Value(Value v)
Constructs a new Value as a copy of another valueValue(Value metaData, DataInputStream dis)
Read the data of a Value from a DataInputStream, the meta-data of the value has to be set before calling this method!Value(Node valnode)
Construct a new Value and read the data from XML
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Value
abs()
Value
acos()
Value
add_days(long days)
Add a number of days to a Date value.Value
add_months(int months)
Value
and(Value v)
Value
asin()
Value
atan()
Value
atan2(double arg0)
Value
atan2(Value arg0)
Value
bool_and(Value v)
Value
bool_not()
Value
bool_or(Value v)
Value
bool_xor(Value v)
Value
byteToHexEncode()
Change a string into its hexadecimal representation.Value
ceil()
Value
charToHexEncode()
Change a string into its hexadecimal representation.void
clearValue()
Clears the content and name of a ValueObject
clone()
Value
Clone()
Build a copy of this Valueint
compare(Value v)
Compare 2 values of the same or different type! The comparison of Strings is case insensitiveint
compare(Value v, boolean caseInsensitive)
Compare 2 values of the same or different type!void
convertString(int newtype)
Convert this Value from type String to another typeValue
cos()
Value
dat2num()
Value
dat2str()
Value
dat2str(String arg0)
Value
dat2str(String arg0, String arg1)
Value
different(Value v)
Value
divide(byte v)
Value
divide(double v)
Value
divide(int v)
Value
divide(long v)
Value
divide(BigDecimal v)
Value
divide(Value v)
Value
e()
Value
equal(Value v)
boolean
equals(Object v)
boolean
equalValueType(Value v)
boolean
equalValueType(Value v, boolean checkTypeOnly)
Returns whether "types" of the values are exactly the same: type, name, length, precision.Value
exp()
Value
first_day()
Value
floor()
static String[]
getAllTypes()
Get an array of String describing the possible types a Value can have.BigDecimal
getBigNumber()
Get the BigDecimal number of this Value.boolean
getBoolean()
Get the boolean value of this Value.byte[]
getBytes()
String
getClassName()
Date
getDate()
Get the Date of this Value.static Value
getInstance()
long
getInteger()
Get the long integer representation of this value.int
getLength()
Get the length of this Value.String
getName()
Obtain the name of a Valuedouble
getNumber()
Get the double precision floating point number of this Value.String
getOrigin()
Obtain the origin of the step.int
getPrecision()
get the precision of this ValueSerializable
getSerializable()
Get the Serializable of this Value.String
getString()
Get the String text representing this value.int
getStringLength()
Get the length of the String representing this value.int
getType()
Returns the type of this Valuestatic int
getType(String desc)
Convert the String description of a type to an integer type.String
getTypeDesc()
Return the type of a value in a textual form: "String", "Number", "Integer", "Boolean", "Date", ...static String
getTypeDesc(int t)
Return the type of a value in a textual form: "String", "Number", "Integer", "Boolean", "Date", ...static String[]
getTypes()
get an array of String describing the possible types a Value can have.ValueInterface
getValueInterface()
String
getXML()
Produce the XML representation of this value.Value
greater(Value v)
Value
greater_equal(Value v)
int
hashCode()
Value
hexToByteDecode()
Change a hexadecimal string into normal ASCII representation.Value
hexToCharDecode()
Change a hexadecimal string into normal ASCII representation.Value
initcap()
boolean
isBigNumber()
Checks whether or not the value is a Big Numberboolean
isBinary()
Checks whether or not this value is of type Binaryboolean
isBoolean()
Checks whether or not this value is a booleanboolean
isDate()
Checks whether or not this value is a Dateboolean
isEmpty()
Checks whether or not this Value is empty.boolean
isEqualTo(byte number)
Check whether this value is equal to the Integer supplied.boolean
isEqualTo(double number)
Check whether this value is equal to the Number supplied.boolean
isEqualTo(int number)
Check whether this value is equal to the Integer supplied.boolean
isEqualTo(long number)
Check whether this value is equal to the Integer supplied.boolean
isEqualTo(String string)
Check whether this value is equal to the String supplied.boolean
isEqualTo(BigDecimal number)
Check whether this value is equal to the BigDecimal supplied.boolean
isEqualTo(Date date)
Check whether this value is equal to the Date supplied.boolean
isInteger()
Checks whether or not this value is an Integerboolean
isNull()
Checks wheter or not a value is null.boolean
isNumber()
Checks whether or not the value is a Numberboolean
isNumeric()
Checks whether or not this Value is Numeric A Value is numeric if it is either of type Number or Integerstatic boolean
isNumeric(int t)
Checks whether or not the specified type is either Integer or Numberboolean
isSerializableType()
Checks whether or not this value is of type Serializableboolean
isString()
Checks wheter or not the value is a String.void
jsConstructor()
void
jsConstructor(String name)
void
jsConstructor(String name, String value)
Value
last_day()
Value
leftstr(int len)
Value
leftstr(Value len)
Value
length()
Value
like(Value v)
boolean
loadXML(Node valnode)
Read the data for this Value from an XML NodeValue
log()
Value
lower()
Value
lpad(int len)
Value
lpad(int len, String padstr)
Value
lpad(Value len)
Value
lpad(Value len, Value padstr)
Value
ltrim()
void
merge(Value other)
Merges another Value.Value
minus(byte v)
Value
minus(double v)
Value
minus(int v)
Value
minus(long v)
Value
minus(BigDecimal v)
Value
minus(Value v)
Value
mod(byte arg)
Value
mod(double arg0)
Value
mod(int arg)
Value
mod(long arg)
Value
mod(BigDecimal arg)
Value
mod(Value arg)
Value
multiply(byte v)
Value
multiply(double v)
Value
multiply(int v)
Value
multiply(long v)
Value
multiply(BigDecimal v)
Value
multiply(Value v)
Value
num2dat()
Value
num2str()
Value
num2str(String format)
Value
num2str(String format, String decimalSymbol)
Value
num2str(String format, String decimalSymbol, String groupingSymbol)
Value
num2str(String format, String decimalSymbol, String groupingSymbol, String currencySymbol)
Value
nvl(Value alt)
Value
or(Value v)
Value
pi()
Value
plus(byte v)
Value
plus(double v)
Value
plus(int v)
Value
plus(long v)
Value
plus(BigDecimal v)
Value
plus(Value v)
Value
power(double arg)
Value
power(BigDecimal arg)
Value
power(Value v)
void
readObj(DataInputStream dis)
Read the metadata and data for this Value object from the specified data input streamValue
replace(String repl, String with)
Value
replace(Value repl, Value with)
Value
rightstr(int len)
Value
rightstr(Value len)
Value
round()
Rounds off to the nearest integer.Value
round(int decimalPlaces)
Rounds the Number value to a certain number decimal places.Value
rpad(int len)
Value
rpad(int len, String padstr)
Value
rpad(Value len)
Value
rpad(Value len, Value padstr)
Value
rtrim()
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!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!void
setName(String name)
Sets the name of a Valuevoid
setNull()
Sets the Value to null, no type is being changed.void
setNull(boolean n)
Sets or unsets a value to null, no type is being changed.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.void
setPrecision(int p)
Sets the precision of this Value Note: no rounding or truncation takes place, this is meta-data only!void
setSerializedValue(Serializable ser)
void
setType(int val_type)
Set the type of this Valuevoid
setValue(boolean bool)
Sets the Value to a booleanvoid
setValue(byte b)
Sets the Value to a long integervoid
setValue(byte[] b)
Sets the Value to a byte arrayvoid
setValue(double num)
Sets the value to a double Number value.void
setValue(int i)
Sets the Value to a long integervoid
setValue(long l)
Sets the Value to a long integervoid
setValue(Boolean b)
void
setValue(String str)
Sets the Value to a String textvoid
setValue(StringBuffer str)
Sets the Value to a String textvoid
setValue(StringBuilder str)
Sets the Value to a String textvoid
setValue(BigDecimal num)
Sets the value to a BigDecimal number value.void
setValue(Date dat)
Sets the Value to a Datevoid
setValue(Value v)
Copy the Value from another Value.void
setValueInterface(ValueInterface valueInterface)
Value
sign()
Value
sin()
Value
smaller(Value v)
Value
smaller_equal(Value v)
Value
sqrt()
Value
startsWith(String string)
Value
startsWith(Value string)
Value
str2dat(String arg0)
Value
str2dat(String arg0, String arg1)
Value
str2num()
Value
str2num(String pattern)
Value
str2num(String pattern, String decimal)
Value
str2num(String pattern, String decimal, String grouping)
Value
str2num(String pattern, String decimal, String grouping, String currency)
Value
substr(int from)
Value
substr(int from, int to)
Value
substr(Value from)
Value
substr(Value from, Value to)
Value
sysdate()
Value
tan()
String
toString()
Returns a padded to length String text representation of this ValueString
toString(boolean pad)
a String text representation of this Value, optionally padded to the specified lengthString
toStringMeta()
a String text representation of this Value, optionally padded to the specified lengthValue
trim()
Performs a right and left trim of spaces in the string.Value
trunc()
Value
trunc(double level)
Value
trunc(int level)
Value
upper()
Value
v_decode(Value[] args)
Value
v_if(Value[] args)
void
write(OutputStream outputStream)
Write the value, including the meta-data to a DataOutputStreamboolean
writeData(DataOutputStream dos)
Write the data of this Value, without the meta-data to a DataOutputStreamvoid
writeObj(DataOutputStream dos)
Value
xor(Value v)
-
-
-
Field Detail
-
XML_TAG
public static final String XML_TAG
- See Also:
- Constant Field Values
-
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 Valueval_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 ValuevalType
- Sets the type of the Value (Value.VALUE_TYPE_*)length
- The length of the valueprecision
- 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 Valuebignum
- 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 Valuenum
- 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 Valuestr
- 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 Valuestr
- 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 Valuestr
- 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 Valuedat
- 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 Valuebool
- 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 Valuel
- 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 Valuev
- 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 Valueb
- 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
-
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.
-
writeObj
public void writeObj(DataOutputStream dos) throws IOException
- Throws:
IOException
-
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.
-
bool_not
public Value bool_not()
-
minus
public Value minus(BigDecimal v) throws KettleValueException
- Throws:
KettleValueException
-
minus
public Value minus(double v) throws KettleValueException
- Throws:
KettleValueException
-
minus
public Value minus(long v) throws KettleValueException
- Throws:
KettleValueException
-
minus
public Value minus(int v) throws KettleValueException
- Throws:
KettleValueException
-
minus
public Value minus(byte v) throws KettleValueException
- Throws:
KettleValueException
-
minus
public Value minus(Value v) throws KettleValueException
- Throws:
KettleValueException
-
plus
public Value plus(BigDecimal 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)
-
divide
public Value divide(BigDecimal v) throws KettleValueException
- Throws:
KettleValueException
-
divide
public Value divide(double v) throws KettleValueException
- Throws:
KettleValueException
-
divide
public Value divide(long v) throws KettleValueException
- Throws:
KettleValueException
-
divide
public Value divide(int v) throws KettleValueException
- Throws:
KettleValueException
-
divide
public Value divide(byte v) throws KettleValueException
- Throws:
KettleValueException
-
divide
public Value divide(Value v) throws KettleValueException
- Throws:
KettleValueException
-
multiply
public Value multiply(BigDecimal v) throws KettleValueException
- Throws:
KettleValueException
-
multiply
public Value multiply(double v) throws KettleValueException
- Throws:
KettleValueException
-
multiply
public Value multiply(long v) throws KettleValueException
- Throws:
KettleValueException
-
multiply
public Value multiply(int v) throws KettleValueException
- Throws:
KettleValueException
-
multiply
public Value multiply(byte v) throws KettleValueException
- Throws:
KettleValueException
-
multiply
public Value multiply(Value v) throws KettleValueException
- Throws:
KettleValueException
-
abs
public Value abs() throws KettleValueException
- Throws:
KettleValueException
-
acos
public Value acos() throws KettleValueException
- Throws:
KettleValueException
-
asin
public Value asin() throws KettleValueException
- Throws:
KettleValueException
-
atan
public Value atan() throws KettleValueException
- Throws:
KettleValueException
-
atan2
public Value atan2(Value arg0) throws KettleValueException
- Throws:
KettleValueException
-
atan2
public Value atan2(double arg0) throws KettleValueException
- Throws:
KettleValueException
-
ceil
public Value ceil() throws KettleValueException
- Throws:
KettleValueException
-
cos
public Value cos() throws KettleValueException
- Throws:
KettleValueException
-
exp
public Value exp() throws KettleValueException
- Throws:
KettleValueException
-
floor
public Value floor() throws KettleValueException
- Throws:
KettleValueException
-
initcap
public Value initcap()
-
length
public Value length() throws KettleValueException
- Throws:
KettleValueException
-
log
public Value log() throws KettleValueException
- Throws:
KettleValueException
-
lower
public Value lower()
-
lpad
public Value lpad(int len)
-
ltrim
public Value ltrim()
-
mod
public Value mod(Value arg) throws KettleValueException
- Throws:
KettleValueException
-
mod
public Value mod(BigDecimal arg) throws KettleValueException
- Throws:
KettleValueException
-
mod
public Value mod(long arg) throws KettleValueException
- Throws:
KettleValueException
-
mod
public Value mod(int arg) throws KettleValueException
- Throws:
KettleValueException
-
mod
public Value mod(byte arg) throws KettleValueException
- Throws:
KettleValueException
-
mod
public Value mod(double arg0) throws KettleValueException
- Throws:
KettleValueException
-
power
public Value power(BigDecimal arg) throws KettleValueException
- Throws:
KettleValueException
-
power
public Value power(double arg) throws KettleValueException
- Throws:
KettleValueException
-
power
public Value power(Value v) throws KettleValueException
- Throws:
KettleValueException
-
round
public Value round() throws KettleValueException
Rounds off to the nearest integer.See also: java.lang.Math.round()
- Returns:
- The rounded Number value.
- Throws:
KettleValueException
-
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)
-
rtrim
public Value rtrim()
-
sign
public Value sign() throws KettleValueException
- Throws:
KettleValueException
-
sin
public Value sin() throws KettleValueException
- Throws:
KettleValueException
-
sqrt
public Value sqrt() throws KettleValueException
- Throws:
KettleValueException
-
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)
-
sysdate
public Value sysdate()
-
tan
public Value tan() throws KettleValueException
- Throws:
KettleValueException
-
num2str
public Value num2str() throws KettleValueException
- Throws:
KettleValueException
-
num2str
public Value num2str(String format) throws KettleValueException
- Throws:
KettleValueException
-
num2str
public Value num2str(String format, String decimalSymbol) throws KettleValueException
- Throws:
KettleValueException
-
num2str
public Value num2str(String format, String decimalSymbol, String groupingSymbol) throws KettleValueException
- Throws:
KettleValueException
-
num2str
public Value num2str(String format, String decimalSymbol, String groupingSymbol, String currencySymbol) throws KettleValueException
- Throws:
KettleValueException
-
dat2str
public Value dat2str() throws KettleValueException
- Throws:
KettleValueException
-
dat2str
public Value dat2str(String arg0) throws KettleValueException
- Throws:
KettleValueException
-
dat2str
public Value dat2str(String arg0, String arg1) throws KettleValueException
- Throws:
KettleValueException
-
num2dat
public Value num2dat() throws KettleValueException
- Throws:
KettleValueException
-
str2dat
public Value str2dat(String arg0) throws KettleValueException
- Throws:
KettleValueException
-
str2dat
public Value str2dat(String arg0, String arg1) throws KettleValueException
- Throws:
KettleValueException
-
str2num
public Value str2num() throws KettleValueException
- Throws:
KettleValueException
-
str2num
public Value str2num(String pattern) throws KettleValueException
- Throws:
KettleValueException
-
str2num
public Value str2num(String pattern, String decimal) throws KettleValueException
- Throws:
KettleValueException
-
str2num
public Value str2num(String pattern, String decimal, String grouping) throws KettleValueException
- Throws:
KettleValueException
-
str2num
public Value str2num(String pattern, String decimal, String grouping, String currency) throws KettleValueException
- Throws:
KettleValueException
-
dat2num
public Value dat2num() throws KettleValueException
- Throws:
KettleValueException
-
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()
-
e
public Value e()
-
pi
public Value pi()
-
v_decode
public Value v_decode(Value[] args) throws KettleValueException
- Throws:
KettleValueException
-
v_if
public Value v_if(Value[] args) throws KettleValueException
- Throws:
KettleValueException
-
add_months
public Value add_months(int months) throws KettleValueException
- Throws:
KettleValueException
-
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
-
last_day
public Value last_day() throws KettleValueException
- Throws:
KettleValueException
-
first_day
public Value first_day() throws KettleValueException
- Throws:
KettleValueException
-
trunc
public Value trunc() throws KettleValueException
- Throws:
KettleValueException
-
trunc
public Value trunc(double level) throws KettleValueException
- Throws:
KettleValueException
-
trunc
public Value trunc(int level) throws KettleValueException
- 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)
-
getXML
public String getXML()
Produce the XML representation of this value.- Specified by:
getXML
in interfaceXMLInterface
- 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
-
getValueInterface
public ValueInterface getValueInterface()
-
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 isnull
or empty- Parameters:
other
- The other value
-
-