|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.cementj.base.ValueObject
public abstract class ValueObject
Generic functionality for objects used to transfer data between objects. All VOs or value objects extending this class will have pre-built implementations of equals(), and hashcode(). In addition, these extended classes will have meaningful implementations of Describable and DescribableAsXML.
This class is named after the "Data Transfer Object" pattern. Some references use the term "Value Object" instead. They mean the same thing.
To keep VOs usable as distributed objects, it's recommended that they don't contain fields which aren't Serializable.
The implementations of equals() and hashcode() make extensions of this object automatically usable in HashMaps and Hashtables.
An example extension follows:
public class CustomerVO extends ValueObject
{
public CustomerVO() {}
public String getCustomerId() {return _customerId;}
public void setCustomerId(String id)
{
if (id == null) throw new IllegalArgumentException
("Null customer Id not allowed.");
if (id.equals("")) throw new IllegalArgumentException
("Blank customer Id not allowed.");
_customerId = id;
}
// All other accessors and mutators omitted.
private String _customerId = null;
private String _firstName = null;
private String _lastName = null;
private String _address = null;
private String _city = null;
private String _state = null;
private String _zipCode = null;
}
Copyright: Delta Vortex Technologies, 2003.
| Constructor Summary | |
|---|---|
protected |
ValueObject()
|
| Method Summary | |
|---|---|
java.lang.String |
describe()
Provides a textual version of description and state. |
java.lang.String |
describeAsXMLDocument()
Provides XML Document Text for a given instance. |
java.lang.String |
describeAsXMLElement()
Provides XML Element Text for a given instance. |
java.lang.String |
describeAsXMLElement(java.lang.String fieldName)
Provides XML Element Text for a given instance. |
java.lang.String |
encodeAsXML()
|
boolean |
equals(java.lang.Object obj)
|
java.lang.String |
getReasonForNotEquals(java.lang.Object obj)
Provides a textual reason that two ValueObjects are not equal. |
int |
hashCode()
|
protected void |
init()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected ValueObject()
| Method Detail |
|---|
protected void init()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String getReasonForNotEquals(java.lang.Object obj)
obj -
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String describe()
Describable
describe in interface Describablepublic java.lang.String encodeAsXML()
public java.lang.String describeAsXMLDocument()
DescribableAsXML
describeAsXMLDocument in interface DescribableAsXMLpublic java.lang.String describeAsXMLElement()
DescribableAsXML
describeAsXMLElement in interface DescribableAsXMLpublic java.lang.String describeAsXMLElement(java.lang.String fieldName)
DescribableAsXML
describeAsXMLElement in interface DescribableAsXML
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||