|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.amx.duet.tools.io.MarshallUtil
Utility class used to marshall data similar to NetLinx marshalling.
Constructor Summary | |
MarshallUtil()
|
Method Summary | |
static int |
LengthVariableToString(Marshall encode)
This routine calculates how many bytes it takes to encode a variable. |
static int |
LengthVariableToString(Marshall[] encodeArray)
This routine calculates how many bytes it takes to encode an array variable. |
static int |
StringToVariable(Marshall[] decodeArray,
ObjectRef rBuffer,
ObjectRef rPos)
This routine takes the Encode array data from rBuffer and loads the values into the decode array variable. |
static int |
StringToVariable(Marshall decode,
ObjectRef rBuffer,
ObjectRef rPos)
This routine takes the Encode data from rBuffer and loads the values into the decode variable. |
static int |
VariableToString(Marshall[] encodeArray,
ObjectRef rBuffer,
ObjectRef rPos)
This routine takes the variable encodeArray and creates entries in the buffer to represent that array. |
static int |
VariableToString(Marshall encode,
ObjectRef rBuffer,
ObjectRef rPos)
This routine takes the variable encode and creates entries in the buffer to represent that variable. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MarshallUtil()
Method Detail |
public static final int VariableToString(Marshall encode, ObjectRef rBuffer, ObjectRef rPos)
Note: NetLinx intrinsic types are smaller than java types
Example: INTEGER = short and LONG = int
encode
- This is the variable to be encoded.
Example:
ObjectRef encoder = new ObjectRef(0); ObjectRef buffer = new ObjectRef(""); ObjectRef rPos = new rPos((long)0); String sDate = ""; int ret = 0; // do some date processing... encoder.valueOf(sDate); if ((ret = NetLinx.VariableToString(encoder, buffer, rPos)) < 0) return ret;
rBuffer
- Must be of type String. This is where the encode data is placed.
Create rbuffer with a valueOf(String) Example:
ObjectRef rBuffer = new ObjectRef("") or rBuffer.valueOf("")
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)
public static final int VariableToString(Marshall[] encodeArray, ObjectRef rBuffer, ObjectRef rPos)
Note: NetLinx intrinsic types are smaller than java types
Example: INTEGER = short and LONG = int
encodeArray
- This is the variable to be encoded.
Example (class Appointment implements IStruct):
ObjectRef buffer = new ObjectRef(""); ObjectRef rPos = new rPos((long)0); Appointment sAppts[] = new Appointment[10]; int ret = 0; // do some appointment processing... ObjectRef[] encodeArray = new ObjectRef[sAppts.length]; for (int i = 0; i < sAppts.length; i++) encodeArray[i] = new ObjectRef(sAppts[i]); if ((ret = NetLinx.VariableToString(encodeArray, buffer, rPos)) < 0) return ret;
rBuffer
- Must be of type String. This is where the encode data is placed.
Create rbuffer with a valueOf(String) Example:
ObjectRef rBuffer = new ObjectRef("") or rBuffer.valueOf("")
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)
public static final int StringToVariable(Marshall decode, ObjectRef rBuffer, ObjectRef rPos)
Note: NetLinx intrinsic types are smaller than java types
Example: INTEGER = short and LONG = int
decode
- This is the variable to be decoded into.
Example:
ObjectRef decoder = new ObjectRef(0); ObjectRef buffer = new ObjectRef(""); ObjectRef rPos = new rPos((long)0); String sDate = ""; int ret = 0; // do some date processing... decoder.valueOf(sDate); if ((ret = NetLinx.StringToVariable(decoder, buffer, rPos)) < 0) return ret; sDate = decoder.toString();
rBuffer
- Must be of type String. This is where the decode data is found.
Create rbuffer with a valueOf(String) Example:
ObjectRef rBuffer = new ObjectRef("") or rBuffer.valueOf("")
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)
public static final int StringToVariable(Marshall[] decodeArray, ObjectRef rBuffer, ObjectRef rPos)
Note: NetLinx intrinsic types are smaller than java types
Example: INTEGER = short and LONG = int
decodeArray
- This is the variable to be decoded into.
Example (class Appointment implements IStruct):
ObjectRef buffer = new ObjectRef(""); ObjectRef rPos = new rPos((long)0); Appointment sAppts[] = new Appointment[10]; int ret = 0; // do some appointment processing... ObjectRef[] decodeArray = new ObjectRef[sAppts.length]; for (int i = 0; i < sAppts.length; i++) decodeArray[i] = new ObjectRef(sAppts[i]); if ((ret = NetLinx.StringToVariable(decodeArray, buffer, rTempPos)) < 0) return ret;
Note: Class objects such as the Appointment class are passed by reference to the ObjectRef class. Therefore, the values will change along with the decodeArray value and don't need to be passed back to the sAppts array, but intrinsic type arrays do need their values to be passed back. So you will need to something like this:
public int [] nApptList = new int[10]; decodeArray = new ObjectRef[nApptList.length]; for (int i = 0; i < nApptList.length; i++) decodeArray[i] = new ObjectRef((short)nApptList[i]); if ((ret = NetLinx.StringToVariable(decodeArray, buffer, rTempPos)) < 0) return ret; for (int i = 0; i < nApptList.length; i++) nApptList[i] = decodeArray[i].toInt();
rBuffer
- Must be of type String. This is where the decode data is found.
Create rbuffer with a valueOf(String) Example:
ObjectRef rBuffer = new ObjectRef("") or rBuffer.valueOf("")
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)
public static final int LengthVariableToString(Marshall encode)
encode
- any type of variable. This is the variable to be encoded. Example: ObjectRef encode = new ObjectRef(0) or encode.valueOf(0)
public static final int LengthVariableToString(Marshall[] encodeArray)
encodeArray
- any type of array variable. This is the array to be encoded. Example: ObjectRef[] encodeArray = new ObjectRef[nValues.length]; for (int i = 0; i < nValues.length; i++) encodeArray[i] = new ObjectRef(nValues[i]);
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |