Class LayoutMessage

java.lang.Object
cl.obcom.desktopfx.layout.LayoutMessage
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
NetServerMessage

public class LayoutMessage extends Object implements Serializable, Cloneable
Text message formatted according to a Layout specification.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new LayoutMessage instance.
    Constructs a new LayoutMessage instance with layout.
    Constructs a new LayoutMessage instance with text.
    LayoutMessage(String text, Layout layout)
    Constructs a new LayoutMessage instance with arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a "deep" copy of this LayoutMessage.
    final void
    Copies all the properties of source into this LayoutMessage.
    final boolean
    exists(String fieldName)
    Returns true if the field indexed by fieldName exists in the Layout of this message.
    final Character
    getChar(String fieldName)
    Returns the character value of the field identified by fieldName.
    final Character
    getChar(String fieldName, int index)
    Returns the character value of the field identified by fieldName and index.
    final Date
    getDate(String fieldName)
    Returns the date value of the field identified by fieldName.
    final Date
    getDate(String fieldName, int index)
    Returns the date value of the field identified by fieldName and index.
    static boolean
    Returns true if, by default, numeric fields are stored using the ANSI format.
    final Double
    getDouble(String fieldName)
    Returns the double value of the field identified by fieldName.
    final Double
    getDouble(String fieldName, int index)
    Returns the double value of the field identified by fieldName and index.
    getField(String fieldName)
    Returns the field identified by fieldName.
    final Integer
    getInteger(String fieldName)
    Returns the integer value of the field identified by fieldName.
    final Integer
    getInteger(String fieldName, int index)
    Returns the integer value of the field identified by fieldName and index.
    final Layout
    Returns the current layout of this message.
    final Long
    getLong(String fieldName)
    Returns the long value of the field identified by fieldName.
    final Long
    getLong(String fieldName, int index)
    Returns the long value of the field identified by fieldName and index.
    getNumber(String fieldName)
    Returns the decimal value of the field identified by fieldName.
    getNumber(String fieldName, int index)
    Returns the decimal value of the field identified by fieldName and index.
    final int
    getOccurs(String fieldName)
    Returns the number of occurrences of the field identified by fieldName.
    final String
    getString(String fieldName)
    Returns the string value of the field identified by fieldName.
    final String
    getString(String fieldName, int index)
    Returns the string value of the field identified by fieldName and index.
    final String
    getSubstring(int start, int end)
    Returns a substring that begins at start index and extends to index end-1.
    final String
    getSubstring(int start, int end, boolean rtrim, boolean nodata)
    Returns a substring that begins at start index and extends to index end-1.
    final String
    Returns the text of this message with trailing spaces preserved.
    final String
    getText(boolean rtrim)
    Returns the text of this message.
    final int
    Returns the length of the text of this message.
    final String
    Returns the text of this message with trailing spaces are removed.
    final Object
    getValue(String fieldName)
    Returns the object value of the field identified by fieldName.
    final Object
    getValue(String fieldName, int index)
    Returns the object value of the field identified by fieldName and index.
    final void
    Changes the value of each field of this message to its default value.
    final void
    Changes the value of each field of this message to the value of its corresponding field in source.
    final boolean
    isNull(int start, int end)
    Returns true if a substring is NULL.
    final boolean
    isNull(String fieldName)
    Returns true if the value of the field identified by fieldName is NULL.
    final boolean
    isNull(String fieldName, int index)
    Returns true if the value of the field identified by fieldName and index is NULL.
    final boolean
    Returns true if numeric fields are stored using the ANSI format.
    final void
    setChar(String fieldName, int index, Character value)
    Changes the character value of the field identified by fieldName and index.
    final void
    setChar(String fieldName, Character value)
    Changes the character value of the field identified by fieldName.
    final void
    setDate(String fieldName, int index, Date value)
    Changes the date value of the field identified by fieldName and index.
    final void
    setDate(String fieldName, Date value)
    Changes the date value of the field identified by fieldName.
    static void
    setDefaultSignANSI(boolean signANSI)
    Defines if, by default, numeric fields are stored using the ANSI format.
    final void
    setDouble(String fieldName, int index, Double value)
    Changes the double value of the field identified by fieldName and index.
    final void
    setDouble(String fieldName, Double value)
    Changes the double value of the field identified by fieldName.
    final void
    setInteger(String fieldName, int index, Integer value)
    Changes the integer value of the field identified by fieldName and index.
    final void
    setInteger(String fieldName, Integer value)
    Changes the integer value of the field identified by fieldName.
    final void
    setLayout(Layout layout)
    Changes the layout of this message.
    final void
    setLong(String fieldName, int index, Long value)
    Changes the long value of the field identified by fieldName and index.
    final void
    setLong(String fieldName, Long value)
    Changes the long value of the field identified by fieldName.
    final void
    setNull(String fieldName)
    Changes the value of the field identified by fieldName to NULL.
    final void
    setNull(String fieldName, int index)
    Changes the value of the field identified by fieldName and index to NULL.
    final void
    setNumber(String fieldName, int index, BigDecimal value)
    Changes the decimal value of the field identified by fieldName and index.
    final void
    setNumber(String fieldName, BigDecimal value)
    Changes the decimal value of the field identified by fieldName.
    final void
    setSignANSI(boolean signANSI)
    Defines whether numeric fields are stored in this message using the ANSI format.
    final void
    setString(String fieldName, int index, String value)
    Changes the string value of the field identified by fieldName and index.
    final void
    setString(String fieldName, String value)
    Changes the string value of the field identified by fieldName.
    final void
    setSubstring(int start, int end, String value)
    Replaces a substring with the supplied value.
    final void
    Changes the text of this message.
    final void
    setValue(String fieldName, int index, Object value)
    Changes the object value of the field identified by fieldName and index.
    final void
    setValue(String fieldName, Object value)
    Changes the object value of the field identified by fieldName.
    Returns a string representation of this message.
    final String
    Returns the XML string representation of the data stored in this message.
    final String
    toXml(boolean omitXmlDeclaration, String encoding, boolean indent, int indentAmount)
    Returns the XML string representation of the data stored in this message.
    final Layout
    Verifies that the name of the layout of this message matches the supplied name.

    Methods inherited from class java.lang.Object

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

    • LayoutMessage

      public LayoutMessage()
      Constructs a new LayoutMessage instance.
    • LayoutMessage

      public LayoutMessage(String text)
      Constructs a new LayoutMessage instance with text.
      Parameters:
      text - the initial text of the message.
    • LayoutMessage

      public LayoutMessage(Layout layout)
      Constructs a new LayoutMessage instance with layout.
      Parameters:
      layout - the initial layout of the message.
    • LayoutMessage

      public LayoutMessage(String text, Layout layout)
      Constructs a new LayoutMessage instance with arguments.
      Parameters:
      text - the initial text of the message.
      layout - the initial layout of the message.
  • Method Details

    • isSignANSI

      public final boolean isSignANSI()
      Returns true if numeric fields are stored using the ANSI format. Otherwise, numeric fields are stored using the TANDEM format.
      Returns:
      true if numeric fields are stored using the ANSI format.
    • setSignANSI

      public final void setSignANSI(boolean signANSI)
      Defines whether numeric fields are stored in this message using the ANSI format. If signANSI is true, numeric fields will be stored using the ANSI format. Otherwise, numeric fields will be stored using the TANDEM format.

      Note: this method does not change the representation of the numeric fields that are currently stored in this message. It defines how numeric fields will be stored in future calls to the setNumber or the setString methods.

      Parameters:
      signANSI - if true numeric fields will be stored using the ANSI mechanism. Otherwise, the TANDEM mechanism will be used.
    • getDefaultSignANSI

      public static boolean getDefaultSignANSI()
      Returns true if, by default, numeric fields are stored using the ANSI format. Otherwise, numeric fields are stored using the TANDEM format.

      When a new message is created, it uses this global value to initialize its behavior. This default behavior can be changed on individual messages using the setSignANSI method.

      Returns:
      true if, by default, numeric fields are stored using the ANSI format. Otherwise, the TANDEM format is used.
    • setDefaultSignANSI

      public static void setDefaultSignANSI(boolean signANSI)
      Defines if, by default, numeric fields are stored using the ANSI format. If signANSI is true, numeric fields will be stored using the ANSI format. Otherwise, numeric fields will be stored using the TANDEM mechanism.

      When a new message is created, it uses this global value to initialize its behavior. This default behavior can be changed on individual messages using the setSignANSI method.

      Parameters:
      signANSI - if true numeric fields will be stored, by default, using the ANSI format. Otherwise, the TANDEM format will be used.
    • getTextLen

      public final int getTextLen()
      Returns the length of the text of this message.
      Returns:
      the length of the text of this message.
    • getText

      public final String getText()
      Returns the text of this message with trailing spaces preserved.
      Returns:
      the text of this message with trailing spaces preserved.
    • getTextTrim

      public final String getTextTrim()
      Returns the text of this message with trailing spaces are removed.
      Returns:
      the text of this message with trailing spaces are removed.
    • getText

      public final String getText(boolean rtrim)
      Returns the text of this message. If rtrim is true, trailing spaces are removed.
      Parameters:
      rtrim - if true trailing spaces are removed.
      Returns:
      the text of this message.
      See Also:
    • setText

      public final void setText(String text)
      Changes the text of this message.
      Parameters:
      text - the new text of this message (can be null).
    • getSubstring

      public final String getSubstring(int start, int end)
      Returns a substring that begins at start index and extends to index end-1. Trailing spaces are removed. It returns null if the first character of the substring is NO-DATA (0x1A).
      Parameters:
      start - the start index of the substring.
      end - the end index of the substring.
      Returns:
      the requiered substring or null.
    • getSubstring

      public final String getSubstring(int start, int end, boolean rtrim, boolean nodata)
      Returns a substring that begins at start index and extends to index end-1. If argument rtrim is true, trailing spaces are removed. It returns null if nodata is true and the first character of the substring is NO-DATA (0x1A). If nodata is false, the returned substring includes NO-DATA (0x1A) characters.
      Parameters:
      start - the start index of the substring.
      end - the end index of the substring.
      rtrim - if true remove trailing spaces.
      nodata - if true check for NO-DATA.
      Returns:
      the requiered substring or null.
    • setSubstring

      public final void setSubstring(int start, int end, String value)
      Replaces a substring with the supplied value. The substring begins at start index and extends to index end-1. If value is null, the substring is filled with NO-DATA (0x1A) characters. If value is shorter than the substring, the remaining space is filled with spaces. If value is too long, it is truncated.
      Parameters:
      start - the start index of the substring.
      end - the end index of the substring.
      value - the replacement value (can be null).
    • getLayout

      public final Layout getLayout()
      Returns the current layout of this message. It returns null if the message has no defined layout.
      Returns:
      the layout of this message or null.
    • setLayout

      public final void setLayout(Layout layout)
      Changes the layout of this message. If layout is null, the message will have no defined layout.
      Parameters:
      layout - new layout of this message (can be null).
    • verifyLayout

      public final Layout verifyLayout(String name)
      Verifies that the name of the layout of this message matches the supplied name. This method throws IllegalArgumentException if this message has no defined layout, or if the layout names do not match.

      This convenience method is normally used in the implementation of methods that process transaction requests whose data must be sent from a client application with a particular structure (or layout).

      Parameters:
      name - the name of the required layout.
      Returns:
      the verified layout of this message (never null).
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if the layout names do not match.
    • initFields

      public final void initFields()
      Changes the value of each field of this message to its default value. The default value of a layout field is obtained using the getDefault method. If this message has no defined layout, nothing happens.
    • initFields

      public final void initFields(LayoutMessage source)
      Changes the value of each field of this message to the value of its corresponding field in source. Two fields are said to correspond if they have the same name and type. If a field has no corresponding field in source, then its value is set to its default value. If source is null or if source has no defined layout, then this methods operates as the initFields() method. If this message has no defined layout, nothing happens.
      Parameters:
      source - the message with corresponding fields (can be null).
    • getField

      public final LayoutField getField(String fieldName)
      Returns the field identified by fieldName. It returns null if this message does not have a defined layout, or if the field is not defined in the layout.
      Parameters:
      fieldName - name of the layout field.
      Returns:
      the field identified by fieldName or null.
      Throws:
      NullPointerException - if fieldName is null.
    • exists

      public final boolean exists(String fieldName)
      Returns true if the field indexed by fieldName exists in the Layout of this message. If returns false if this message does not have a defined layout, or if the field is not defined in the layout.
      Parameters:
      fieldName - the name of the layout field.
      Returns:
      true if the field is defined.
      Throws:
      NullPointerException - if fieldName is null.
    • getOccurs

      public final int getOccurs(String fieldName)
      Returns the number of occurrences of the field identified by fieldName.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the number of occurrences of the specified field.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
    • isNull

      public final boolean isNull(int start, int end)
      Returns true if a substring is NULL. A substring is NULL if it's first character is NO-DATA (0x1A). The substring begins at start index and extends to index end-1.
      Parameters:
      start - the start index of the substring.
      end - the end index of the substring.
      Returns:
      true if the substring is NULL.
    • isNull

      public final boolean isNull(String fieldName)
      Returns true if the value of the field identified by fieldName is NULL. The value of the field is NULL if the first character of it's substring is NO-DATA (0x1A).
      Parameters:
      fieldName - name of the required field.
      Returns:
      true if the specified field is NULL.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
    • isNull

      public final boolean isNull(String fieldName, int index)
      Returns true if the value of the field identified by fieldName and index is NULL. The value is NULL if the first character of it's substring is NO-DATA (0x1A).
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      true if the specified field is NULL.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
    • setNull

      public final void setNull(String fieldName)
      Changes the value of the field identified by fieldName to NULL. The value is set to NULL by replacing all characters of the field's substring with NO-DATA (0x1A).
      Parameters:
      fieldName - name of the required field.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
    • setNull

      public final void setNull(String fieldName, int index)
      Changes the value of the field identified by fieldName and index to NULL. The value is set to NULL by replacing all characters of the field's substring with NO-DATA (0x1A).
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
    • getString

      public final String getString(String fieldName)
      Returns the string value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the string value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
    • getString

      public final String getString(String fieldName, int index)
      Returns the string value of the field identified by fieldName and index. It returns null if the value of the field is NULL.

      If the field is a FieldType.LIST and index is -1, it returns a string containing all the occurrences of the list.

      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the string value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
    • setString

      public final void setString(String fieldName, String value)
      Changes the string value of the field identified by fieldName. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new string value of the field (can be null)..
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if value has an invalid format.
    • setString

      public final void setString(String fieldName, int index, String value)
      Changes the string value of the field identified by fieldName and index. If value is null then the value of the field is set to NULL.

      If the field is a FieldType.LIST and index is -1, the string containing all the occurrences of this list field is updated with the supplied value.

      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new string value of the field (can be null)..
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if value has an invalid format.
    • getChar

      public final Character getChar(String fieldName)
      Returns the character value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the character value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
    • getChar

      public final Character getChar(String fieldName, int index)
      Returns the character value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the character value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
    • setChar

      public final void setChar(String fieldName, Character value)
      Changes the character value of the field identified by fieldName. If value is null the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new character value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if value has an invalid format.
    • setChar

      public final void setChar(String fieldName, int index, Character value)
      Changes the character value of the field identified by fieldName and index. If value is null the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new character value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if value has an invalid format.
    • getNumber

      public final BigDecimal getNumber(String fieldName)
      Returns the decimal value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the decimal value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getNumber

      public final BigDecimal getNumber(String fieldName, int index)
      Returns the decimal value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the decimal value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setNumber

      public final void setNumber(String fieldName, BigDecimal value)
      Changes the decimal value of the field identified by fieldName. If value is null the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new decimal value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setNumber

      public final void setNumber(String fieldName, int index, BigDecimal value)
      Changes the decimal value of the field identified by fieldName and index. If value is null then the field's data is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new decimal value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getDouble

      public final Double getDouble(String fieldName)
      Returns the double value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the double value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getDouble

      public final Double getDouble(String fieldName, int index)
      Returns the double value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the double value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setDouble

      public final void setDouble(String fieldName, Double value)
      Changes the double value of the field identified by fieldName. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new double value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setDouble

      public final void setDouble(String fieldName, int index, Double value)
      Changes the double value of the field identified by fieldName and index. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new double value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getInteger

      public final Integer getInteger(String fieldName)
      Returns the integer value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the integer value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getInteger

      public final Integer getInteger(String fieldName, int index)
      Returns the integer value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the integer value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setInteger

      public final void setInteger(String fieldName, Integer value)
      Changes the integer value of the field identified by fieldName. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new integer value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setInteger

      public final void setInteger(String fieldName, int index, Integer value)
      Changes the integer value of the field identified by fieldName and index. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new integer value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getLong

      public final Long getLong(String fieldName)
      Returns the long value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the long value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getLong

      public final Long getLong(String fieldName, int index)
      Returns the long value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the long value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setLong

      public final void setLong(String fieldName, Long value)
      Changes the long value of the field identified by fieldName. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new long value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • setLong

      public final void setLong(String fieldName, int index, Long value)
      Changes the long value of the field identified by fieldName and index. If value is null, the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new long value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      UnsupportedOperationException - if the type of the field is not NUMERIC or SIGNED.
    • getDate

      public final Date getDate(String fieldName)
      Returns the date value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the date value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not DATE.
    • getDate

      public final Date getDate(String fieldName, int index)
      Returns the date value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the date value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
      UnsupportedOperationException - if the type of the field is not DATE.
    • setDate

      public final void setDate(String fieldName, Date value)
      Changes the date value of the field identified by fieldName. If value is null the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new date value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      UnsupportedOperationException - if the type of the field is not DATE.
    • setDate

      public final void setDate(String fieldName, int index, Date value)
      Changes the date value of the field identified by fieldName and index. If value is null then the field's data is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new date value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      UnsupportedOperationException - if the type of the field is not DATE.
    • getValue

      public final Object getValue(String fieldName)
      Returns the object value of the field identified by fieldName. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      Returns:
      the object value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if the field record data is invalid.
    • getValue

      public final Object getValue(String fieldName, int index)
      Returns the object value of the field identified by fieldName and index. It returns null if the value of the field is NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      Returns:
      the object value of the specified field or null.
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if the field record data is invalid.
    • setValue

      public final void setValue(String fieldName, Object value)
      Changes the object value of the field identified by fieldName. If value is null the value of the field is set to NULL.
      Parameters:
      fieldName - name of the required field.
      value - the new object value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      ValueFormatException - if supplied value is invalid.
    • setValue

      public final void setValue(String fieldName, int index, Object value)
      Changes the object value of the field identified by fieldName and index. If value is null then the field's data is set to NULL.
      Parameters:
      fieldName - name of the required field.
      index - index of the required field occurrence.
      value - the new object value of the field (can be null).
      Throws:
      NullPointerException - if fieldName is null.
      IllegalStateException - if no layout is defined.
      IllegalArgumentException - if the field does not exist.
      IndexOutOfBoundsException - if index is out-of-bounds.
      ValueFormatException - if supplied value is invalid.
    • toXml

      public final String toXml(boolean omitXmlDeclaration, String encoding, boolean indent, int indentAmount)
      Returns the XML string representation of the data stored in this message. If omitXmlDeclaration is true, the XML declaration header is not included. The encoding argument specifies the character encoding included in the XML declaration header (for example "UTF-8" or "ISO-8859-1"). If indent is true, the resulting XML will have whitespace included to indent the tree. The indentation amount is specified with indentAmount.

      Consider, for example, a layout named CONTACT with four fields called SERVICE, GROUP, USERNAME and USERCODE. The string returned by this method for a message with layout CONTACT would be smae as the following indented XML tree, except for the values of the fields which are shown in italics:

       <CONTACT>
           <SERVICE>service</SERVICE>
           <GROUP>group</GROUP>
           <USERNAME>user</USERNAME>
           <USERCODE>12345</USERCODE>
       </CONTACT>
      Parameters:
      omitXmlDeclaration - specifies whether to omit the XML declaration.
      encoding - the character encoding included in the XML declaration.
      indent - specifies whether to indent the XML representation.
      indentAmount - specifies the indentation amount.
      Returns:
      the XML representation of the data stored in this message.
      Throws:
      NullPointerException - if encoding is null.
      IllegalArgumentException - if indentAmount is negative.
    • toXml

      public final String toXml()
      Returns the XML string representation of the data stored in this message.

      This method has the same effect as calling toXml(true, "UTF-8", false, 0).

      Returns:
      the XML representation of the data stored in this message.
    • toString

      public String toString()
      Returns a string representation of this message.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this message.
    • copyFrom

      public final void copyFrom(LayoutMessage source)
      Copies all the properties of source into this LayoutMessage. The values of all properties in this LayoutMessage are replaced by copies of the values of corresponding source properties.
      Parameters:
      source - the source LayoutMessage to be copied.
      Throws:
      NullPointerException - if source is null.
    • clone

      public LayoutMessage clone()
      Returns a "deep" copy of this LayoutMessage.
      Overrides:
      clone in class Object
      Returns:
      a "deep" copy of this LayoutMessage.