public abstract class LocalAbstractObjectAutoImpl extends LocalAbstractObject
getDataFields()
method.
If the newly created object cannot be descendant of this class, the static methods for
reading/writing can be used.LocalAbstractObject.DataEqualObject, LocalAbstractObject.TextStreamFactory<T extends LocalAbstractObject>, LocalAbstractObject.TrivialDistanceFunction
counterDistanceComputations, counterLowerBoundDistanceComputations, counterPrecomputedDistanceSavings, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, trivialDistanceFunction, UNKNOWN_DISTANCE
Modifier | Constructor and Description |
---|---|
protected |
LocalAbstractObjectAutoImpl()
Creates a new instance of LocalAbstractObjectAutoImpl.
|
protected |
LocalAbstractObjectAutoImpl(java.io.BufferedReader stream)
Creates a new instance of object from a text stream.
|
Modifier and Type | Method and Description |
---|---|
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 java.lang.String |
getArrayItemsRegexp()
Returns the regular expression used to separate items of an array attribute.
|
protected char |
getArrayItemsSeparator()
Returns the character that separates items of an array attribute.
|
protected java.lang.String |
getAttributesRegexp()
Returns the regular expression used to separate attributes in a text stream.
|
protected char |
getAttributesSeparator()
Returns the character that separates attributes in a text stream.
|
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,
java.lang.String attributesRegexp,
java.lang.String arrayItemsRegexp,
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.
|
binarySerialize, clearSurplusData, clone, clone, create, create, createMetaDistancesHolder, excludeUsingPrecompDist, getBinarySize, getDistance, getDistance, getDistance, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceImpl, getDistanceLowerBound, getDistanceLowerBoundImpl, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceUpperBound, getDistanceUpperBoundImpl, getMaxDistance, getNormDistance, getPrecomputedDistance, getPrecomputedDistance, getRandomChar, getRandomNormal, chainDestroy, chainFilter, includeUsingPrecompDist, isDistanceCompatible, parseObjectComment, peekNextChar, readObjectComments, readObjectCommentsWithoutData, unchainFilter, write, write, writeObjectComment
clone, getLocatorURI, getNoDataObject, getObjectKey, getObjectKey, getObjectLocatorURI, setObjectKey, toString
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 fromjava.io.EOFException
- is thrown when the end-of-file is reachedjava.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 objectprotected char getAttributesSeparator()
protected java.lang.String getAttributesRegexp()
getAttributesSeparator()
plus any number of spaces.protected char getArrayItemsSeparator()
protected java.lang.String getArrayItemsRegexp()
getArrayItemsSeparator()
plus any number of spaces.protected void writeData(java.io.OutputStream stream) throws java.io.IOException
LocalAbstractObject
writeData
in class LocalAbstractObject
stream
- the stream to store this object tojava.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 minimal and the maximal possible values and optional third integer parameter with index of the field to modifyjava.lang.CloneNotSupportedException
- if the object's class does not support cloning 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 streamjava.io.IOException
- if there was an error writing to the streamjava.lang.IllegalArgumentException
- if one of the specified fields is invalidpublic static void readAttributesFromStream(java.lang.String line, java.lang.String attributesRegexp, java.lang.String arrayItemsRegexp, 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 dataattributesRegexp
- the regular expression that is used to separate attributesarrayItemsRegexp
- the regular expression that is used to separate items of arraysdataObject
- the object whose data are readdataFields
- the list of dataObject
attribute fields to read from the streamjava.io.IOException
- if there was an error reading from the streamjava.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 namesjava.lang.IllegalArgumentException
- if there is no attribute field with the specified name