Package org.pentaho.di.compatibility
Class Row
java.lang.Object
org.pentaho.di.compatibility.Row
- All Implemented Interfaces:
Serializable
,Comparable<Row>
,XMLInterface
This class describes a single row in a stream of data. A row is a array/list of Value objects.
Note that most methods in this class assume that a value with a certain name only occurs once in the Row.
- Since:
- Beginning 2003.
- Author:
- Matt
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRow()
Create a new empty row (with 0 values)Row
(DataInputStream dis) Read a row of Values from an input-stream.Row
(DataInputStream dis, int size, Row meta) Read a number of Values without meta-data into a row.Row
(DataInputStream dis, Row meta) Read a number of Values without meta-data into a row.Creates a new row as a duplicate of the given row. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.void
Add all the values of row r to the Row.void
Add a value on a certain location in the row.void
Add a value after the last value of the rowvoid
clear()
Removes all values from the row.Clone()
Returns an exact copy of this row.int
Compare 2 complete rows of values with each other.int
Compare 2 complete rows of values with each otherint
Compare 2 rows with each other using certain values in the rows and also considering an ascending clause.int
int
Compare 2 rows with each other using certain values in the rows and also considering an ascending clause.int
Compare 2 rows with each other using one value in the rows and also considering an ascending clause.int
boolean
static final byte[]
extractData
(Row row) get
(int idx) Deprecated.boolean
getBoolean
(String valuename, boolean def) Search for a value, if it doesn't occur in the row, return the default value.Search for a value, if it doesn't occur in the row, return the default value.String[]
Get an array of the names of all the Values in the Row.String[]
getFieldNamesAndTypes
(int maxlen) Get an array of strings showing the name of the values in the row padded to a maximum length, followed by the types of the values.long
getInteger
(String valuename, long def) Search for a value, if it doesn't occur in the row, return the default value.double
Search for a value, if it doesn't occur in the row, return the default value.static final Row
long
Search for a value, if it doesn't occur in the row, return the default value.Search for a value, if it doesn't occur in the row, return the default value.getValue
(int index) Get the value on a given position in the row.getXML()
Return the XML representation of a row.int
hashCode()
boolean
isEmpty()
Checks whether or not the row is empty A row is empty if all the values in the row are null A row is empty if there are no values in the row.boolean
Check wether or not this row should be ignored...void
Merge the data of row r to this Row.void
Merge the values of row r to this Row.void
print()
Print the names and the String representations of the values of the Values in row to stdout.void
remove
(int idx) Deprecated.void
removeValue
(int idx) Remove a value on a certain index.boolean
removeValue
(String valname) Remove a value with a given name from the row.searchValue
(String name) Search the Value by name in the row.int
searchValueIndex
(String name) Search the Value by name in the row, return the Values index.void
Marks this row as to be ignored by the next steps.void
setIgnore
(boolean i) Marks this row as to be ignored or not by the next steps.void
setUsedValueListeners
(List<ValueUsedListener> usedValueListeners) void
Set the value on index idx.int
size()
Return number of Values in Row.static final void
toString()
Convert the row to a String representation.Return the meta-data of a row as a String.void
write
(DataOutputStream dos) Write the content of the row to a DataOutputStream.boolean
Write a row of Values to a DataOutputStream, without saving the meta-data.
-
Field Details
-
XML_TAG
- See Also:
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
-
Constructor Details
-
Row
public Row()Create a new empty row (with 0 values) -
Row
Creates a new row as a duplicate of the given row. The values are copied one by one into new values.- Parameters:
r
- The row to be copied.
-
Row
Read a row of Values from an input-stream.- Parameters:
dis
- The DataInputStream to read from- Throws:
KettleFileException
-
Row
Read a number of Values without meta-data into a row.- Parameters:
dis
- The DataInputStream to read frommeta
- The description (name, type, length, precision) of the values to be read (the same number of values are read)- Throws:
KettleFileException
- if the row couldn't be created by reading from the data input stream.
-
Row
Read a number of Values without meta-data into a row.- Parameters:
dis
- The DataInputStream to read fromsize
- the number or values to readmeta
- The description (name, type, length, precision) of the values to be read- Throws:
KettleFileException
- if the row couldn't be created by reading from the data input stream.
-
Row
-
-
Method Details
-
getValue
Get the value on a given position in the row.- Parameters:
index
- The position to look for- Returns:
- The Value on in the given index
-
addValue
Add a value after the last value of the row- Parameters:
v
- The value to add to the row
-
setValue
Set the value on index idx.- Parameters:
idx
- The indexv
- The value to set
-
addValue
Add a value on a certain location in the row.- Parameters:
idx
- The index where the value needs to be put in the rowv
- The value to add to the row
-
add
Deprecated.Add an object to the row.- Parameters:
obj
- the object to add
-
get
Deprecated.Get an object from the row.- Parameters:
idx
- the index to get the object from- Returns:
- the object
-
remove
Deprecated.Remove an object in the row on index idx.- Parameters:
idx
- The object to remove
-
removeValue
Remove a value with a given name from the row.- Parameters:
valname
- The value name to remove from this row- Returns:
- true if the value was found and removed, false if the value wasn't found.
-
removeValue
public void removeValue(int idx) Remove a value on a certain index.- Parameters:
idx
- the index to remove in the row
-
clear
public void clear()Removes all values from the row. -
addRow
Add all the values of row r to the Row.- Parameters:
r
- The row to be added to this row.
-
mergeRow
Merge the values of row r to this Row. Merge means: only the values that are not yet in the row are added (comparing on the value name).- Parameters:
r
- The row to be merged with this row
-
mergeData
Merge the data of row r to this Row. That means: All fields in row r that do exist in this row (same name and same type) and have non-empty values will have their values written into this row, if the value of that field is empty in this row.- Parameters:
r
- The row to be merged with this row
-
searchValueIndex
Search the Value by name in the row, return the Values index.- Parameters:
name
- the value name to search for.- Returns:
- the index of the value with the given name, -1 is nothing was found.
-
searchValue
Search the Value by name in the row.- Parameters:
name
- the value name to search for- Returns:
- the Value with the given name, null if nothing was found.
-
size
public int size()Return number of Values in Row.- Returns:
- number of Values.
-
print
public void print()Print the names and the String representations of the values of the Values in row to stdout. -
toString
Convert the row to a String representation. -
toStringMeta
Return the meta-data of a row as a String.- Returns:
- the meta-data of a row as a String
-
setIgnore
public void setIgnore()Marks this row as to be ignored by the next steps. -
setIgnore
public void setIgnore(boolean i) Marks this row as to be ignored or not by the next steps.- Parameters:
i
- true: ignore this row, false: don't ignore.
-
isIgnored
public boolean isIgnored()Check wether or not this row should be ignored...- Returns:
- true if the row should be ignored.
-
write
Write the content of the row to a DataOutputStream.- Parameters:
dos
- The DataOutputStream to write to- Throws:
KettleFileException
- if an error occurs.
-
writeData
Write a row of Values to a DataOutputStream, without saving the meta-data.- Parameters:
dos
- The DataOutputStream to write to- Returns:
- true if the row was written successfuly, false if something went wrong.
- Throws:
KettleFileException
-
compare
Compare 2 rows with each other using certain values in the rows and also considering an ascending clause.- Parameters:
r
- The row to compare withfieldnrs
- The indexes of the values to compareascending
- an entry for each value to compare where true means and normal compare, false the reverse.- Returns:
- -1 if the row is smaller, 0 if they are equal and 1 if the row is larger.
-
compare
-
compare
public int compare(Row r, int[] fieldnrs1, int[] fieldnrs2, boolean[] ascending, boolean[] caseInsensitive) Compare 2 rows with each other using certain values in the rows and also considering an ascending clause.- Parameters:
r
- The row to compare withfieldnrs
- The indexes of the values to compare in the source row (this)fieldnrs2
- The indexes of the values to compare with.ascending
- an entry for each value to compare where true means and normal compare, false the reverse.- Returns:
- -1 if the row is smaller, 0 if they are equal and 1 if the row is larger.
-
compare
Compare 2 rows with each other using one value in the rows and also considering an ascending clause.- Parameters:
r
- The row to compare withfieldnr
- The indexe of the values to comparesort_desc
- true means and normal compare, false the reverse.- Returns:
- -1 if the row is smaller, 0 if they are equal and 1 if the row is larger.
-
compare
Compare 2 complete rows of values with each other. Strings are compared in a case insensitive way- Parameters:
r
- the row to compare with- Returns:
- -1 if the row is smaller, 0 if both rows are equal, 1 if the row is larger.
-
compare
Compare 2 complete rows of values with each other- Parameters:
r
- the row to compare with- Returns:
- -1 if the row is smaller, 0 if both rows are equal, 1 if the row is larger.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Row>
-
equals
-
hashCode
public int hashCode() -
Clone
Returns an exact copy of this row. On purpose not the real clone() method (notice the uppercase 'C') because of (rhino) javascript problems with it.- Returns:
- an exact copy of this row
-
isEmpty
public boolean isEmpty()Checks whether or not the row is empty A row is empty if all the values in the row are null A row is empty if there are no values in the row.- Returns:
- true if the row is considered empty, false if the row is not empty.
-
getFieldNames
Get an array of the names of all the Values in the Row.- Returns:
- an array of Strings: the names of all the Values in the Row.
-
getFieldNamesAndTypes
Get an array of strings showing the name of the values in the row padded to a maximum length, followed by the types of the values.- Parameters:
maxlen
- The length to which the name will be padded.- Returns:
- an array of strings: the names and the types of the fieldnames in the row.
-
getBoolean
Search for a value, if it doesn't occur in the row, return the default value.- Parameters:
valuename
- The valuename to look fordef
- The default value to return- Returns:
- The boolean representation of the value found or the default
-
getString
Search for a value, if it doesn't occur in the row, return the default value.- Parameters:
valuename
- The valuename to look fordef
- The default value to return- Returns:
- The String representation of the value found or the default
-
getDate
Search for a value, if it doesn't occur in the row, return the default value.- Parameters:
valuename
- The valuename to look fordef
- The default value to return- Returns:
- The Date representation of the value found or the default
-
getNumber
Search for a value, if it doesn't occur in the row, return the default value.- Parameters:
valuename
- The valuename to look fordef
- The default value to return- Returns:
- The double representation of the value found or the default
-
getInteger
Search for a value, if it doesn't occur in the row, return the default value.- Parameters:
valuename
- The valuename to look fordef
- The default value to return- Returns:
- The long integer representation of the value found or the default
-
getShort
Search for a value, if it doesn't occur in the row, return the default value.- Parameters:
valuename
- The valuename to look fordef
- The default value to return- Returns:
- The short integer representation of the value found or the default
-
getXML
Return the XML representation of a row.- Specified by:
getXML
in interfaceXMLInterface
- Returns:
- The XML representation of this row
-
sortRows
-
extractData
-
getRow
-
getUsedValueListeners
- Returns:
- the usedValueListeners
-
setUsedValueListeners
- Parameters:
usedValueListeners
- the usedValueListeners to set
-