|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavaclient2.xdr.XdrUnion
public abstract class XdrUnion
The abstract base class XdrUnion
helps (de-)serializing
polymorphic classes. This class should not be confused with C unions in
general. Instead XdrUnion
is an object-oriented construct
which helps in deploying polymorphism. For examples on how to use this,
please take a look at the "ACPLTea Java Library" package, which is also
available from www.acplt.org/ks
. As a sidenote, the
serialization scheme implemented by XdrUnion
is only a question
of getting used to it: after serializing the type code of the polymorphic
class, the variant part is serialized first before the common part. This
behaviour stems from the ACPLT C++ Communication Library and has been
retained for compatibility reasons. As it doesn't hurt, you won't mind
anyway.
To use polymorphism with XDR streams, you'll have to derive your own base
class (let's call it foo
from XdrUnion
and implement the two methods
xdrEncodeCommon(XdrEncodingStream)
and
xdrDecodeCommon(XdrDecodingStream)
. Do not overwrite
the methods xdrEncode and xdrDecode!
Then, in your foo
-derived classes, like bar
and baz
, implement the other two methods
xdrEncodeVariant(XdrEncodingStream)
and
xdrDecodeVariant(XdrDecodingStream)
. In addition, implement
getXdrTypeCode()
to return an int, uniquely identifying your
class. Note that this identifier only needs to be unique within the scope
of your foo
class.
Constructor Summary | |
---|---|
XdrUnion()
|
Method Summary | |
---|---|
abstract int |
getXdrTypeCode()
Returns the so-called type code which identifies a derived class when encoded or decoded. |
void |
xdrDecode(XdrDecodingStream xdr)
Decodes -- that is: deserializes -- an object from a XDR stream in compliance to RFC 1832. |
abstract void |
xdrDecodeCommon(XdrDecodingStream xdr)
Decodes -- that is: deserializes -- the common part of an object from a XDR stream in compliance to RFC 1832. |
abstract void |
xdrDecodeVariant(XdrDecodingStream xdr)
Decodes -- that is: deserializes -- the variant part of an object from a XDR stream in compliance to RFC 1832. |
void |
xdrEncode(XdrEncodingStream xdr)
Encodes -- that is: serializes -- an object into a XDR stream in compliance to RFC 1832. |
abstract void |
xdrEncodeCommon(XdrEncodingStream xdr)
Encodes -- that is: serializes -- the common part of an object into a XDR stream in compliance to RFC 1832. |
abstract void |
xdrEncodeVariant(XdrEncodingStream xdr)
Encodes -- that is: serializes -- the variant part of an object into a XDR stream in compliance to RFC 1832. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XdrUnion()
Method Detail |
---|
public abstract int getXdrTypeCode()
foo
is derived from XdrUnion
and foo
is the base class for bar
and
baz
, then the type code needs only be unique between
bar
and baz
.
public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, java.io.IOException
xdrEncode
in interface XdrAble
xdr
- XDR stream to which information is sent for encoding.
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, java.io.IOException
xdrDecode
in interface XdrAble
xdr
- XDR stream from which decoded information is retrieved.
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public abstract void xdrEncodeCommon(XdrEncodingStream xdr) throws OncRpcException, java.io.IOException
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public abstract void xdrDecodeCommon(XdrDecodingStream xdr) throws OncRpcException, java.io.IOException
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public abstract void xdrEncodeVariant(XdrEncodingStream xdr) throws OncRpcException, java.io.IOException
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public abstract void xdrDecodeVariant(XdrDecodingStream xdr) throws OncRpcException, java.io.IOException
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |