|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Defines interface methods governing object serialization.
WHAT'S AN INTERFACE?
An interface defines a set of methods. Usually the set of methods is related to some operation, such as drag and drop--the class must implement several methods to fully implement the behavior, and the method definitions need to be consistent across every class that implements the behavior.
So what's the advantage to Interfaces over inheritence? After all, we might create an abstract class, and have all the classes that inherit from that class implement the set of methods defined in the interface. The advantage is that interfaces don't have to be applied to classes in the same class hierarchy. In our case, the serialization interface is defined, and both the PduElement class tree and the Unsigned number class tree implement the interface. These classes are related only in that they have a common ancestor, which we can't modify, and probably wouldn't want to anyway, since we would then have to implement the methods for every intermediate class. Java doesn't do multiple inheritence (thank the elder gods), so we can't do mix-ins.
By declaring that a class implements an interface, we can make compile-time checks to confirm that the class does indeed have the correct method prototypes. Interfaces are also useful for determining at runtime whether a class can perform the operations required to implement a behavior.
Method Summary | |
void |
deSerialize(java.io.DataInputStream outputStream)
Reads an object in from DIS format. |
void |
serialize(java.io.DataOutputStream outputStream)
Writes an object out in DIS format. |
Method Detail |
public void serialize(java.io.DataOutputStream outputStream)
public void deSerialize(java.io.DataInputStream outputStream)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |