org.pentaho.di.core.row
Class ValueMeta

java.lang.Object
  extended by org.pentaho.di.core.row.ValueMeta
All Implemented Interfaces:
Cloneable, ValueMetaInterface

public class ValueMeta
extends Object
implements ValueMetaInterface

Author:
jb

Field Summary
static String DEFAULT_DATE_FORMAT_MASK
           
static boolean EMPTY_STRING_AND_NULL_ARE_DIFFERENT
           
static String[] SINGLE_BYTE_ENCODINGS
           
static String[] trimTypeCode
          The trim type codes
static String[] trimTypeDesc
          The trim description
static String XML_DATA_TAG
           
static String XML_META_TAG
           
 
Fields inherited from interface org.pentaho.di.core.row.ValueMetaInterface
DEFAULT_INTEGER_LENGTH, SORT_TYPE_ASCENDING, SORT_TYPE_DESCENDING, SORT_TYPE_NOT_SORTED, sortTypeCodes, STORAGE_TYPE_BINARY_STRING, STORAGE_TYPE_INDEXED, STORAGE_TYPE_NORMAL, storageTypeCodes, TRIM_TYPE_BOTH, TRIM_TYPE_LEFT, TRIM_TYPE_NONE, TRIM_TYPE_RIGHT, TYPE_BIGNUMBER, TYPE_BINARY, TYPE_BOOLEAN, TYPE_DATE, TYPE_INTEGER, TYPE_NONE, TYPE_NUMBER, TYPE_SERIALIZABLE, TYPE_STRING, typeCodes
 
Constructor Summary
ValueMeta()
           
ValueMeta(DataInputStream inputStream)
           
ValueMeta(Node node)
           
ValueMeta(String name)
           
ValueMeta(String name, int type)
           
ValueMeta(String name, int type, int storageType)
           
ValueMeta(String name, int type, int length, int precision)
           
 
Method Summary
 ValueMeta clone()
           
 Object cloneValueData(Object object)
          Clones the data.
 int compare(Object data1, Object data2)
          Compare 2 values of the same data type
 int compare(Object data1, ValueMetaInterface meta2, Object data2)
          Compare 2 values of the same data type
 Object convertBinaryStringToNativeType(byte[] binary)
          Convert the binary data to the actual data type.
- byte[] --> Long (Integer) - byte[] --> Double (Number) - byte[] --> BigDecimal (BigNumber) - byte[] --> Date (Date) - byte[] --> Boolean (Boolean) - byte[] --> byte[] (Binary)
 Object convertData(ValueMetaInterface meta2, Object data2)
          Convert the specified data to the data type specified in this object.
 Object convertDataCompatible(ValueMetaInterface meta2, Object data2)
          Convert the specified data to the data type specified in this object.
 Object convertDataFromString(String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull, int trim_type)
          Convert the specified string to the data type specified in this object.
 Object convertDataUsingConversionMetaData(Object data2)
          Convert an object to the data type specified in the conversion metadata
 Object convertNormalStorageTypeToBinaryString(Object object)
          Convert a normal storage type to a binary string object.
static Boolean convertStringToBoolean(String string)
           
 Object convertToBinaryStringStorageType(Object object)
          Converts the specified data object to the binary string storage type.
 Object convertToNormalStorageType(Object object)
          Converts the specified data object to the normal storage type.
 Value createOriginalValue(Object data)
          Create an old-style value for backward compatibility reasons
static String[] getAllTypes()
          Get an array of String describing the possible types a Value can have.
 BigDecimal getBigNumber(Object object)
          Convert the supplied data to a BigNumber
 byte[] getBinary(Object object)
          Convert the supplied data to binary data
 byte[] getBinaryString(Object object)
          convert the supplied data to a binary string representation (for writing text)
 Boolean getBoolean(Object object)
          Convert the supplied data to a Boolean
 String getComments()
           
 String getCompatibleString(Object object)
          Convert the supplied data to a String compatible with version 2.5.
 String getConversionMask()
           
 ValueMetaInterface getConversionMetadata()
          This conversion metadata can be attached to a String object to see where it came from and with which mask it was generated, the encoding, the local languages used, padding, etc.
 String getCurrencySymbol()
           
 String getDataXML(Object object)
           
 Date getDate(Object object)
          Convert the supplied data to a Date
 SimpleDateFormat getDateFormat()
           
 Locale getDateFormatLocale()
           
 DecimalFormat getDecimalFormat()
           
 DecimalFormat getDecimalFormat(boolean useBigDecimal)
           
 String getDecimalSymbol()
           
 String getGroupingSymbol()
           
 Object[] getIndex()
           
 Long getInteger(Object object)
          Convert the supplied data to an Integer
 int getLength()
           
 String getMetaXML()
           
 String getName()
           
 Double getNumber(Object object)
          Convert the supplied data to a Number
 long getNumberOfBinaryStringConversions()
           
 String getOrigin()
           
 int getOriginalColumnType()
          store original JDBC RecordSetMetaData for later use
 String getOriginalColumnTypeName()
           
 int getOriginalPrecision()
           
 int getOriginalScale()
           
 int getPrecision()
           
 ValueMetaInterface getStorageMetadata()
           
 int getStorageType()
           
static int getStorageType(String desc)
          Convert the String description of a storage type to an integer type.
static String getStorageTypeCode(int storageType)
           
 String getStorageTypeDesc()
          Return the storage type of a value in a textual form: "normal", "binary-string", "indexes"
 String getString(Object object)
          Convert the supplied data to a String
 String getStringEncoding()
           
 int getTrimType()
           
static int getTrimTypeByCode(String tt)
           
static int getTrimTypeByDesc(String tt)
           
static String getTrimTypeCode(int i)
           
static String[] getTrimTypeCodes()
           
static String getTrimTypeDesc(int i)
           
static String[] getTrimTypeDescriptions()
           
 int getType()
           
static 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 type)
          TODO: change Desc to Code all over the place.
static String[] getTypes()
          get an array of String describing the possible types a Value can have.
 Object getValue(Node node)
          Convert a data XML node to an Object that corresponds to the metadata.
 Object getValueData(Value value)
          Extracts the primitive data from an old style Value object
 int hashCode(Object object)
          Calculate the hashcode of the specified data object
 boolean isBigNumber()
          Checks whether or not the value is a Big Number
 boolean isBigNumberFormatting()
           
 boolean isBinary()
          Checks whether or not this value is of type Binary
 boolean isBoolean()
          Checks whether or not this value is a boolean
 boolean isCaseInsensitive()
           
 boolean isDate()
          Checks whether or not this value is a Date
 boolean isDateFormatLenient()
           
 boolean isInteger()
          Checks whether or not this value is an Integer
 boolean isLargeTextField()
           
 boolean isNull(Object data)
          Determine if an object is null.
 boolean isNumber()
          Checks whether or not the value is a Number
 boolean isNumeric()
          Checks whether or not this Value is Numeric A Value is numeric if it is either of type Number or Integer
static boolean isNumeric(int t)
          Checks whether or not the specified type is either Integer or Number
 boolean isOriginalAutoIncrement()
           
 int isOriginalNullable()
           
 boolean isOriginalSigned()
           
 boolean isOutputPaddingEnabled()
           
 boolean isSerializableType()
          Checks whether or not this value is of type Serializable
 boolean isSingleByteEncoding()
           
 boolean isSortedAscending()
           
 boolean isSortedDescending()
           
 boolean isStorageBinaryString()
           
 boolean isStorageIndexed()
           
 boolean isStorageNormal()
           
 boolean isString()
          Checks whether or not the value is a String.
 Object readData(DataInputStream inputStream)
          De-serialize data from an inputstream.
 boolean requiresRealClone()
           
 void setBigNumberFormatting(boolean bigNumberFormatting)
           
 void setCaseInsensitive(boolean caseInsensitive)
           
 void setComments(String comments)
           
 void setConversionMask(String conversionMask)
           
 void setConversionMetadata(ValueMetaInterface conversionMetadata)
          Attach conversion metadata to a String object to see where it came from and with which mask it was generated, the encoding, the local languages used, padding, etc.
 void setCurrencySymbol(String currencySymbol)
           
 void setDateFormatLenient(boolean dateFormatLenient)
           
 void setDateFormatLocale(Locale dateFormatLocale)
           
 void setDecimalSymbol(String decimalSymbol)
           
 void setGroupingSymbol(String groupingSymbol)
           
 void setIndex(Object[] index)
           
 void setLargeTextField(boolean largeTextField)
           
 void setLength(int length)
           
 void setLength(int length, int precision)
           
 void setName(String name)
           
 void setNumberOfBinaryStringConversions(long numberOfBinaryStringConversions)
           
 void setOrigin(String origin)
           
 void setOriginalAutoIncrement(boolean originalAutoIncrement)
           
 void setOriginalColumnType(int originalColumnType)
           
 void setOriginalColumnTypeName(String originalColumnTypeName)
           
 void setOriginalNullable(int originalNullable)
           
 void setOriginalPrecision(int originalPrecision)
           
 void setOriginalScale(int originalScale)
           
 void setOriginalSigned(boolean originalSigned)
           
 void setOutputPaddingEnabled(boolean outputPaddingEnabled)
           
 void setPrecision(int precision)
           
 void setSortedDescending(boolean sortedDescending)
           
 void setStorageMetadata(ValueMetaInterface storageMetadata)
           
 void setStorageType(int storageType)
           
 void setStringEncoding(String encoding)
           
 void setTrimType(int trimType)
           
 void setType(int type)
           
 String toString()
           
 String toStringMeta()
          a String text representation of this Value, optionally padded to the specified length
 void writeData(DataOutputStream outputStream, Object object)
          Serialize the content of the specified data object to the outputStream.
 void writeMeta(DataOutputStream outputStream)
          Write the content of this class (metadata) to the specified output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_DATE_FORMAT_MASK

