Package gov.nasa.pds.objectAccess
Class FixedTableRecord
- java.lang.Object
-
- gov.nasa.pds.objectAccess.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 ofFixedTableRecord
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 theTableRecord
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.
-
-
-
Constructor Detail
-
FixedTableRecord
public FixedTableRecord(byte[] value, java.util.Map<java.lang.String,java.lang.Integer> map, FieldDescription[] fields)
Creates an instance ofFixedTableRecord
for reading field values of a fixed-width table record.- Parameters:
value
- the record valuemap
- a hash mapping field name to field indexfields
- an array of field descriptions (field meta data)
-
-
Method Detail
-
length
public int length()
- Specified by:
length
in interfaceTableRecord
-
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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namecharset
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- 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 interfaceTableRecord
- 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 interfaceTableRecord
- Parameters:
name
- the field namevalue
- a byte value
-
clear
public void clear()
Description copied from interface:TableRecord
Clears the content of theTableRecord
object.- Specified by:
clear
in interfaceTableRecord
-
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
-
getLocation
public RecordLocation getLocation()
- Specified by:
getLocation
in interfaceTableRecord
- Returns:
- Gets the record location.
-
setLocation
public void setLocation(RecordLocation location)
Description copied from interface:TableRecord
Sets the record location.- Specified by:
setLocation
in interfaceTableRecord
- Parameters:
location
- the record location.
-
-