|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.objects.UniqueID
messif.objects.AbstractObject
messif.objects.LocalAbstractObject
messif.objects.LocalAbstractObjectAutoImpl
public abstract class LocalAbstractObjectAutoImpl
This class eases the task of implementing data read/write methods.
The data fields of the subclass needs to be marked by overriding the getDataFields()
method.
If the newly created object cannot be descendant of this class, the static methods for
reading/writing can be used.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class messif.objects.LocalAbstractObject |
---|
LocalAbstractObject.DataEqualObject |
Field Summary |
---|
Fields inherited from class messif.objects.LocalAbstractObject |
---|
counterDistanceComputations, counterLowerBoundDistanceComputations, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, UNKNOWN_DISTANCE |
Constructor Summary | |
---|---|
protected |
LocalAbstractObjectAutoImpl()
Creates a new instance of LocalAbstractObjectAutoImpl. |
protected |
LocalAbstractObjectAutoImpl(java.io.BufferedReader stream)
Creates a new instance of object from a text stream. |
Method Summary | |
---|---|
LocalAbstractObject |
cloneRandomlyModify(java.lang.Object... args)
Creates and returns a randomly modified copy of this object. |
boolean |
dataEquals(java.lang.Object obj)
Indicates whether some other object has the same data as this one. |
int |
dataHashCode()
Returns a hash code value for the data of this object. |
protected abstract java.lang.reflect.Field[] |
getDataFields()
Returns the list of fields that should be automatically managed by AutoImpl class as data. |
protected static java.lang.reflect.Field[] |
getFieldsForNames(java.lang.Class<? extends LocalAbstractObject> forClass,
java.lang.String... fieldName)
Returns a list of fields of the specified class that match the provided names. |
int |
getSize()
Returns the size of this object in bytes. |
static void |
readAttributesFromStream(java.lang.String line,
char attributesSeparator,
char arrayItemsSeparator,
LocalAbstractObject dataObject,
java.lang.reflect.Field... dataFields)
Helper method for reading object primitive/array attributes from a text stream. |
static void |
writeAttributesToStream(java.io.OutputStream stream,
char attributesSeparator,
char arrayItemsSeparator,
LocalAbstractObject dataObject,
java.lang.reflect.Field... dataFields)
Helper method for writing object primitive/array attributes to a text stream. |
protected void |
writeData(java.io.OutputStream stream)
Store this object's data to a text stream. |
Methods inherited from class messif.objects.AbstractObject |
---|
clone, getLocatorURI, getNoDataObject, getObjectID, getObjectKey, setObjectKey, toString |
Methods inherited from class messif.objects.UniqueID |
---|
compareTo, equals, hashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected LocalAbstractObjectAutoImpl()
protected LocalAbstractObjectAutoImpl(java.io.BufferedReader stream) throws java.io.EOFException, java.io.IOException, java.lang.IllegalArgumentException
stream
- the text stream to read one object from
java.io.EOFException
- is thrown when the end-of-file is reached
java.io.IOException
- if there is an error during reading from the given stream;
java.lang.IllegalArgumentException
- if the text stream contains invalid values for this objectMethod Detail |
---|
protected void writeData(java.io.OutputStream stream) throws java.io.IOException
LocalAbstractObject
writeData
in class LocalAbstractObject
stream
- the stream to store this object to
java.io.IOException
- if there was an error while writing to streampublic int getSize() throws java.lang.IllegalArgumentException
LocalAbstractObject
getSize
in class LocalAbstractObject
java.lang.IllegalArgumentException
public boolean dataEquals(java.lang.Object obj)
LocalAbstractObject
dataEquals
in class LocalAbstractObject
obj
- the reference object with which to compare.
true
if this object is the same as the obj
argument; false
otherwise.public int dataHashCode() throws java.lang.IllegalArgumentException
LocalAbstractObject
dataHashCode
in class LocalAbstractObject
java.lang.IllegalArgumentException
public LocalAbstractObject cloneRandomlyModify(java.lang.Object... args) throws java.lang.CloneNotSupportedException
cloneRandomlyModify
in class LocalAbstractObject
args
- two objects with the miminal and the maximal possible values and optional third integer parameter with index of the field to modify
java.lang.CloneNotSupportedException
- if the object's class does not support clonning or there was an errorpublic static void writeAttributesToStream(java.io.OutputStream stream, char attributesSeparator, char arrayItemsSeparator, LocalAbstractObject dataObject, java.lang.reflect.Field... dataFields) throws java.io.IOException, java.lang.IllegalArgumentException
toString
method result is written.
If the attribute is an array, a arrayItemsSeparator
-separated list of items is written.
stream
- the stream to output the text toattributesSeparator
- the character written to separate attributesarrayItemsSeparator
- the character written to separate items of an array attributedataObject
- the object whose data are writtendataFields
- the list of dataObject
attribute fields to write to the stream
java.io.IOException
- if there was an error writing to the stream
java.lang.IllegalArgumentException
- if one of the specified fields is invalidpublic static void readAttributesFromStream(java.lang.String line, char attributesSeparator, char arrayItemsSeparator, LocalAbstractObject dataObject, java.lang.reflect.Field... dataFields) throws java.io.IOException, java.lang.IllegalArgumentException
Object valueOf(String value)
method is used to create a respective attribute object.
If the field is an array, a arrayItemsSeparator
-separated list of items is read into respective attribute array.
line
- a line of text representing the dataattributesSeparator
- the character that separates attributesarrayItemsSeparator
- the character that separates items of arraysdataObject
- the object whose data are readdataFields
- the list of dataObject
attribute fields to read from the stream
java.io.IOException
- if there was an error reading from the stream
java.lang.IllegalArgumentException
- if one of the specified fields is invalid or the value specified for a field can't be converted to correct typeprotected abstract java.lang.reflect.Field[] getDataFields()
private final static Field[] fields = getFieldsFor????(.class, ...);
protected Field[] getDataFields() {
return fields;
}
See getFieldsForNames(java.lang.Class extends messif.objects.LocalAbstractObject>, java.lang.String...)
for explanation how to get field lists.
protected static java.lang.reflect.Field[] getFieldsForNames(java.lang.Class<? extends LocalAbstractObject> forClass, java.lang.String... fieldName) throws java.lang.IllegalArgumentException
forClass
- the class to get fields forfieldName
- the list of field names
java.lang.IllegalArgumentException
- if there is no attribute field with the specified name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |