Class FixedTableRecord

  • All Implemented Interfaces:
    TableRecord

    public class FixedTableRecord
    extends java.lang.Object
    implements TableRecord
    Implements a fixed-width table record.
    • Constructor Summary

      Constructors 
      Constructor Description
      FixedTableRecord​(byte[] value, java.util.Map<java.lang.String,​java.lang.Integer> map, FieldDescription[] fields)
      Creates an instance of FixedTableRecord for reading field values of a fixed-width table record.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears the content of the TableRecord object.
      int findColumn​(java.lang.String name)
      Gets the integer index of a field with the given name (1-relative).
      java.math.BigInteger getBigInteger​(int index)
      Gets the field value as a Java BigInteger.
      java.math.BigInteger getBigInteger​(java.lang.String name)
      Gets the field value as a Java BigInteger.
      boolean getBoolean​(int index)
      Gets the boolean value of a field given the index.
      boolean getBoolean​(java.lang.String name)
      Gets the boolean value of a field given the index.
      byte getByte​(int index)
      Gets the byte value of a field given the index.
      byte getByte​(java.lang.String name)
      Gets the byte value of a field given the name.
      double getDouble​(int index)
      Gets the double value of a field given the index.
      double getDouble​(java.lang.String name)
      Gets the double value of a field given the name.
      float getFloat​(int index)
      Gets the float value of a field given the index.
      float getFloat​(java.lang.String name)
      Gets the float value of a field given the name.
      int getInt​(int index)
      Gets the integer value of a field given the index.
      int getInt​(java.lang.String name)
      Gets the integer value of a field given the name.
      RecordLocation getLocation()  
      long getLong​(int index)
      Gets the long value of a field given the index.
      long getLong​(java.lang.String name)
      Gets the long value of a field given the name.
      byte[] getRecordValue()
      Returns a byte array that stores the record value.
      short getShort​(int index)
      Gets the short value of a field given the index.
      short getShort​(java.lang.String name)
      Gets the short value of a field given the name.
      java.lang.String getString​(int index)
      Gets the string value of a field given the index.
      java.lang.String getString​(int index, java.nio.charset.Charset charset)
      Gets the string value of a field given the index.
      java.lang.String getString​(java.lang.String name)
      Gets the string value of a field given the name.
      java.lang.String getString​(java.lang.String name, java.nio.charset.Charset charset)
      Gets the string value of a field given the name.
      int length()  
      void setByte​(int index, byte value)
      Sets one byte value to a field given the index.
      void setByte​(java.lang.String name, byte value)
      Sets one byte value to a field given the name.
      void setDouble​(int index, double value)
      Sets eight bytes containing the double value to a field given the index.
      void setDouble​(java.lang.String name, double value)
      Sets eight bytes containing the double value to a field given the name.
      void setFloat​(int index, float value)
      Sets four bytes containing the float value to a field given the index.
      void setFloat​(java.lang.String name, float value)
      Sets four bytes containing the float value to a field given the name.
      void setInt​(int index, int value)
      Sets four bytes containing the integer value to a field given the index.
      void setInt​(java.lang.String name, int value)
      Sets four bytes containing the integer value to a field given the name.
      void setLocation​(RecordLocation location)
      Sets the record location.
      void setLong​(int index, long value)
      Sets eight bytes containing the long value to the record given the field index.
      void setLong​(java.lang.String name, long value)
      Sets eight bytes containing the long value to the record given the field name.
      void setRecordValue​(byte[] value)
      Sets the record value.
      void setShort​(int index, short value)
      Sets two bytes containing the short value to a field given the index.
      void setShort​(java.lang.String name, short value)
      Sets two bytes containing the short value to a field given the index.
      void setString​(int index, java.lang.String value)
      Sets a string value to a field given the index.
      void setString​(java.lang.String value)
      Sets a String value to the record at the current offset.
      void setString​(java.lang.String name, java.lang.String value)
      Sets a string value to a field given the name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FixedTableRecord

        public FixedTableRecord​(byte[] value,
                                java.util.Map<java.lang.String,​java.lang.Integer> map,
                                FieldDescription[] fields)
        Creates an instance of FixedTableRecord for reading field values of a fixed-width table record.
        Parameters:
        value - the record value
        map - a hash mapping field name to field index
        fields - an array of field descriptions (field meta data)
    • Method Detail

      • findColumn

        public int findColumn​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the integer index of a field with the given name (1-relative).
        Specified by:
        findColumn in interface TableRecord
        Parameters:
        name - the name of a field
        Returns:
        the integer index of a field (1-relative)
      • getBoolean

        public boolean getBoolean​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the boolean value of a field given the index.
        Specified by:
        getBoolean in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        the boolean value
      • getBoolean

        public boolean getBoolean​(int index)
        Description copied from interface: TableRecord
        Gets the boolean value of a field given the index.
        Specified by:
        getBoolean in interface TableRecord
        Parameters:
        index - the field index
        Returns:
        the boolean value
      • getShort

        public short getShort​(int index)
        Description copied from interface: TableRecord
        Gets the short value of a field given the index.
        Specified by:
        getShort in interface TableRecord
        Parameters:
        index - the column index (1-relative)
        Returns:
        a short value
      • getShort

        public short getShort​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the short value of a field given the name.
        Specified by:
        getShort in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        a short value
      • getByte

        public byte getByte​(int index)
        Description copied from interface: TableRecord
        Gets the byte value of a field given the index.
        Specified by:
        getByte in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        Returns:
        a byte value
      • getByte

        public byte getByte​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the byte value of a field given the name.
        Specified by:
        getByte in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        a byte value
      • getLong

        public long getLong​(int index)
        Description copied from interface: TableRecord
        Gets the long value of a field given the index.

        It throws NumberFormatException if the number is out of range when converting from ASCII_Integer to long.

        Specified by:
        getLong in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        Returns:
        a long value
      • getLong

        public long getLong​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the long value of a field given the name.
        Specified by:
        getLong in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        a long value
      • getInt

        public int getInt​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the integer value of a field given the name.
        Specified by:
        getInt in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        an integer value
      • getInt

        public int getInt​(int index)
        Description copied from interface: TableRecord
        Gets the integer value of a field given the index.

        It throws NumberFormatException if the number is out of range when converting from ASCII_Integer to int.

        Specified by:
        getInt in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        Returns:
        an integer value
      • getBigInteger

        public java.math.BigInteger getBigInteger​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the field value as a Java BigInteger.
        Specified by:
        getBigInteger in interface TableRecord
        Parameters:
        name - the name of the field
        Returns:
        the field value, as a BigInteger
      • getBigInteger

        public java.math.BigInteger getBigInteger​(int index)
        Description copied from interface: TableRecord
        Gets the field value as a Java BigInteger.
        Specified by:
        getBigInteger in interface TableRecord
        Parameters:
        index - the field index
        Returns:
        the field value, as a BigInteger
      • getDouble

        public double getDouble​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the double value of a field given the name.
        Specified by:
        getDouble in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        a double value
      • getDouble

        public double getDouble​(int index)
        Description copied from interface: TableRecord
        Gets the double value of a field given the index.

        If the number is out of range when converting from ASCII_Real to double, the method returns Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.

        Specified by:
        getDouble in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        Returns:
        a double value
      • getFloat

        public float getFloat​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the float value of a field given the name.
        Specified by:
        getFloat in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        a float value
      • getFloat

        public float getFloat​(int index)
        Description copied from interface: TableRecord
        Gets the float value of a field given the index.

        If the number is out of range when converting from ASCII_Real to float, the method returns Float.POSITIVE_INFINITY or Float.NEGATIVE_INFINITY.

        Specified by:
        getFloat in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        Returns:
        a float value
      • getString

        public java.lang.String getString​(java.lang.String name)
        Description copied from interface: TableRecord
        Gets the string value of a field given the name.
        Specified by:
        getString in interface TableRecord
        Parameters:
        name - the field name
        Returns:
        a String value
      • getString

        public java.lang.String getString​(java.lang.String name,
                                          java.nio.charset.Charset charset)
        Description copied from interface: TableRecord
        Gets the string value of a field given the name.
        Specified by:
        getString in interface TableRecord
        Parameters:
        name - the field name
        charset - the charset to use.
        Returns:
        a String value
      • getString

        public java.lang.String getString​(int index)
        Description copied from interface: TableRecord
        Gets the string value of a field given the index.
        Specified by:
        getString in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        Returns:
        a String value
      • getString

        public java.lang.String getString​(int index,
                                          java.nio.charset.Charset charset)
        Description copied from interface: TableRecord
        Gets the string value of a field given the index.
        Specified by:
        getString in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        charset - The charset to use.
        Returns:
        a String value
      • setString

        public void setString​(int index,
                              java.lang.String value)
        Description copied from interface: TableRecord
        Sets a string value to a field given the index. In a fixed-width text file, numeric values are right justified and non-numeric values are left justified.
        Specified by:
        setString in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - a string value
      • setString

        public void setString​(java.lang.String name,
                              java.lang.String value)
        Description copied from interface: TableRecord
        Sets a string value to a field given the name. In a fixed-width text file, numeric values are right justified and non-numeric values are left justified.
        Specified by:
        setString in interface TableRecord
        Parameters:
        name - the field name
        value - a string value
      • setString

        public void setString​(java.lang.String value)
        Description copied from interface: TableRecord
        Sets a String value to the record at the current offset. Use this method to write a field delimiter in fixed-width text file.
        Specified by:
        setString in interface TableRecord
        Parameters:
        value - a String value
      • setInt

        public void setInt​(int index,
                           int value)
        Description copied from interface: TableRecord
        Sets four bytes containing the integer value to a field given the index.
        Specified by:
        setInt in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - an integer value
      • setInt

        public void setInt​(java.lang.String name,
                           int value)
        Description copied from interface: TableRecord
        Sets four bytes containing the integer value to a field given the name.
        Specified by:
        setInt in interface TableRecord
        Parameters:
        name - the field name
        value - an integer value
      • setDouble

        public void setDouble​(int index,
                              double value)
        Description copied from interface: TableRecord
        Sets eight bytes containing the double value to a field given the index.
        Specified by:
        setDouble in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - a double value
      • setDouble

        public void setDouble​(java.lang.String name,
                              double value)
        Description copied from interface: TableRecord
        Sets eight bytes containing the double value to a field given the name.
        Specified by:
        setDouble in interface TableRecord
        Parameters:
        name - the field name
        value - a double value
      • setFloat

        public void setFloat​(int index,
                             float value)
        Description copied from interface: TableRecord
        Sets four bytes containing the float value to a field given the index.
        Specified by:
        setFloat in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - a float value
      • setFloat

        public void setFloat​(java.lang.String name,
                             float value)
        Description copied from interface: TableRecord
        Sets four bytes containing the float value to a field given the name.
        Specified by:
        setFloat in interface TableRecord
        Parameters:
        name - the field name
        value - a float value
      • setLong

        public void setLong​(int index,
                            long value)
        Description copied from interface: TableRecord
        Sets eight bytes containing the long value to the record given the field index.
        Specified by:
        setLong in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - a long value
      • setLong

        public void setLong​(java.lang.String name,
                            long value)
        Description copied from interface: TableRecord
        Sets eight bytes containing the long value to the record given the field name.
        Specified by:
        setLong in interface TableRecord
        Parameters:
        name - the field name
        value - a long value
      • setShort

        public void setShort​(int index,
                             short value)
        Description copied from interface: TableRecord
        Sets two bytes containing the short value to a field given the index.
        Specified by:
        setShort in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - a short value
      • setShort

        public void setShort​(java.lang.String name,
                             short value)
        Description copied from interface: TableRecord
        Sets two bytes containing the short value to a field given the index.
        Specified by:
        setShort in interface TableRecord
        Parameters:
        name - the field name
        value - a short value
      • setByte

        public void setByte​(int index,
                            byte value)
        Description copied from interface: TableRecord
        Sets one byte value to a field given the index.
        Specified by:
        setByte in interface TableRecord
        Parameters:
        index - the field index (1-relative)
        value - a byte value
      • setByte

        public void setByte​(java.lang.String name,
                            byte value)
        Description copied from interface: TableRecord
        Sets one byte value to a field given the name.
        Specified by:
        setByte in interface TableRecord
        Parameters:
        name - the field name
        value - a byte value
      • clear

        public void clear()
        Description copied from interface: TableRecord
        Clears the content of the TableRecord object.
        Specified by:
        clear in interface TableRecord
      • setRecordValue

        public void setRecordValue​(byte[] value)
        Sets the record value.
        Parameters:
        value - byte array that contains the record value
      • getRecordValue

        public byte[] getRecordValue()
        Returns a byte array that stores the record value.
        Returns:
        a byte array that contains the record value
      • setLocation

        public void setLocation​(RecordLocation location)
        Description copied from interface: TableRecord
        Sets the record location.
        Specified by:
        setLocation in interface TableRecord
        Parameters:
        location - the record location.