public static final String DEFAULT_DATE_FORMAT_MASK
See Also:
Constant Field Values

XML_META_TAG

public static final String XML_META_TAG
See Also:
Constant Field Values

XML_DATA_TAG

public static final String XML_DATA_TAG
See Also:
Constant Field Values

EMPTY_STRING_AND_NULL_ARE_DIFFERENT

public static final boolean EMPTY_STRING_AND_NULL_ARE_DIFFERENT

trimTypeCode

public static final String[] trimTypeCode
The trim type codes


trimTypeDesc

public static final String[] trimTypeDesc
The trim description


SINGLE_BYTE_ENCODINGS

public static final String[] SINGLE_BYTE_ENCODINGS
Constructor Detail

ValueMeta

public ValueMeta()

ValueMeta

public ValueMeta(String name)

ValueMeta

public ValueMeta(String name,
                 int type)

ValueMeta

public ValueMeta(String name,
                 int type,
                 int storageType)

ValueMeta

public ValueMeta(String name,
                 int type,
                 int length,
                 int precision)

ValueMeta

public ValueMeta(DataInputStream inputStream)
          throws KettleFileException,
                 KettleEOFException
Throws:
KettleFileException
KettleEOFException

ValueMeta

public ValueMeta(Node node)
          throws KettleException
Throws:
KettleException
Method Detail

clone

public ValueMeta clone()
Specified by:
clone in interface ValueMetaInterface
Overrides:
clone in class Object
Returns:
a copy of this value meta object

getComments

public String getComments()
Specified by:
getComments in interface ValueMetaInterface
Returns:
the comments

setComments

public void setComments(String comments)
Specified by:
setComments in interface ValueMetaInterface
Parameters:
comments - the comments to set

getIndex

public Object[] getIndex()
Specified by:
getIndex in interface ValueMetaInterface
Returns:
the index

setIndex

public void setIndex(Object[] index)
Specified by:
setIndex in interface ValueMetaInterface
Parameters:
index - the index to set

getLength

public int getLength()
Specified by:
getLength in interface ValueMetaInterface
Returns:
the length

setLength

public void setLength(int length)
Specified by:
setLength in interface ValueMetaInterface
Parameters:
length - the length to set

setLength

public void setLength(int length,
                      int precision)
Specified by:
setLength in interface ValueMetaInterface
Parameters:
length - the length to set

getName

public String getName()
Specified by:
getName in interface ValueMetaInterface
Returns:
the name

setName

public void setName(String name)
Specified by:
setName in interface ValueMetaInterface
Parameters:
name - the name to set

getOrigin

public String getOrigin()
Specified by:
getOrigin in interface ValueMetaInterface
Returns:
the origin

setOrigin

public void setOrigin(String origin)
Specified by:
setOrigin in interface ValueMetaInterface
Parameters:
origin - the origin to set

getPrecision

public int getPrecision()
Specified by:
getPrecision in interface ValueMetaInterface
Returns:
the precision

setPrecision

public void setPrecision(int precision)
Specified by:
setPrecision in interface ValueMetaInterface
Parameters:
precision - the precision to set

getStorageType

public int getStorageType()
Specified by:
getStorageType in interface ValueMetaInterface
Returns:
the storageType

setStorageType

public void setStorageType(int storageType)
Specified by:
setStorageType in interface ValueMetaInterface
Parameters:
storageType - the storageType to set

isStorageNormal

public boolean isStorageNormal()
Specified by:
isStorageNormal in interface ValueMetaInterface

isStorageIndexed

public boolean isStorageIndexed()
Specified by:
isStorageIndexed in interface ValueMetaInterface

isStorageBinaryString

public boolean isStorageBinaryString()
Specified by:
isStorageBinaryString in interface ValueMetaInterface

getType

public int getType()
Specified by:
getType in interface ValueMetaInterface
Returns:
the type

setType

