ParsingFramework
Class ParserFramework

java.lang.Object
  extended by ParsingFramework.ParserFramework
All Implemented Interfaces:
IParseOperations

public class ParserFramework
extends java.lang.Object
implements IParseOperations

Singleton object which provides operations to parse data in raw formats e.g. in byte arrays or bitsets into typed Java objects.

Version:
Starlink 0.1
Author:
Paul Grace, Lancaster University

Field Summary
static java.util.Map<java.lang.String,OperationHost> functionList
           
static java.util.Map<java.lang.String,OperationHost> operationList
          Local database of objects that host operations for parsing data into types.
 
Constructor Summary
protected ParserFramework()
          Constructor.
 
Method Summary
 java.lang.Object composeTypedValue(java.lang.String dataType, java.lang.Object dataValue, int size)
          Composes the representation of the data type to be used in the message format.
 java.lang.Object decode(java.lang.String function, java.lang.Object dataField)
           
 java.lang.Object getConstantValue(java.lang.String type, java.lang.String constant)
           
 java.lang.Object getFunctionResult(java.lang.String function)
           
 java.lang.Object getFunctionResult(java.lang.String function, java.lang.Object parameter)
           
static ParserFramework getInstance()
           
 java.lang.Object getTextTypedValue(java.lang.String dataType, java.lang.Object dataValue)
           
 java.lang.Object getTypedValue(java.lang.String dataType, java.lang.Object dataValue)
          Convert the data in the dataValue parameter into a Java object that matches the dataType provided.
 byte[] toByteArray(java.util.BitSet bits)
          local operation that transforms an array of bits into an array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operationList

public static java.util.Map<java.lang.String,OperationHost> operationList
Local database of objects that host operations for parsing data into types. This object contains a subset of the operations.


functionList

public static java.util.Map<java.lang.String,OperationHost> functionList
Constructor Detail

ParserFramework

protected ParserFramework()
Constructor. Initialise the database with the operations implemented in this particular class

Method Detail

getInstance

public static ParserFramework getInstance()

toByteArray

public byte[] toByteArray(java.util.BitSet bits)
local operation that transforms an array of bits into an array of bytes.

Specified by:
toByteArray in interface IParseOperations
Parameters:
bits - BitSet to convert to a binary array
Returns:
The converted Byte array.

getTypedValue

public java.lang.Object getTypedValue(java.lang.String dataType,
                                      java.lang.Object dataValue)
                               throws TypeNotFoundException
Convert the data in the dataValue parameter into a Java object that matches the dataType provided.

Specified by:
getTypedValue in interface IParseOperations
Parameters:
dataType - Required type to be produced
dataValue - The raw data to be parsed
Returns:
A Java of type dataType with the value held in dataValue
Throws:
TypeNotFoundException

getTextTypedValue

public java.lang.Object getTextTypedValue(java.lang.String dataType,
                                          java.lang.Object dataValue)
                                   throws TypeNotFoundException
Specified by:
getTextTypedValue in interface IParseOperations
Throws:
TypeNotFoundException

composeTypedValue

public java.lang.Object composeTypedValue(java.lang.String dataType,
                                          java.lang.Object dataValue,
                                          int size)
                                   throws TypeNotFoundException
Composes the representation of the data type to be used in the message format.

Specified by:
composeTypedValue in interface IParseOperations
Parameters:
dataType - Required type to be composed
dataValue - The current object value to be marshalled
size - The length of the data to be created e.g. (2 byte for int)
Returns:
The marshalled result which will typically be a byte array
Throws:
TypeNotFoundException

getConstantValue

public java.lang.Object getConstantValue(java.lang.String type,
                                         java.lang.String constant)
Specified by:
getConstantValue in interface IParseOperations

getFunctionResult

public java.lang.Object getFunctionResult(java.lang.String function,
                                          java.lang.Object parameter)
Specified by:
getFunctionResult in interface IParseOperations

getFunctionResult

public java.lang.Object getFunctionResult(java.lang.String function)
Specified by:
getFunctionResult in interface IParseOperations

decode

public java.lang.Object decode(java.lang.String function,
                               java.lang.Object dataField)
                        throws TypeNotFoundException
Specified by:
decode in interface IParseOperations
Throws:
TypeNotFoundException