com.resilientedge.jockey.appcomm
Class MarshallableInt

java.lang.Object
  |
  +--com.resilientedge.jockey.appcomm.MarshallableInt
All Implemented Interfaces:
Marshallable

public class MarshallableInt
extends java.lang.Object
implements Marshallable

A simple implementation of a fixed length marshallable string. Useful for assembling more complex marshallable objects.

Version:
$Revision: 1.1.1.1 $
Author:
John Gardner

Fields inherited from interface com.resilientedge.jockey.appcomm.Marshallable
FAILED, SUCCESS, TYPE_FIXED_STRING, TYPE_OBJECT, TYPE_UINT_32
 
Constructor Summary
MarshallableInt()
          Constructor.
MarshallableInt(int value)
          Constructor.
 
Method Summary
 int fromBytes(byte[] buffer, int offset)
          Reinitialize this object from the contents of an array of bytes.
 java.lang.String getMarshalName()
          Return an identifier for this object.
 int getMarshalSize()
          Return the number of bytes that this object would require to marshal itself.
 int getValue()
          Return the int represented by this object.
 int toBytes(byte[] buffer, int offset)
          Marshal this object to a language independent array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarshallableInt

public MarshallableInt()
Constructor.

MarshallableInt

public MarshallableInt(int value)
Constructor.
Parameters:
value - value of this string
Method Detail

getValue

public int getValue()
Return the int represented by this object.
Returns:
value

getMarshalName

public java.lang.String getMarshalName()
Return an identifier for this object. This has to be unique among marshallable objects. The name actually doesn't matter for this object, since it is a primitive type understood by the marshaller.
Specified by:
getMarshalName in interface Marshallable
Returns:
name for this object.

toBytes

public int toBytes(byte[] buffer,
                   int offset)
Marshal this object to a language independent array of bytes. Should be called by any subclass before marshalling derived attributes.
Specified by:
toBytes in interface Marshallable
Parameters:
buffer - a destination buffer to receive this object.
offset - begin marshalling at this offset from buffer start
Returns:
the number of bytes of the input buffer consumed.

fromBytes

public int fromBytes(byte[] buffer,
                     int offset)
Reinitialize this object from the contents of an array of bytes. Should be called by any subclass before unmarshalling derived attributes.
Specified by:
fromBytes in interface Marshallable
Parameters:
buffer - a buffer containing the marshalled object.
offset - begin unmarshalling at this offset from buffer start
Returns:
the number of bytes of the input buffer consumed.

getMarshalSize

public int getMarshalSize()
Return the number of bytes that this object would require to marshal itself. Should be called by any subclass and added to defived size.
Specified by:
getMarshalSize in interface Marshallable
Returns:
the number of bytes that the header information would consume.


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.