public void setType(int type)
Specified by:
setType in interface ValueMetaInterface
Parameters:
type - the type to set

getConversionMask

public String getConversionMask()
Specified by:
getConversionMask in interface ValueMetaInterface
Returns:
the conversionMask

setConversionMask

public void setConversionMask(String conversionMask)
Specified by:
setConversionMask in interface ValueMetaInterface
Parameters:
conversionMask - the conversionMask to set

getStringEncoding

public String getStringEncoding()
Specified by:
getStringEncoding in interface ValueMetaInterface
Returns:
the encoding

setStringEncoding

public void setStringEncoding(String encoding)
Specified by:
setStringEncoding in interface ValueMetaInterface
Parameters:
encoding - the encoding to set

getDecimalSymbol

public String getDecimalSymbol()
Specified by:
getDecimalSymbol in interface ValueMetaInterface
Returns:
the decimalSymbol

setDecimalSymbol

public void setDecimalSymbol(String decimalSymbol)
Specified by:
setDecimalSymbol in interface ValueMetaInterface
Parameters:
decimalSymbol - the decimalSymbol to set

getGroupingSymbol

public String getGroupingSymbol()
Specified by:
getGroupingSymbol in interface ValueMetaInterface
Returns:
the groupingSymbol

setGroupingSymbol

public void setGroupingSymbol(String groupingSymbol)
Specified by:
setGroupingSymbol in interface ValueMetaInterface
Parameters:
groupingSymbol - the groupingSymbol to set

getCurrencySymbol

public String getCurrencySymbol()
Specified by:
getCurrencySymbol in interface ValueMetaInterface
Returns:
the currencySymbol

setCurrencySymbol

public void setCurrencySymbol(String currencySymbol)
Specified by:
setCurrencySymbol in interface ValueMetaInterface
Parameters:
currencySymbol - the currencySymbol to set

isCaseInsensitive

public boolean isCaseInsensitive()
Specified by:
isCaseInsensitive in interface ValueMetaInterface
Returns:
the caseInsensitive

setCaseInsensitive

public void setCaseInsensitive(boolean caseInsensitive)
Specified by:
setCaseInsensitive in interface ValueMetaInterface
Parameters:
caseInsensitive - the caseInsensitive to set

isSortedDescending

public boolean isSortedDescending()
Specified by:
isSortedDescending in interface ValueMetaInterface
Returns:
the sortedDescending

setSortedDescending

public void setSortedDescending(boolean sortedDescending)
Specified by:
setSortedDescending in interface ValueMetaInterface
Parameters:
sortedDescending - the sortedDescending to set

isOutputPaddingEnabled

public boolean isOutputPaddingEnabled()
Specified by:
isOutputPaddingEnabled in interface ValueMetaInterface
Returns:
true if output padding is enabled (padding to specified length)

setOutputPaddingEnabled

public void setOutputPaddingEnabled(boolean outputPaddingEnabled)
Specified by:
setOutputPaddingEnabled in interface ValueMetaInterface
Parameters:
outputPaddingEnabled - Set to true if output padding is to be enabled (padding to specified length)

isLargeTextField

public boolean isLargeTextField()
Specified by:
isLargeTextField in interface ValueMetaInterface
Returns:
true if this is a large text field (CLOB, TEXT) with arbitrary length.

setLargeTextField

public void setLargeTextField(boolean largeTextField)
Specified by:
setLargeTextField in interface ValueMetaInterface
Parameters:
largeTextField - Set to true if this is to be a large text field (CLOB, TEXT) with arbitrary length.

isDateFormatLenient

public boolean isDateFormatLenient()
Specified by:
isDateFormatLenient in interface ValueMetaInterface
Returns:
the dateFormatLenient

setDateFormatLenient

public void setDateFormatLenient(boolean dateFormatLenient)
Specified by:
setDateFormatLenient in interface ValueMetaInterface
Parameters:
dateFormatLenient - the dateFormatLenient to set

getDateFormatLocale

public Locale getDateFormatLocale()
Specified by:
getDateFormatLocale in interface ValueMetaInterface
Returns:
the dateFormatLocale

setDateFormatLocale

public void setDateFormatLocale(Locale dateFormatLocale)
Specified by:
setDateFormatLocale in interface ValueMetaInterface
Parameters:
dateFormatLocale - the dateFormatLocale to set

getDateFormat

public SimpleDateFormat getDateFormat()
Specified by:
getDateFormat in interface ValueMetaInterface

getDecimalFormat

public DecimalFormat getDecimalFormat()
Specified by:
getDecimalFormat in interface ValueMetaInterface

getDecimalFormat

