com.amx.duet.tools.io
Class Marshall

java.lang.Object
  extended bycom.amx.duet.tools.lang.ObjectRef
      extended bycom.amx.duet.tools.io.Marshall
All Implemented Interfaces:
IBinaryMarshall

public class Marshall
extends ObjectRef
implements IBinaryMarshall

Includes handling for NetLinx binary marshalling.

Version:
1.0.0

Field Summary
 
Fields inherited from interface com.amx.duet.tools.io.IBinaryMarshall
SIZE_CHAR, SIZE_DWORD, SIZE_QWORD, SIZE_WORD, STV_DECODE_DATA_INCOMPLETE, STV_DECODE_DATA_TOO_SMALL, STV_DECODE_EOS, STV_DECODE_OBJECT_TOO_SMALL, STV_DECODE_OK, STV_DECODE_VARIABLE_MISMATCH, STV_ENCODE_BUFFER_TOO_SMALL, STV_ENCODE_OK, STV_ENCODE_VARIABLE_UNKNOWN, TYPE_ARRAY, TYPE_CHAR, TYPE_CHAR_ARRAY, TYPE_DWORD, TYPE_DWORD_ARRAY, TYPE_LONG_CHAR_ARRAY, TYPE_QWORD, TYPE_QWORD_ARRAY, TYPE_SKIP, TYPE_STRUCT_END, TYPE_STRUCT_START, TYPE_WORD, TYPE_WORD_ARRAY
 
Constructor Summary
Marshall(boolean b)
          Creates an object representation of the boolean argument.
Marshall(byte b)
          Creates an object representation of the byte argument.
Marshall(char c)
          Creates an object representation of the char argument.
Marshall(double d)
          Creates an object representation of the double argument.
Marshall(float f)
          Creates an object representation of the float argument.
Marshall(int i)
          Creates an object representation of the int argument.
Marshall(long l)
          Creates an object representation of the long argument.
Marshall(java.lang.Object o)
          Stores a copy of the Object argument.
Marshall(java.lang.Object o, ObjectType refType)
          Stores a copy of the Object argument as the ObjectType passed in.
Marshall(short s)
          Creates an object representation of the short argument.
Marshall(java.lang.String str)
          Creates an object representation of the String argument.
 
Method Summary
 int binaryDecode(ObjectRef buffer, boolean skipHeader)
           
 int binaryDecode(ObjectRef buffer, ObjectRef rPos)
          This function should decode a string buffer
 int binaryDecodeString(ObjectRef buffer)
           
 int binaryEncode(ObjectRef buffer, boolean skipHeader)
           
 int binaryEncode(ObjectRef buffer, ObjectRef rPos)
          This function should encode a string buffer.
 int binaryEncodeString(ObjectRef buffer, boolean wideChar)
           
static boolean skipBinaryHeader(byte type)
          This method will check the marshall type passed to see if the instrinsic value's header byte should be skipped.
 
Methods inherited from class com.amx.duet.tools.lang.ObjectRef
booleanValue, byteValue, charValue, doubleValue, equals, floatValue, getType, getValue, intValue, longValue, shortValue, stringValue, toBoolean, toByte, toChar, toDouble, toFloat, toInt, toLong, toShort, toString, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Marshall

public Marshall(boolean b)
Creates an object representation of the boolean argument.

Parameters:
b - a boolean.

Marshall

public Marshall(byte b)
Creates an object representation of the byte argument.

Parameters:
b - a byte.

Marshall

public Marshall(char c)
Creates an object representation of the char argument.

Parameters:
c - a char.

Marshall

public Marshall(short s)
Creates an object representation of the short argument.

Parameters:
s - a short.

Marshall

public Marshall(int i)
Creates an object representation of the int argument.

Parameters:
i - a int.

Marshall

public Marshall(long l)
Creates an object representation of the long argument.

Parameters:
l - a long.

Marshall

public Marshall(float f)
Creates an object representation of the float argument.

Parameters:
f - a float.

Marshall

public Marshall(double d)
Creates an object representation of the double argument.

Parameters:
d - a double.

Marshall

public Marshall(java.lang.String str)
Creates an object representation of the String argument.

Parameters:
str - a String.

Marshall

public Marshall(java.lang.Object o)
Stores a copy of the Object argument.

Parameters:
o - an Object.

Marshall

public Marshall(java.lang.Object o,
                ObjectType refType)
Stores a copy of the Object argument as the ObjectType passed in.

Parameters:
o - an Object.
refType - the ObjectType that the object is assigned as.
Method Detail

skipBinaryHeader

public static final boolean skipBinaryHeader(byte type)
This method will check the marshall type passed to see if the instrinsic value's header byte should be skipped.

Parameters:
type -
Returns:

binaryEncode

public int binaryEncode(ObjectRef buffer,
                        ObjectRef rPos)
This function should encode a string buffer.

NOTE: to encode an array create an ObjectRef array, and then do the binaryEncode method on the individual elements

Specified by:
binaryEncode in interface IBinaryMarshall
Parameters:
rPos - Must be of type long. This is where the first byte of the encoding is placed. It is also modified to point to the next location after the last encoded byte. That means that successive calls to this function can be made without modifying position. Position should be set to 0 on the first call.

Create rPos with a valueOf(long) Example:
ObjectRef rPos = new ObjectRef((long)0) or rPos.valueOf((long)0)

Returns:
  • 0 Encoded OK
  • -1 Encoded variable unrecognized type
  • -2 Encoded data would not fit into buffer, buffer too small

binaryEncode

public int binaryEncode(ObjectRef buffer,
                        boolean skipHeader)
Parameters:
buffer -
skipHeader -
Returns:

binaryDecode

public int binaryDecode(ObjectRef buffer,
                        ObjectRef rPos)
This function should decode a string buffer

Specified by:
binaryDecode in interface IBinaryMarshall
Parameters:
rPos - Must be of type long. This is where the first byte of the decode data. Is it also modified to point to the next location after the last decoded byte. That means that successive calls to this function can be made without modifying position. Position should be set to 0 on the first call.

Create rPos with a valueOf(long) Example:
ObjectRef rPos = new ObjectRef((long)0) or rPos.valueOf((long)0)

Returns:
  • 2 - Decode data to small, more members in structure
  • 1 - Structure to small, more members in decode string
  • 0 - Decoded OK
  • -1 - Decode variable type mismatch
  • -2 - Decode data too small, decoder ran out of data

binaryDecode

public int binaryDecode(ObjectRef buffer,
                        boolean skipHeader)
Parameters:
buffer -
skipHeader -
Returns:

binaryEncodeString

public int binaryEncodeString(ObjectRef buffer,
                              boolean wideChar)
Parameters:
buffer -
wideChar -
Returns:

binaryDecodeString

public int binaryDecodeString(ObjectRef buffer)
Parameters:
buffer -
Returns:


Copyright © 2008 AMX LLC. All Rights Reserved.