org.licas.parsers.types

## Class ArrayParser

- java.lang.Object
- - org.licas.parsers.types.ArrayParser

- All Implemented Interfaces:
    org.ai_heuristic.def.ParserDef

      public class ArrayParser
      extends java.lang.Object
      implements org.ai_heuristic.def.ParserDef

  This class parses a String-based representation of an array to or from XML. Only arrays of simple types can be handled - String/Integer/Float/Double/Byte/Boolean. The values should be represented by a single String-based description with brackets at either end. Note that `Const.ARRAYSEP` or '|' is used to tokenise each individual element and so you should always use this class to serialize or parse your array.

  For example: 1. An array of int's might have a classname of [I and a string value of [1, 2, 3]. 2. An array of String's might have a classname of [Ljava.lang.String; and a string value of [str1, str2, str3].

  Author:
    Kieran Greer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ArrayParser()` Creates a new instance of ArrayParser

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `parse(org.licas_xml.abs.Element toParse)` Parse an XML description of an Array back into a Java object.
    `java.lang.Object` | `parseToArray(java.lang.String arrayType, java.lang.String arrayValues)` Parse an XML description of an Array back into a Java object.
    `org.licas_xml.abs.Element` | `serialize(java.lang.Object toSerialize)` Serialize the array object to XML.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ArrayParser

          public ArrayParser()

      Creates a new instance of ArrayParser

  - ### Method Detail

    - #### serialize

          public org.licas_xml.abs.Element serialize(java.lang.Object toSerialize)
                                              throws java.lang.Exception

      Serialize the array object to XML.
      Specified by:
        `serialize` in interface `org.ai_heuristic.def.ParserDef`
      Parameters:
        `toSerialize` - the Array object to serialize.
      Returns:
        an XML description of the object.
      Throws:
        `java.lang.Exception` - any error.

    - #### parse

          public java.lang.Object parse(org.licas_xml.abs.Element toParse)
                                 throws java.lang.Exception

      Parse an XML description of an Array back into a Java object.
      Specified by:
        `parse` in interface `org.ai_heuristic.def.ParserDef`
      Parameters:
        `toParse` - the XML description to parse.
      Returns:
        the array object that is created.
      Throws:
        `java.lang.Exception` - any error.

    - #### parseToArray

          public java.lang.Object parseToArray(java.lang.String arrayType,
                                               java.lang.String arrayValues)
                                        throws java.lang.Exception

      Parse an XML description of an Array back into a Java object.
      Parameters:
        `arrayType` - type of array to parse.
        `arrayValues` - array description as a string.
      Returns:
        the array object that is created.
      Throws:
        `java.lang.Exception` - any error.