public DecimalFormat getDecimalFormat(boolean useBigDecimal)
Specified by:
getDecimalFormat in interface ValueMetaInterface

convertStringToBoolean

public static Boolean convertStringToBoolean(String string)

convertToNormalStorageType

public Object convertToNormalStorageType(Object object)
                                  throws KettleValueException
Converts the specified data object to the normal storage type.

Specified by:
convertToNormalStorageType in interface ValueMetaInterface
Parameters:
object - the data object to convert
Returns:
the data in a normal storage type
Throws:
KettleValueException - In case there is a data conversion error.

convertToBinaryStringStorageType

public Object convertToBinaryStringStorageType(Object object)
                                        throws KettleValueException
Converts the specified data object to the binary string storage type.

Specified by:
convertToBinaryStringStorageType in interface ValueMetaInterface
Parameters:
object - the data object to convert
Returns:
the data in a binary string storage type
Throws:
KettleValueException - In case there is a data conversion error.

convertBinaryStringToNativeType

public Object convertBinaryStringToNativeType(byte[] binary)
                                       throws KettleValueException
Convert the binary data to the actual data type.
- byte[] --> Long (Integer) - byte[] --> Double (Number) - byte[] --> BigDecimal (BigNumber) - byte[] --> Date (Date) - byte[] --> Boolean (Boolean) - byte[] --> byte[] (Binary)

Specified by:
convertBinaryStringToNativeType in interface ValueMetaInterface
Parameters:
binary -
Returns:
Throws:
KettleValueException

convertNormalStorageTypeToBinaryString

public Object convertNormalStorageTypeToBinaryString(Object object)
                                              throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert a normal storage type to a binary string object. (for comparison reasons)

Specified by:
convertNormalStorageTypeToBinaryString in interface ValueMetaInterface
Parameters:
object - The object expressed in a normal storage type
Returns:
a binary string
Throws:
KettleValueException - in case there is a data conversion error

cloneValueData

public Object cloneValueData(Object object)
                      throws KettleValueException
Clones the data. Normally, we don't have to do anything here, but just for arguments and safety, we do a little extra work in case of binary blobs and Date objects. We should write a programmers manual later on to specify in all clarity that "we always overwrite/replace values in the Object[] data rows, we never modify them".

Specified by:
cloneValueData in interface ValueMetaInterface
Returns:
a cloned data object if needed
Throws:
KettleValueException

getCompatibleString

public String getCompatibleString(Object object)
                           throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to a String compatible with version 2.5.

Specified by:
getCompatibleString in interface ValueMetaInterface
Throws:
KettleValueException

getString

public String getString(Object object)
                 throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to a String

Specified by:
getString in interface ValueMetaInterface
Throws:
KettleValueException

getNumber

public Double getNumber(Object object)
                 throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to a Number

Specified by:
getNumber in interface ValueMetaInterface
Throws:
KettleValueException

getInteger

public Long getInteger(Object object)
                throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to an Integer

Specified by:
getInteger in interface ValueMetaInterface
Throws:
KettleValueException

getBigNumber

public BigDecimal getBigNumber(Object object)
                        throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to a BigNumber

Specified by:
getBigNumber in interface ValueMetaInterface
Throws:
KettleValueException

getBoolean

public Boolean getBoolean(Object object)
                   throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to a Boolean

Specified by:
getBoolean in interface ValueMetaInterface
Throws:
KettleValueException

getDate

public Date getDate(Object object)
             throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to a Date

Specified by:
getDate in interface ValueMetaInterface
Throws:
KettleValueException

getBinary

public byte[] getBinary(Object object)
                 throws KettleValueException
Description copied from interface: ValueMetaInterface
Convert the supplied data to binary data

Specified by:
getBinary in interface ValueMetaInterface
Throws:
KettleValueException

getBinaryString

public byte[] getBinaryString(Object object)
                       throws KettleValueException
Description copied from interface: ValueMetaInterface
convert the supplied data to a binary string representation (for writing text)

Specified by:
getBinaryString in interface ValueMetaInterface
Throws:
KettleValueException

isString

public boolean isString()
Checks whether or not the value is a String.

Specified by:
isString in interface ValueMetaInterface
Returns:
true if the value is a String.

isDate

public boolean isDate()
Checks whether or not this value is a Date

Specified by:
isDate in interface ValueMetaInterface
Returns:
true if the value is a Date

isBigNumber

public boolean isBigNumber()
Checks whether or not the value is a Big Number

Specified by:
isBigNumber in interface ValueMetaInterface
Returns:
true is this value is a big number

isNumber

public boolean isNumber()
Checks whether or not the value is a Number

