public class ObjectString extends LocalAbstractObject implements StringDataProvider, BinarySerializable
String
as its data content.
No implementation of distance function is provided - see ObjectStringEditDist
.LocalAbstractObject.DataEqualObject, LocalAbstractObject.TextStreamFactory<T extends LocalAbstractObject>, LocalAbstractObject.TrivialDistanceFunction
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
text
Data string
|
counterDistanceComputations, counterLowerBoundDistanceComputations, counterPrecomputedDistanceSavings, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, trivialDistanceFunction, UNKNOWN_DISTANCE
Modifier | Constructor and Description |
---|---|
|
ObjectString()
Creates a new instance of ObjectString with randomly generated string content.
|
protected |
ObjectString(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of ObjectString loaded from binary input buffer.
|
|
ObjectString(java.io.BufferedReader stream)
Creates a new instance of ObjectString from text stream.
|
|
ObjectString(int minLength,
int maxLength)
Creates a new instance of ObjectString with randomly generated string content.
|
|
ObjectString(java.lang.String text)
Creates a new instance of ObjectString.
|
|
ObjectString(java.lang.String text,
java.lang.String locatorURI)
Creates a new instance of ObjectString.
|
Modifier and Type | Method and Description |
---|---|
int |
binarySerialize(BinaryOutput output,
BinarySerializator serializator)
Binary-serialize this object into the
output . |
LocalAbstractObject |
cloneRandomlyModify(java.lang.Object... args)
Creates and returns a randomly modified copy of this string.
|
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.
|
static java.lang.String |
generateRandom(int minLength,
int maxLength)
Generate a random text.
|
int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
protected float |
getDistanceImpl(LocalAbstractObject obj,
float distThreshold)
The actual implementation of the metric function (see
LocalAbstractObject.getDistance(messif.objects.LocalAbstractObject) for full explanation). |
AbstractObjectKey |
getObjectKey()
Returns the object key.
|
int |
getSize()
Returns the size of this object in bytes.
|
java.lang.String |
getStringData()
Returns the string that represents the contents of this object.
|
int |
getStringLength()
Returns the length of the content string.
|
java.lang.String |
toString()
Converts this object to a string representation.
|
void |
writeData(java.io.OutputStream stream)
Store this object's data to a text stream.
|
clearSurplusData, clone, clone, create, create, createMetaDistancesHolder, 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, parseObjectComment, peekNextChar, readAttributesFromStream, readObjectComments, readObjectCommentsWithoutData, unchainFilter, write, write, writeAttributesToStream, writeObjectComment
clone, getLocatorURI, getNoDataObject, getObjectKey, getObjectLocatorURI, setObjectKey
public ObjectString(java.lang.String text)
text
- the string content of the new objectpublic ObjectString(java.lang.String text, java.lang.String locatorURI)
text
- the string content of the new objectlocatorURI
- the locator URI for the new objectpublic ObjectString()
public ObjectString(int minLength, int maxLength)
minLength
characters
and at most maxLength
characters.minLength
- minimal length of the randomly generated string contentmaxLength
- maximal length of the randomly generated string contentpublic ObjectString(java.io.BufferedReader stream) throws java.io.EOFException, java.io.IOException
stream
- the stream from which to read lines of textjava.io.EOFException
- if the end-of-file of the given stream is reachedjava.io.IOException
- if there was an I/O error during reading from the streamprotected ObjectString(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the buffer to read the ObjectString fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the bufferpublic static java.lang.String generateRandom(int minLength, int maxLength)
minLength
characters
and at most maxLength
characters.minLength
- minimal length of the randomly generated textmaxLength
- maximal length of the randomly generated textpublic 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 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()
LocalAbstractObject
dataHashCode
in class LocalAbstractObject
public java.lang.String getStringData()
getStringData
in interface StringDataProvider
public int getStringLength()
public int getSize()
LocalAbstractObject
getSize
in class LocalAbstractObject
public AbstractObjectKey getObjectKey()
AbstractObject
getObjectKey
in class AbstractObject
protected float getDistanceImpl(LocalAbstractObject obj, float distThreshold)
LocalAbstractObject.getDistance(messif.objects.LocalAbstractObject)
for full explanation).
The implementation should not increment distanceComputations statistics.
Implements a trivial distance, so that the ObjectString can be used directly.getDistanceImpl
in class LocalAbstractObject
obj
- the object to compute distance todistThreshold
- the threshold value on the distancepublic LocalAbstractObject cloneRandomlyModify(java.lang.Object... args) throws java.lang.CloneNotSupportedException
cloneRandomlyModify
in class LocalAbstractObject
args
- expected size of the args
array is 1: ObjectString containing all possible charsjava.lang.CloneNotSupportedException
- if the object's class does not support cloning or there was an errorpublic java.lang.String toString()
toString
in class AbstractObject
public int binarySerialize(BinaryOutput output, BinarySerializator serializator) throws java.io.IOException
LocalAbstractObject
output
.binarySerialize
in interface BinarySerializable
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 serializationpublic int getBinarySize(BinarySerializator serializator)
LocalAbstractObject
getBinarySize
in interface BinarySerializable
getBinarySize
in class LocalAbstractObject
serializator
- the serializator used to write objects