Class DefaultFieldAdapter

java.lang.Object
gov.nasa.pds.objectAccess.table.DefaultFieldAdapter
All Implemented Interfaces:
FieldAdapter
Direct Known Subclasses:
NumericTextFieldAdapter

public class DefaultFieldAdapter
extends Object
implements FieldAdapter
Implements an adapter object for table fields that can read the field value from a byte array or write the field value into a byte array. Also has methods for formatting the value into an output writer for either delimited or fixed-width output. Methods not appropriate for the field type will throw UnsupportedOperationException.
  • Constructor Summary

    Constructors
    Constructor Description
    DefaultFieldAdapter()  
  • Method Summary

    Modifier and Type Method Description
    BigInteger getBigInteger​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java BigInteger.
    byte getByte​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java byte.
    double getDouble​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java double.
    float getFloat​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java float.
    int getInt​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java int.
    long getLong​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java long.
    short getShort​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java short.
    String getString​(byte[] buf, int offset, int length, int startBit, int stopBit)
    Gets the field value as a Java string, using the US-ASCII character set to convert from bytes to characters.
    String getString​(byte[] buf, int offset, int length, int startBit, int stopBit, Charset charset)
    Gets the field value as a Java string, using a specified character set to convert from bytes to characters.
    void setBigInteger​(BigInteger value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java BigInteger.
    void setByte​(byte value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java byte.
    void setDouble​(double value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java double.
    void setFloat​(float value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java float.
    void setInt​(int value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java int.
    void setLong​(long value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java long.
    void setShort​(short value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java short.
    void setString​(String value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
    Sets the field value as a Java string.
    void setString​(String value, int offset, int length, ByteBuffer buffer, boolean isRightJustified, Charset charset)
    Sets the field value as a Java string, using a specified character set to convert from characters to bytes.
    void setString​(String value, ByteBuffer buffer, Charset charset)  

    Methods inherited from class java.lang.Object

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

    • DefaultFieldAdapter

      public DefaultFieldAdapter()
  • Method Details

    • getByte

      public byte getByte​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java byte.
      Specified by:
      getByte in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a short
    • getShort

      public short getShort​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java short.
      Specified by:
      getShort in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a short
    • getInt

      public int getInt​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java int.
      Specified by:
      getInt in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as an int
    • getLong

      public long getLong​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java long.
      Specified by:
      getLong in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a long
    • getFloat

      public float getFloat​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java float.
      Specified by:
      getFloat in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a float
    • getDouble

      public double getDouble​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java double.
      Specified by:
      getDouble in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a double
    • getString

      public String getString​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java string, using the US-ASCII character set to convert from bytes to characters.
      Specified by:
      getString in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a string
    • getString

      public String getString​(byte[] buf, int offset, int length, int startBit, int stopBit, Charset charset)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java string, using a specified character set to convert from bytes to characters.
      Specified by:
      getString in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      charset - the character set to use when converting bytes to characters
      Returns:
      the field value, as a string
    • setByte

      public void setByte​(byte value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java byte.
      Specified by:
      setByte in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setShort

      public void setShort​(short value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java short.
      Specified by:
      setShort in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setInt

      public void setInt​(int value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java int.
      Specified by:
      setInt in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setLong

      public void setLong​(long value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java long.
      Specified by:
      setLong in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setFloat

      public void setFloat​(float value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java float.
      Specified by:
      setFloat in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setDouble

      public void setDouble​(double value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java double.
      Specified by:
      setDouble in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setString

      public void setString​(String value, int offset, int length, ByteBuffer buffer, boolean isRightJustified, Charset charset)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java string, using a specified character set to convert from characters to bytes.
      Specified by:
      setString in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
      charset - the character set to use when converting the string to bytes
    • setString

      public void setString​(String value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java string.
      Specified by:
      setString in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified
    • setString

      public void setString​(String value, ByteBuffer buffer, Charset charset)
    • getBigInteger

      public BigInteger getBigInteger​(byte[] buf, int offset, int length, int startBit, int stopBit)
      Description copied from interface: FieldAdapter
      Gets the field value as a Java BigInteger.
      Specified by:
      getBigInteger in interface FieldAdapter
      Parameters:
      buf - the byte array containing the field
      offset - the field offset
      length - the length of the field data
      startBit - the start bit, for bit fields
      stopBit - the stop bit, for bit fields
      Returns:
      the field value, as a BigInteger
    • setBigInteger

      public void setBigInteger​(BigInteger value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
      Description copied from interface: FieldAdapter
      Sets the field value as a Java BigInteger.
      Specified by:
      setBigInteger in interface FieldAdapter
      Parameters:
      value - the field value
      offset - the field offset
      length - the length of the value
      buffer - the byte buffer into which to set the value
      isRightJustified - true, if the string value should be right-justified