Specified by:
isNumber in interface ValueMetaInterface
Returns:
true is this value is a number

isBoolean

public boolean isBoolean()
Checks whether or not this value is a boolean

Specified by:
isBoolean in interface ValueMetaInterface
Returns:
true if this value has type boolean.

isSerializableType

public boolean isSerializableType()
Checks whether or not this value is of type Serializable

Specified by:
isSerializableType in interface ValueMetaInterface
Returns:
true if this value has type Serializable

isBinary

public boolean isBinary()
Checks whether or not this value is of type Binary

Specified by:
isBinary in interface ValueMetaInterface
Returns:
true if this value has type Binary

isInteger

public boolean isInteger()
Checks whether or not this value is an Integer

Specified by:
isInteger in interface ValueMetaInterface
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

Specified by:
isNumeric in interface ValueMetaInterface
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

isSortedAscending

public boolean isSortedAscending()

getTypeDesc

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

Specified by:
getTypeDesc in interface ValueMetaInterface
Returns:
A String describing the type of value.

getStorageTypeDesc

public String getStorageTypeDesc()
Return the storage type of a value in a textual form: "normal", "binary-string", "indexes"

Returns:
A String describing the storage type of the value metadata

toString

public String toString()
Overrides:
toString in class Object

toStringMeta

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

Specified by:
toStringMeta in interface ValueMetaInterface
Returns:
a String text representation of this Value, optionally padded to the specified length

writeData

public void writeData(DataOutputStream outputStream,
                      Object object)
               throws KettleFileException
Description copied from interface: ValueMetaInterface
Serialize the content of the specified data object to the outputStream. No metadata is written.

Specified by:
writeData in interface ValueMetaInterface
Parameters:
outputStream - the outputstream to write to
object - the data object to serialize
Throws:
KettleFileException - in case a I/O error occurs

readData

public Object readData(DataInputStream inputStream)
                throws KettleFileException,
                       KettleEOFException,
                       SocketTimeoutException
Description copied from interface: ValueMetaInterface
De-serialize data from an inputstream. No metadata is read or changed.

Specified by:
readData in interface ValueMetaInterface
Parameters:
inputStream - the input stream to read from
Returns:
a new data object
Throws:
KettleFileException - in case a I/O error occurs
KettleEOFException - When we have read all the data there is to read
SocketTimeoutException - In case there is a timeout (when set on a socket) during reading

writeMeta

public void writeMeta(DataOutputStream outputStream)
               throws KettleFileException
Description copied from interface: ValueMetaInterface
Write the content of this class (metadata) to the specified output stream.

Specified by:
writeMeta in interface ValueMetaInterface
Parameters:
outputStream - the outputstream to write to
Throws:
KettleFileException - in case a I/O error occurs

getMetaXML

public String getMetaXML()
                  throws IOException
Specified by:
getMetaXML in interface ValueMetaInterface
Returns:
an XML representation of the row metadata
Throws:
IOException - Thrown in case there is an (Base64/GZip) decoding problem

getDataXML

public String getDataXML(Object object)
                  throws IOException
Specified by:
getDataXML in interface ValueMetaInterface
Parameters:
object - The data to serialize as XML
Returns:
an xML representation of the row data
Throws:
IOException - Thrown in case there is an (Base64/GZip) decoding problem

getValue

public Object getValue(Node node)
                throws KettleException
Convert a data XML node to an Object that corresponds to the metadata. This is basically String to Object conversion that is being done.

Specified by:
getValue in interface ValueMetaInterface
Parameters:
node - the node to retrieve the data value from
Returns:
the converted data value
Throws:
IOException - thrown in case there is a problem with the XML to object conversion
KettleException - thrown in case there is a problem with the XML to object conversion

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.

getTypeDesc

public static final String getTypeDesc(int type)
TODO: change Desc to Code all over the place. Make sure we can localise this stuff later on.

Parameters:
type - the type
Returns:
the description (code) of the type

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. (ValueMetaInterface.TYPE_...)

getStorageType

public static final int getStorageType(String desc)
Convert the String description of a storage type to an integer type.

Parameters:
desc - The description of the storage type to convert
Returns:
The integer storage type of the given String. (ValueMetaInterface.STORAGE_TYPE_...) or -1 if the storage type code not be found.

getStorageTypeCode

public static final String getStorageTypeCode(int storageType)

isNull

public boolean isNull(Object data)
               throws KettleValueException
Determine if an object is null. This is the case if data==null or if it's an empty string.

Specified by:
isNull in interface ValueMetaInterface
Parameters:
data - the object to test
Returns:
true if the object is considered null.
Throws:
KettleValueException - in case there is a conversion error (only thrown in case of lazy conversion)

