Class RowMeta

    • Method Detail

      • size

        public int size()
        Description copied from interface: RowMetaInterface
        Returns the size of the metadata row.
        Specified by:
        size in interface RowMetaInterface
        Returns:
        the number of values in the row
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: RowMetaInterface
        Returns true if there are no elements in the row metadata.
        Specified by:
        isEmpty in interface RowMetaInterface
        Returns:
        true if there are no elements in the row metadata
      • exists

        public boolean exists​(ValueMetaInterface meta)
        Description copied from interface: RowMetaInterface
        Check if a value is already present in this row with the same name.
        Specified by:
        exists in interface RowMetaInterface
        Parameters:
        meta - the value to check for existence
        Returns:
        true if a value with the same name already exists in the row
      • addValueMeta

        public void addValueMeta​(ValueMetaInterface meta)
        Add a metadata value. If a value with the same name already exists, it gets renamed.
        Specified by:
        addValueMeta in interface RowMetaInterface
        Parameters:
        meta - The metadata value to add
      • addValueMeta

        public void addValueMeta​(int index,
                                 ValueMetaInterface meta)
        Add a metadata value on a certain location in the row. If a value with the same name already exists, it gets renamed. Remember to change the data row according to this.
        Specified by:
        addValueMeta in interface RowMetaInterface
        Parameters:
        index - The index where the metadata value needs to be put in the row
        meta - The metadata value to add to the row
      • getValueMeta

        public ValueMetaInterface getValueMeta​(int index)
        Get the value metadata on the specified index.
        Specified by:
        getValueMeta in interface RowMetaInterface
        Parameters:
        index - The index to get the value metadata from
        Returns:
        The value metadata specified by the index.
      • setValueMeta

        public void setValueMeta​(int index,
                                 ValueMetaInterface valueMeta)
        Replaces a value meta entry in the row metadata with another one
        Specified by:
        setValueMeta in interface RowMetaInterface
        Parameters:
        index - The index in the row to replace at
        valueMeta - the metadata to replace with
      • getString

        public String getString​(Object[] dataRow,
                                int index)
                         throws KettleValueException
        Get a String value from a row of data. Convert data if this needed.
        Specified by:
        getString in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The string found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • getInteger

        public Long getInteger​(Object[] dataRow,
                               int index)
                        throws KettleValueException
        Get an Integer value from a row of data. Convert data if this needed.
        Specified by:
        getInteger in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The integer found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • getNumber

        public Double getNumber​(Object[] dataRow,
                                int index)
                         throws KettleValueException
        Get a Number value from a row of data. Convert data if this needed.
        Specified by:
        getNumber in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The number found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • getDate

        public Date getDate​(Object[] dataRow,
                            int index)
                     throws KettleValueException
        Get a Date value from a row of data. Convert data if this needed.
        Specified by:
        getDate in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The date found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • getBigNumber

        public BigDecimal getBigNumber​(Object[] dataRow,
                                       int index)
                                throws KettleValueException
        Get a BigNumber value from a row of data. Convert data if this needed.
        Specified by:
        getBigNumber in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The bignumber found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • getBoolean

        public Boolean getBoolean​(Object[] dataRow,
                                  int index)
                           throws KettleValueException
        Get a Boolean value from a row of data. Convert data if this needed.
        Specified by:
        getBoolean in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The boolean found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • getBinary

        public byte[] getBinary​(Object[] dataRow,
                                int index)
                         throws KettleValueException
        Get a Binary value from a row of data. Convert data if this needed.
        Specified by:
        getBinary in interface RowMetaInterface
        Parameters:
        dataRow - the row of data
        index - the index
        Returns:
        The binary found on that position in the row
        Throws:
        KettleValueException - in case there was a problem converting the data.
      • isNull

        public boolean isNull​(Object[] dataRow,
                              int index)
                       throws KettleValueException
        Determines whether a value in a row is null. A value is null when the object is null or when it's an empty String
        Specified by:
        isNull in interface RowMetaInterface
        Parameters:
        dataRow - The row of data
        index - the index to reference
        Returns:
        true if the value on the index is null.
        Throws:
        KettleValueException - in case there is a conversion error (only thrown in case of lazy conversion)
      • indexOfValue

        public int indexOfValue​(String valueName)
        Searches the index of a value meta with a given name
        Specified by:
        indexOfValue in interface RowMetaInterface
        Parameters:
        valueName - the name of the value metadata to look for
        Returns:
        the index or -1 in case we didn't find the value
      • searchValueMeta

        public ValueMetaInterface searchValueMeta​(String valueName)
        Searches for a value with a certain name in the value meta list
        Specified by:
        searchValueMeta in interface RowMetaInterface
        Parameters:
        valueName - The value name to search for
        Returns:
        The value metadata or null if nothing was found
      • addRowMeta

        public void addRowMeta​(RowMetaInterface rowMeta)
        Description copied from interface: RowMetaInterface
        Add a number of fields from another row (append to the end).
        Specified by:
        addRowMeta in interface RowMetaInterface
        Parameters:
        rowMeta - The row of metadata values to add
      • mergeRowMeta

        public void mergeRowMeta​(RowMetaInterface r)
        Merge the values of row r to this Row. The values that are not yet in the row are added unchanged. The values that are in the row are renamed to name_2, name_3, etc.
        Specified by:
        mergeRowMeta in interface RowMetaInterface
        Parameters:
        r - The row to be merged with this row
      • mergeRowMeta

        public void mergeRowMeta​(RowMetaInterface r,
                                 String originStepName)
        Merge the values of row r to this Row. The fields that are not yet in the row are added unchanged. The fields that are in the row are renamed to name_2, name_3, etc. If the fields are renamed, the provided originStepName will be assigned as the origin step for those fields.
        Specified by:
        mergeRowMeta in interface RowMetaInterface
        Parameters:
        r - The row to be merged with this row
        originStepName - The name to use as the origin step
      • getFieldNames

        public String[] getFieldNames()
        Get an array of the names of all the Values in the Row.
        Specified by:
        getFieldNames in interface RowMetaInterface
        Returns:
        an array of Strings: the names of all the Values in the Row.
      • removeValueMeta

        public void removeValueMeta​(int index)
        Description copied from interface: RowMetaInterface
        Remove a value metadata object on a certain index in the row.
        Specified by:
        removeValueMeta in interface RowMetaInterface
        Parameters:
        index - the index to remove the value metadata from
      • toStringMeta

        public String toStringMeta()
        Description copied from interface: RowMetaInterface
        To string meta.
        Specified by:
        toStringMeta in interface RowMetaInterface
        Returns:
        a string with a description of all the metadata values of the complete row of metadata
      • getFieldNamesAndTypes

        public 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.
        Specified by:
        getFieldNamesAndTypes in interface RowMetaInterface
        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.
      • compare

        public int compare​(Object[] rowData1,
                           Object[] rowData2,
                           int[] fieldnrs)
                    throws KettleValueException
        Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.
        Specified by:
        compare in interface RowMetaInterface
        Parameters:
        rowData1 - The first row of data
        rowData2 - The second row of data
        fieldnrs - the fields to compare on (in that order)
        Returns:
        0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
        Throws:
        KettleValueException
      • equals

        public boolean equals​(Object[] rowData1,
                              Object[] rowData2,
                              int[] fieldnrs)
                       throws KettleValueException
        Compare 2 rows with each other for equality using certain values in the rows and also considering the case sensitivity flag.
        Specified by:
        equals in interface RowMetaInterface
        Parameters:
        rowData1 - The first row of data
        rowData2 - The second row of data
        fieldnrs - the fields to compare on (in that order)
        Returns:
        true if the rows are considered equal, false if they are not.
        Throws:
        KettleValueException
      • compare

        public int compare​(Object[] rowData1,
                           Object[] rowData2,
                           int[] fieldnrs1,
                           int[] fieldnrs2)
                    throws KettleValueException
        Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.
        Specified by:
        compare in interface RowMetaInterface
        Parameters:
        rowData1 - The first row of data
        rowData2 - The second row of data
        fieldnrs1 - The indexes of the values to compare in the first row
        fieldnrs2 - The indexes of the values to compare with in the second row
        Returns:
        0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
        Throws:
        KettleValueException
      • compare

        public int compare​(Object[] rowData1,
                           RowMetaInterface rowMeta2,
                           Object[] rowData2,
                           int[] fieldnrs1,
                           int[] fieldnrs2)
                    throws KettleValueException
        Compare 2 rows with each other using certain values in the rows and also considering the specified ascending clauses of the value metadata.
        Specified by:
        compare in interface RowMetaInterface
        Parameters:
        rowData1 - The first row of data
        rowMeta2 - the metadata of the second row of data
        rowData2 - The second row of data
        fieldnrs1 - The indexes of the values to compare in the first row
        fieldnrs2 - The indexes of the values to compare with in the second row
        Returns:
        0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
        Throws:
        KettleValueException
      • compare

        public int compare​(Object[] rowData1,
                           Object[] rowData2)
                    throws KettleValueException
        Compare 2 rows with each other using all values in the rows and also considering the specified ascending clauses of the value metadata.
        Specified by:
        compare in interface RowMetaInterface
        Parameters:
        rowData1 - The first row of data
        rowData2 - The second row of data
        Returns:
        0 if the rows are considered equal, -1 is data1 is smaller, 1 if data2 is smaller.
        Throws:
        KettleValueException
      • oldXORHashCode

        @Deprecated
        public int oldXORHashCode​(Object[] rowData)
                           throws KettleValueException
        Deprecated.
        Calculate a hashCode of the content (not the index) of the data specified NOTE: This method uses a simple XOR of the individual hashCodes which can result in a lot of collisions for similar types of data (e.g. [A,B] == [B,A] and is not suitable for normal use. It is kept to provide backward compatibility with CombinationLookup.lookupValues()
        Specified by:
        oldXORHashCode in interface RowMetaInterface
        Parameters:
        rowData - The data to calculate a hashCode with
        Returns:
        the calculated hashCode
        Throws:
        KettleValueException - in case there is a data conversion error
      • hashCode

        public int hashCode​(Object[] rowData)
                     throws KettleValueException
        Calculates a simple hashCode of all the native data objects in the supplied row. This method will return a better distribution of values for rows of numbers or rows with the same values in different positions. NOTE: This method performs against the native values, not the values returned by ValueMeta. This means that if you have two rows with different primitive values ['2008-01-01:12:30'] and ['2008-01-01:00:00'] that use a format object to change the value (as Date yyyy-MM-dd), the hashCodes will be different resulting in the two rows not being considered equal via the hashCode even though compare() or equals() might consider them to be.
        Specified by:
        hashCode in interface RowMetaInterface
        Parameters:
        rowData - The data to calculate a hashCode with
        Returns:
        the calculated hashCode
        Throws:
        KettleValueException - in case there is a data conversion error
      • convertedValuesHashCode

        public int convertedValuesHashCode​(Object[] rowData)
                                    throws KettleValueException
        Calculates a hashcode of the converted value of all objects in the supplied row. This method returns distinct values for nulls of different data types and will return the same hashCode for different native values that have a ValueMeta converting them into the same value (e.g. ['2008-01-01:12:30'] and ['2008-01-01:00:00'] as Date yyyy-MM-dd)
        Specified by:
        convertedValuesHashCode in interface RowMetaInterface
        Parameters:
        rowData - The data to calculate a hashCode with
        Returns:
        the calculated hashCode
        Throws:
        KettleValueException - in case there is a data conversion error
      • extractData

        public static byte[] extractData​(RowMetaInterface metadata,
                                         Object[] row)
        Serialize a row of data to byte[]
        Parameters:
        metadata - the metadata to use
        row - the row of data
        Returns:
        a serialized form of the data as a byte array
      • getRow

        public static Object[] getRow​(RowMetaInterface metadata,
                                      byte[] data)
        Create a row of data bases on a serialized format (byte[])
        Parameters:
        data - the serialized data
        metadata - the metadata to use
        Returns:
        a new row of data
      • getDataXML

        public String getDataXML​(Object[] rowData)
                          throws IOException
        Description copied from interface: RowMetaInterface
        Gets the data xml.
        Specified by:
        getDataXML in interface RowMetaInterface
        Parameters:
        rowData - the row of data to serialize as XML
        Returns:
        an XML representation of the row data
        Throws:
        IOException - Thrown in case there is an (Base64/GZip) encoding problem
      • getRow

        public Object[] getRow​(Node node)
                        throws KettleException
        Convert an XML node into binary data using the row metadata supplied.
        Specified by:
        getRow in interface RowMetaInterface
        Parameters:
        node - The data row node
        Returns:
        a row of data, converted from XML
        Throws:
        IOException - Thrown in case there is an (Base64/GZip) decoding problem
        KettleException - Thrown in case there is an (Base64/GZip) decoding problem