Package gov.nasa.pds.objectAccess
Class FixedTableRecord
java.lang.Object
gov.nasa.pds.objectAccess.FixedTableRecord
- All Implemented Interfaces:
TableRecord
public class FixedTableRecord extends Object implements TableRecord
Implements a fixed-width table record.
-
Constructor Summary
Constructors Constructor Description FixedTableRecord(byte[] value, Map<String,Integer> map, FieldDescription[] fields)Creates an instance ofFixedTableRecordfor reading field values of a fixed-width table record. -
Method Summary
Modifier and Type Method Description voidclear()Clears the content of theTableRecordobject.intfindColumn(String name)Gets the integer index of a field with the given name (1-relative).BigIntegergetBigInteger(int index)Gets the field value as a Java BigInteger.BigIntegergetBigInteger(String name)Gets the field value as a Java BigInteger.booleangetBoolean(int index)Gets the boolean value of a field given the index.booleangetBoolean(String name)Gets the boolean value of a field given the index.bytegetByte(int index)Gets the byte value of a field given the index.bytegetByte(String name)Gets the byte value of a field given the name.doublegetDouble(int index)Gets the double value of a field given the index.doublegetDouble(String name)Gets the double value of a field given the name.floatgetFloat(int index)Gets the float value of a field given the index.floatgetFloat(String name)Gets the float value of a field given the name.intgetInt(int index)Gets the integer value of a field given the index.intgetInt(String name)Gets the integer value of a field given the name.RecordLocationgetLocation()longgetLong(int index)Gets the long value of a field given the index.longgetLong(String name)Gets the long value of a field given the name.byte[]getRecordValue()Returns a byte array that stores the record value.shortgetShort(int index)Gets the short value of a field given the index.shortgetShort(String name)Gets the short value of a field given the name.StringgetString(int index)Gets the string value of a field given the index.StringgetString(int index, Charset charset)Gets the string value of a field given the index.StringgetString(String name)Gets the string value of a field given the name.StringgetString(String name, Charset charset)Gets the string value of a field given the name.voidsetByte(int index, byte value)Sets one byte value to a field given the index.voidsetByte(String name, byte value)Sets one byte value to a field given the name.voidsetDouble(int index, double value)Sets eight bytes containing the double value to a field given the index.voidsetDouble(String name, double value)Sets eight bytes containing the double value to a field given the name.voidsetFloat(int index, float value)Sets four bytes containing the float value to a field given the index.voidsetFloat(String name, float value)Sets four bytes containing the float value to a field given the name.voidsetInt(int index, int value)Sets four bytes containing the integer value to a field given the index.voidsetInt(String name, int value)Sets four bytes containing the integer value to a field given the name.voidsetLocation(RecordLocation location)Sets the record location.voidsetLong(int index, long value)Sets eight bytes containing the long value to the record given the field index.voidsetLong(String name, long value)Sets eight bytes containing the long value to the record given the field name.voidsetRecordValue(byte[] value)Sets the record value.voidsetShort(int index, short value)Sets two bytes containing the short value to a field given the index.voidsetShort(String name, short value)Sets two bytes containing the short value to a field given the index.voidsetString(int index, String value)Sets a string value to a field given the index.voidsetString(String value)Sets a String value to the record at the current offset.voidsetString(String name, String value)Sets a string value to a field given the name.
-
Constructor Details
-
FixedTableRecord
Creates an instance ofFixedTableRecordfor 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 Details
-
findColumn
Description copied from interface:TableRecordGets the integer index of a field with the given name (1-relative).- Specified by:
findColumnin interfaceTableRecord- Parameters:
name- the name of a field- Returns:
- the integer index of a field (1-relative)
-
getBoolean
Description copied from interface:TableRecordGets the boolean value of a field given the index.- Specified by:
getBooleanin interfaceTableRecord- Parameters:
name- the field name- Returns:
- the boolean value
-
getBoolean
public boolean getBoolean(int index)Description copied from interface:TableRecordGets the boolean value of a field given the index.- Specified by:
getBooleanin interfaceTableRecord- Parameters:
index- the field index- Returns:
- the boolean value
-
getShort
public short getShort(int index)Description copied from interface:TableRecordGets the short value of a field given the index.- Specified by:
getShortin interfaceTableRecord- Parameters:
index- the column index (1-relative)- Returns:
- a short value
-
getShort
Description copied from interface:TableRecordGets the short value of a field given the name.- Specified by:
getShortin interfaceTableRecord- Parameters:
name- the field name- Returns:
- a short value
-
getByte
public byte getByte(int index)Description copied from interface:TableRecordGets the byte value of a field given the index.- Specified by:
getBytein interfaceTableRecord- Parameters:
index- the field index (1-relative)- Returns:
- a byte value
-
getByte
Description copied from interface:TableRecordGets the byte value of a field given the name.- Specified by:
getBytein interfaceTableRecord- Parameters:
name- the field name- Returns:
- a byte value
-
getLong
public long getLong(int index)Description copied from interface:TableRecordGets 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:
getLongin interfaceTableRecord- Parameters:
index- the field index (1-relative)- Returns:
- a long value
-
getLong
Description copied from interface:TableRecordGets the long value of a field given the name.- Specified by:
getLongin interfaceTableRecord- Parameters:
name- the field name- Returns:
- a long value
-
getInt
Description copied from interface:TableRecordGets the integer value of a field given the name.- Specified by:
getIntin interfaceTableRecord- Parameters:
name- the field name- Returns:
- an integer value
-
getInt
public int getInt(int index)Description copied from interface:TableRecordGets 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:
getIntin interfaceTableRecord- Parameters:
index- the field index (1-relative)- Returns:
- an integer value
-
getBigInteger
Description copied from interface:TableRecordGets the field value as a Java BigInteger.- Specified by:
getBigIntegerin interfaceTableRecord- Parameters:
name- the name of the field- Returns:
- the field value, as a
BigInteger
-
getBigInteger
Description copied from interface:TableRecordGets the field value as a Java BigInteger.- Specified by:
getBigIntegerin interfaceTableRecord- Parameters:
index- the field index- Returns:
- the field value, as a
BigInteger
-
getDouble
Description copied from interface:TableRecordGets the double value of a field given the name.- Specified by:
getDoublein interfaceTableRecord- Parameters:
name- the field name- Returns:
- a double value
-
getDouble
public double getDouble(int index)Description copied from interface:TableRecordGets 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:
getDoublein interfaceTableRecord- Parameters:
index- the field index (1-relative)- Returns:
- a double value
-
getFloat
Description copied from interface:TableRecordGets the float value of a field given the name.- Specified by:
getFloatin interfaceTableRecord- Parameters:
name- the field name- Returns:
- a float value
-
getFloat
public float getFloat(int index)Description copied from interface:TableRecordGets 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:
getFloatin interfaceTableRecord- Parameters:
index- the field index (1-relative)- Returns:
- a float value
-
getString
Description copied from interface:TableRecordGets the string value of a field given the name.- Specified by:
getStringin interfaceTableRecord- Parameters:
name- the field name- Returns:
- a String value
-
getString
Description copied from interface:TableRecordGets the string value of a field given the name.- Specified by:
getStringin interfaceTableRecord- Parameters:
name- the field namecharset- the charset to use.- Returns:
- a String value
-
getString
Description copied from interface:TableRecordGets the string value of a field given the index.- Specified by:
getStringin interfaceTableRecord- Parameters:
index- the field index (1-relative)- Returns:
- a String value
-
getString
Description copied from interface:TableRecordGets the string value of a field given the index.- Specified by:
getStringin interfaceTableRecord- Parameters:
index- the field index (1-relative)charset- The charset to use.- Returns:
- a String value
-
setString
Description copied from interface:TableRecordSets 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:
setStringin interfaceTableRecord- Parameters:
index- the field index (1-relative)value- a string value
-
setString
Description copied from interface:TableRecordSets 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:
setStringin interfaceTableRecord- Parameters:
name- the field namevalue- a string value
-
setString
Description copied from interface:TableRecordSets 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:
setStringin interfaceTableRecord- Parameters:
value- a String value
-
setInt
public void setInt(int index, int value)Description copied from interface:TableRecordSets four bytes containing the integer value to a field given the index.- Specified by:
setIntin interfaceTableRecord- Parameters:
index- the field index (1-relative)value- an integer value
-
setInt
Description copied from interface:TableRecordSets four bytes containing the integer value to a field given the name.- Specified by:
setIntin interfaceTableRecord- Parameters:
name- the field namevalue- an integer value
-
setDouble
public void setDouble(int index, double value)Description copied from interface:TableRecordSets eight bytes containing the double value to a field given the index.- Specified by:
setDoublein interfaceTableRecord- Parameters:
index- the field index (1-relative)value- a double value
-
setDouble
Description copied from interface:TableRecordSets eight bytes containing the double value to a field given the name.- Specified by:
setDoublein interfaceTableRecord- Parameters:
name- the field namevalue- a double value
-
setFloat
public void setFloat(int index, float value)Description copied from interface:TableRecordSets four bytes containing the float value to a field given the index.- Specified by:
setFloatin interfaceTableRecord- Parameters:
index- the field index (1-relative)value- a float value
-
setFloat
Description copied from interface:TableRecordSets four bytes containing the float value to a field given the name.- Specified by:
setFloatin interfaceTableRecord- Parameters:
name- the field namevalue- a float value
-
setLong
public void setLong(int index, long value)Description copied from interface:TableRecordSets eight bytes containing the long value to the record given the field index.- Specified by:
setLongin interfaceTableRecord- Parameters:
index- the field index (1-relative)value- a long value
-
setLong
Description copied from interface:TableRecordSets eight bytes containing the long value to the record given the field name.- Specified by:
setLongin interfaceTableRecord- Parameters:
name- the field namevalue- a long value
-
setShort
public void setShort(int index, short value)Description copied from interface:TableRecordSets two bytes containing the short value to a field given the index.- Specified by:
setShortin interfaceTableRecord- Parameters:
index- the field index (1-relative)value- a short value
-
setShort
Description copied from interface:TableRecordSets two bytes containing the short value to a field given the index.- Specified by:
setShortin interfaceTableRecord- Parameters:
name- the field namevalue- a short value
-
setByte
public void setByte(int index, byte value)Description copied from interface:TableRecordSets one byte value to a field given the index.- Specified by:
setBytein interfaceTableRecord- Parameters:
index- the field index (1-relative)value- a byte value
-
setByte
Description copied from interface:TableRecordSets one byte value to a field given the name.- Specified by:
setBytein interfaceTableRecord- Parameters:
name- the field namevalue- a byte value
-
clear
public void clear()Description copied from interface:TableRecordClears the content of theTableRecordobject.- Specified by:
clearin 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
- Specified by:
getLocationin interfaceTableRecord- Returns:
- Gets the record location.
-
setLocation
Description copied from interface:TableRecordSets the record location.- Specified by:
setLocationin interfaceTableRecord- Parameters:
location- the record location.
-