compare

public int compare(Object data1,
                   Object data2)
            throws KettleValueException
Compare 2 values of the same data type

Specified by:
compare in interface ValueMetaInterface
Parameters:
data1 - the first value
data2 - the second value
Returns:
0 if the values are equal, -1 if data1 is smaller than data2 and +1 if it's larger.
Throws:
KettleValueException - In case we get conversion errors

compare

public int compare(Object data1,
                   ValueMetaInterface meta2,
                   Object data2)
            throws KettleValueException
Compare 2 values of the same data type

Specified by:
compare in interface ValueMetaInterface
Parameters:
data1 - the first value
meta2 - the second value's metadata
data2 - the second value
Returns:
0 if the values are equal, -1 if data1 is smaller than data2 and +1 if it's larger.
Throws:
KettleValueException - In case we get conversion errors

convertData

public Object convertData(ValueMetaInterface meta2,
                          Object data2)
                   throws KettleValueException
Convert the specified data to the data type specified in this object.

Specified by:
convertData in interface ValueMetaInterface
Parameters:
meta2 - the metadata of the object to be converted
data2 - the data of the object to be converted
Returns:
the object in the data type of this value metadata object
Throws:
KettleValueException - in case there is a data conversion error

convertDataCompatible

public Object convertDataCompatible(ValueMetaInterface meta2,
                                    Object data2)
                             throws KettleValueException
Convert the specified data to the data type specified in this object. For String conversion, be compatible with version 2.5.2.

Specified by:
convertDataCompatible in interface ValueMetaInterface
Parameters:
meta2 - the metadata of the object to be converted
data2 - the data of the object to be converted
Returns:
the object in the data type of this value metadata object
Throws:
KettleValueException - in case there is a data conversion error

convertDataUsingConversionMetaData

public Object convertDataUsingConversionMetaData(Object data2)
                                          throws KettleValueException
Convert an object to the data type specified in the conversion metadata

Specified by:
convertDataUsingConversionMetaData in interface ValueMetaInterface
Parameters:
data - The data
Returns:
The data converted to the storage data type
Throws:
KettleValueException - in case there is a conversion error.

convertDataFromString

public Object convertDataFromString(String pol,
                                    ValueMetaInterface convertMeta,
                                    String nullIf,
                                    String ifNull,
                                    int trim_type)
                             throws KettleValueException
Convert the specified string to the data type specified in this object.

Specified by:
convertDataFromString in interface ValueMetaInterface
Parameters:
pol - the string to be converted
convertMeta - the metadata of the object (only string type) to be converted
nullIf - set the object to null if pos equals nullif (IgnoreCase)
ifNull - set the object to ifNull when pol is empty or null
trim_type - the trim type to be used (ValueMetaInterface.TRIM_TYPE_XXX)
Returns:
the object in the data type of this value metadata object
Throws:
KettleValueException - in case there is a data conversion error

hashCode

public int hashCode(Object object)
             throws KettleValueException
Calculate the hashcode of the specified data object

Specified by:
hashCode in interface ValueMetaInterface
Parameters:
object - the data value to calculate a hashcode for
Returns:
the calculated hashcode
Throws:
KettleValueException

createOriginalValue

public Value createOriginalValue(Object data)
                          throws KettleValueException
Create an old-style value for backward compatibility reasons

Specified by:
createOriginalValue in interface ValueMetaInterface
Parameters:
data - the data to store in the value
Returns:
a newly created Value object
Throws:
KettleValueException - case there is a data conversion problem

getValueData

public Object getValueData(Value value)
                    throws KettleValueException
Extracts the primitive data from an old style Value object

Specified by:
getValueData in interface ValueMetaInterface
Parameters:
value - the old style Value object
Returns:
the value's data, NOT the meta data.
Throws:
KettleValueException - case there is a data conversion problem

getStorageMetadata

public ValueMetaInterface getStorageMetadata()
Specified by:
getStorageMetadata in interface ValueMetaInterface
Returns:
the storageMetadata

setStorageMetadata

public void setStorageMetadata(ValueMetaInterface storageMetadata)
Specified by:
setStorageMetadata in interface ValueMetaInterface
Parameters:
storageMetadata - the storageMetadata to set

getTrimType

public int getTrimType()
Specified by:
getTrimType in interface ValueMetaInterface
Returns:
the trimType

setTrimType

public void setTrimType(int trimType)
Specified by:
setTrimType in interface ValueMetaInterface
Parameters:
trimType - the trimType to set

getTrimTypeByCode

public static final int getTrimTypeByCode(String tt)

getTrimTypeByDesc

