|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.common.object.PropertiedObjectImpl
public class PropertiedObjectImpl
This class provides an implementation of a PropertiedObject, including basic
management of properties and property definitions. However, the compareTo
and equals
assumes that the values either implement the Comparable
interface or they are comparable after toString()
is called
on each value.
Constructor Summary | |
---|---|
|
PropertiedObjectImpl(java.util.List propertyDefns)
Create an instance of the PropertiedObject, specifying the list of PropertyDefinition instances to be used. |
protected |
PropertiedObjectImpl(PropertiedObjectImpl original)
|
Method Summary | |
---|---|
java.lang.Object |
clone()
|
protected int |
compare(PropertiedObjectImpl that)
|
int |
compareTo(java.lang.Object obj)
Compares this object to another. |
protected int |
computeHashCode()
Return a new hash code value for this instance. |
boolean |
containsAllRequiredValues()
|
boolean |
equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. |
protected java.util.Properties |
getPropertiesObject()
|
java.util.List |
getPropertyDefinitions()
Obtain the list of PropertyDefinitions that apply to the specified object's type. |
java.lang.Object |
getValue(PropertyDefinition def)
Obtain from the specified PropertiedObject the property value that corresponds to the specified PropertyDefinition. |
boolean |
isValidValue(PropertyDefinition def,
java.lang.Object value)
Return whether the specified value is considered valid. |
void |
load(java.io.InputStream in)
Reads the properties and values from the input stream according to the Properties.load() method. |
protected void |
setPropertyDefinitions(java.util.List propertyDefns)
Set the list of PropertyDefinition instances that this object is to use. |
void |
setValue(PropertyDefinition def,
java.lang.Object value)
Set on the specified PropertiedObject the value defined by the specified PropertyDefinition. |
void |
store(java.io.OutputStream out,
java.lang.String header)
Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method. |
protected void |
updateHashCode()
Update the currently cached hash code value with a newly computed one. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PropertiedObjectImpl(java.util.List propertyDefns)
propertyDefns
- the list of PropertyDefinition instances; the list
is assumed to be immutable, and may never be nullprotected PropertiedObjectImpl(PropertiedObjectImpl original)
Method Detail |
---|
protected final void updateHashCode()
The implementation of this method invokes the computeHashCode
method, which is likely overridden in subclasses.
protected int computeHashCode()
protected int computeHashCode() { int result = super.computeHashCode(); result = HashCodeUtil.hashCode(result, ... ); result = HashCodeUtil.hashCode(result, ... ); return result; }Any specialized implementation must not rely upon the
hashCode
method.
Note that this method does not and cannot actually update the hash code value.
Rather, this method is called by the updateHashCode
method.
public int compareTo(java.lang.Object obj)
Compares this object to another. If the specified object is an instance of the IODescriptor class, then this method compares the instances; otherwise, it throws a ClassCastException (as instances are comparable only to instances of the same class).
Note: this method is consistent with
equals()
, meaning that
(compare(x, y)==0) == (x.equals(y))
.
compareTo
in interface java.lang.Comparable
obj
- the object that this instance is to be compared to.
java.lang.IllegalArgumentException
- if the specified object reference is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this instance.protected int compare(PropertiedObjectImpl that)
public boolean equals(java.lang.Object obj)
compareTo()
.
equals
in class java.lang.Object
obj
- the object that this instance is to be compared to.
public java.lang.Object clone()
clone
in class java.lang.Object
public java.util.List getPropertyDefinitions()
java.lang.AssertionError
- if obj
is nullprotected void setPropertyDefinitions(java.util.List propertyDefns)
propertyDefns
- the list of PropertyDefinition instances; the list
is assumed to be immutable, and may never be nullpublic java.lang.Object getValue(PropertyDefinition def)
def
- the reference to the PropertyDefinition describing the
property whose value is to be returned; may not be null
java.lang.AssertionError
- if def
is nullpublic boolean isValidValue(PropertyDefinition def, java.lang.Object value)
def
- the reference to the PropertyDefinition describing the
property whose value is to be validated; may not be nullvalue
- the proposed value for the property, which may be a collection if
the property is multi-valued, or may be null if the multiplicity
includes "0"
java.lang.AssertionError
- if either of def
is null,
or if the property is multi-valued and the value
is not an instance
of Object[].public void setValue(PropertyDefinition def, java.lang.Object value)
def
- the reference to the PropertyDefinition describing the
property whose value is to be changed; may not be nullvalue
- the new value for the property; the cardinality and type
must conform PropertyDefinition
java.lang.IllegalArgumentException
- if the value does not correspond
to the PropertyDefinition requirements.
java.lang.AssertionError
- if either of def
is null
or if the property is multi-valued and the value
is not an instance
of Object[].public void load(java.io.InputStream in) throws java.io.IOException
in
- the input stream, which is not closed by this method; may not be null
java.lang.AssertionError
- if the InputStream reference is null
java.io.IOException
- if an error occurred when reading from the input streampublic void store(java.io.OutputStream out, java.lang.String header) throws java.io.IOException
Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method.
If the header argument is not null, then an ASCII # character, the header string, and a line separator are first written to the output stream. Thus, the header can serve as an identifying comment.
out
- an output stream; may not be nullheader
- a description of the property list, which is not closed
by this method; may be null or zero-length
java.lang.AssertionError
- if the InputStream reference is null
java.io.IOException
- if an error occurred when reading from the input streamprotected java.util.Properties getPropertiesObject()
public boolean containsAllRequiredValues()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |