public abstract class MetaObjectParametric extends MetaObject implements ModifiableParametric
MetaObject
that allows to store (in addition
to encapsulated LocalAbstractObject
s) additional named parameters too.
A parameter can be any Serializable
object. If the stored objects
implement also BinarySerializable
, it is used
for serialization.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 |
---|---|
|
MetaObjectParametric(AbstractObjectKey objectKey,
java.util.Map<java.lang.String,? extends java.io.Serializable> additionalParameters)
Creates a new instance of MetaObjectParametric.
|
protected |
MetaObjectParametric(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of MetaObjectParametric loaded from binary input.
|
|
MetaObjectParametric(java.util.Map<java.lang.String,? extends java.io.Serializable> additionalParameters)
Creates a new instance of MetaObjectParametric.
|
|
MetaObjectParametric(java.lang.String locatorURI,
java.util.Map<java.lang.String,? extends java.io.Serializable> additionalParameters)
Creates a new instance of MetaObjectParametric.
|
Modifier and Type | Method and Description |
---|---|
protected int |
binarySerialize(BinaryOutput output,
BinarySerializator serializator)
Binary-serialize this object into the
output . |
void |
clearSurplusData()
Clear non-messif data stored in this object and all its subobjects.
|
boolean |
containsParameter(java.lang.String name)
Returns whether a parameter with the given
name exists in this parametric object. |
protected int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
java.io.Serializable |
getParameter(java.lang.String name)
Returns an additional parameter with the given
name . |
<T> T |
getParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass)
Returns an additional parameter with the given
name . |
<T> T |
getParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass,
T defaultValue)
Returns an additional parameter with the given
name . |
int |
getParameterCount()
Returns the number of additional parameters.
|
java.util.Map<java.lang.String,? extends java.io.Serializable> |
getParameterMap()
Returns the map of all additional parameters.
|
java.util.Collection<java.lang.String> |
getParameterNames()
Returns a set of additional parameter names present in this object.
|
java.io.Serializable |
getRequiredParameter(java.lang.String name)
Returns an additional parameter with the given
name . |
<T> T |
getRequiredParameter(java.lang.String name,
java.lang.Class<? extends T> parameterClass)
Returns an additional parameter with the given
name . |
protected boolean |
parseObjectComment(java.lang.String line)
Processes a comment line of text representation of the object.
|
java.io.Serializable |
removeParameter(java.lang.String name)
Removes an additional parameter with the given
name . |
java.io.Serializable |
setParameter(java.lang.String name,
java.lang.Object value)
Set an additional parameter with the given
name to the given value . |
protected void |
writeData(java.io.OutputStream stream)
Store this object's data to a text stream.
|
protected abstract void |
writeDataImpl(java.io.OutputStream stream)
Store this object's data to a text stream.
|
containsObject, createMetaDistancesHolder, createSearchMetaObject, dataEquals, dataHashCode, fillMetaDistances, fillMetaDistances, getDistanceImpl, getDistanceImpl, getObject, getObjectCount, getObjectFromMap, getObjectMap, getObjectNames, getObjects, getSize, implementationGetDistance, readObject, readObject, readObjects, readObjects, readObjectsHeader, toString, writeObjects, writeObjectsHeader
clone, clone, cloneRandomlyModify, create, create, excludeUsingPrecompDist, getDistance, getDistance, getDistance, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceLowerBound, getDistanceLowerBoundImpl, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceUpperBound, getDistanceUpperBoundImpl, getFieldsForNames, getMaxDistance, getNormDistance, getPrecomputedDistance, getPrecomputedDistance, getRandomChar, getRandomNormal, chainDestroy, chainFilter, includeUsingPrecompDist, isDistanceCompatible, peekNextChar, readAttributesFromStream, readObjectComments, readObjectCommentsWithoutData, unchainFilter, write, write, writeAttributesToStream, writeObjectComment
clone, getLocatorURI, getNoDataObject, getObjectKey, getObjectKey, getObjectLocatorURI, setObjectKey
public MetaObjectParametric(java.util.Map<java.lang.String,? extends java.io.Serializable> additionalParameters)
additionalParameters
- additional parameters for this meta objectpublic MetaObjectParametric(AbstractObjectKey objectKey, java.util.Map<java.lang.String,? extends java.io.Serializable> additionalParameters)
objectKey
- the key to be associated with this objectadditionalParameters
- additional parameters for this meta objectpublic MetaObjectParametric(java.lang.String locatorURI, java.util.Map<java.lang.String,? extends java.io.Serializable> additionalParameters)
AbstractObjectKey
is generated for
the specified locatorURI
.locatorURI
- the locator URI for the new objectadditionalParameters
- additional parameters for this meta objectprotected MetaObjectParametric(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the input to read the MetaObjectParametric fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the bufferpublic int getParameterCount()
Parametric
getParameterCount
in interface Parametric
public java.util.Collection<java.lang.String> getParameterNames()
Parametric
getParameterNames
in interface Parametric
public boolean containsParameter(java.lang.String name)
Parametric
name
exists in this parametric object.containsParameter
in interface Parametric
name
- the name of the additional parameter to getname
or false if it does notpublic java.io.Serializable getParameter(java.lang.String name)
Parametric
name
.getParameter
in interface Parametric
name
- the name of the additional parameter to getname
or null if it is not setpublic java.io.Serializable getRequiredParameter(java.lang.String name) throws java.lang.IllegalArgumentException
Parametric
name
.
If the parameter with the given name
is not set, an exception is thrown.getRequiredParameter
in interface Parametric
name
- the name of the additional parameter to getname
java.lang.IllegalArgumentException
- if the parameter with the given name
is not setpublic <T> T getRequiredParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass) throws java.lang.IllegalArgumentException, java.lang.ClassCastException
Parametric
name
.
If the parameter with the given name
is not set or is not an
instance of parameterClass
, an exception is thrown.getRequiredParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getjava.lang.IllegalArgumentException
- if the parameter with the given name
is not setjava.lang.ClassCastException
- if the parameter with the given name
is not an instance of parameterClass
public <T> T getParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass, T defaultValue)
Parametric
name
.
If the parameter is not set or is not an instance of parameterClass
,
the defaultValue
is returned instead.getParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getdefaultValue
- the default value to use if the parameter is nullpublic <T> T getParameter(java.lang.String name, java.lang.Class<? extends T> parameterClass)
Parametric
name
.
If the parameter name
exists but it is not an instance of
parameterClass
, null is returned.getParameter
in interface Parametric
T
- the class of the parametername
- the name of the additional parameter to getparameterClass
- the class of the parameter to getname
or null if it is not setpublic java.util.Map<java.lang.String,? extends java.io.Serializable> getParameterMap()
Parametric
getParameterMap
in interface Parametric
public java.io.Serializable setParameter(java.lang.String name, java.lang.Object value) throws java.lang.ClassCastException
ModifiableParametric
name
to the given value
.
Note that the previous value is replaced with the new one.setParameter
in interface ModifiableParametric
name
- the name of the additional parameter to setvalue
- the new value for the parametername
or null if it was not setjava.lang.ClassCastException
- if the given value is not Serializable
public java.io.Serializable removeParameter(java.lang.String name)
ModifiableParametric
name
.removeParameter
in interface ModifiableParametric
name
- the name of the additional parameter to removename
that was removed or null if it was not setpublic void clearSurplusData()
parameters
that are clearable
are cleared
and the other non-primitive
parameters are removed from the parameters.clearSurplusData
in interface Clearable
clearSurplusData
in class MetaObject
protected boolean parseObjectComment(java.lang.String line) throws java.lang.IllegalArgumentException
LocalAbstractObject
sets the object key
adds a precomputed distances filter
parseObjectComment
in class LocalAbstractObject
line
- a line with commentjava.lang.IllegalArgumentException
- if there was a problem converting the line's comment, e.g. due to invalid formatprotected final 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 streamprotected abstract void writeDataImpl(java.io.OutputStream stream) throws java.io.IOException
stream
- the stream to store this object tojava.io.IOException
- if there was an error while writing to streamprotected int binarySerialize(BinaryOutput output, BinarySerializator serializator) throws java.io.IOException
output
.binarySerialize
in class LocalAbstractObject
output
- the output that this object is binary-serialized intoserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error during serializationprotected int getBinarySize(BinarySerializator serializator)
getBinarySize
in class LocalAbstractObject
serializator
- the serializator used to write objects