public static final int getTrimTypeByDesc(String tt)

getTrimTypeCode

public static final String getTrimTypeCode(int i)

getTrimTypeDesc

public static final String getTrimTypeDesc(int i)

getConversionMetadata

public ValueMetaInterface getConversionMetadata()
Description copied from interface: ValueMetaInterface
This conversion metadata can be attached to a String object to see where it came from and with which mask it was generated, the encoding, the local languages used, padding, etc.

Specified by:
getConversionMetadata in interface ValueMetaInterface
Returns:
the conversionMetadata

setConversionMetadata

public void setConversionMetadata(ValueMetaInterface conversionMetadata)
Description copied from interface: ValueMetaInterface
Attach conversion metadata to a String object to see where it came from and with which mask it was generated, the encoding, the local languages used, padding, etc.

Specified by:
setConversionMetadata in interface ValueMetaInterface
Parameters:
conversionMetadata - the conversionMetadata to set

isSingleByteEncoding

public boolean isSingleByteEncoding()
Specified by:
isSingleByteEncoding in interface ValueMetaInterface
Returns:
true if the String encoding used (storage) is single byte encoded.

getNumberOfBinaryStringConversions

public long getNumberOfBinaryStringConversions()
Specified by:
getNumberOfBinaryStringConversions in interface ValueMetaInterface
Returns:
the number of binary string to native data type conversions done with this object conversions

setNumberOfBinaryStringConversions

public void setNumberOfBinaryStringConversions(long numberOfBinaryStringConversions)
Specified by:
setNumberOfBinaryStringConversions in interface ValueMetaInterface
Parameters:
numberOfBinaryStringConversions - the number of binary string to native data type done with this object conversions to set

isOriginalAutoIncrement

public boolean isOriginalAutoIncrement()
Specified by:
isOriginalAutoIncrement in interface ValueMetaInterface

setOriginalAutoIncrement

public void setOriginalAutoIncrement(boolean originalAutoIncrement)
Specified by:
setOriginalAutoIncrement in interface ValueMetaInterface

getOriginalColumnType

public int getOriginalColumnType()
Description copied from interface: ValueMetaInterface
store original JDBC RecordSetMetaData for later use

Specified by:
getOriginalColumnType in interface ValueMetaInterface
See Also:
ResultSetMetaData

setOriginalColumnType

public void setOriginalColumnType(int originalColumnType)
Specified by:
setOriginalColumnType in interface ValueMetaInterface

getOriginalColumnTypeName

public String getOriginalColumnTypeName()
Specified by:
getOriginalColumnTypeName in interface ValueMetaInterface

setOriginalColumnTypeName

public void setOriginalColumnTypeName(String originalColumnTypeName)
Specified by:
setOriginalColumnTypeName in interface ValueMetaInterface

isOriginalNullable

public int isOriginalNullable()
Specified by:
isOriginalNullable in interface ValueMetaInterface

setOriginalNullable

public void setOriginalNullable(int originalNullable)
Specified by:
setOriginalNullable in interface ValueMetaInterface

getOriginalPrecision

public int getOriginalPrecision()
Specified by:
getOriginalPrecision in interface ValueMetaInterface

setOriginalPrecision

public void setOriginalPrecision(int originalPrecision)
Specified by:
setOriginalPrecision in interface ValueMetaInterface

getOriginalScale

public int getOriginalScale()
Specified by:
getOriginalScale in interface ValueMetaInterface

setOriginalScale

public void setOriginalScale(int originalScale)
Specified by:
setOriginalScale in interface ValueMetaInterface

isOriginalSigned

public boolean isOriginalSigned()
Specified by:
isOriginalSigned in interface ValueMetaInterface

setOriginalSigned

public void setOriginalSigned(boolean originalSigned)
Specified by:
setOriginalSigned in interface ValueMetaInterface

isBigNumberFormatting

public boolean isBigNumberFormatting()
Returns:
the bigNumberFormatting flag : true if BigNumbers of formatted as well

setBigNumberFormatting

public void setBigNumberFormatting(boolean bigNumberFormatting)
Parameters:
bigNumberFormatting - the bigNumberFormatting flag to set : true if BigNumbers of formatted as well

getTrimTypeCodes

public static String[] getTrimTypeCodes()
Returns:
The available trim type codes (NOT localized, use for persistence)

getTrimTypeDescriptions

public static String[] getTrimTypeDescriptions()
Returns:
The available trim type descriptions (localized)

requiresRealClone

public boolean requiresRealClone()
Specified by:
requiresRealClone in interface ValueMetaInterface
Returns:
true if the data type requires a real copy. Usually a binary or Serializable object