Package com.yahoo.document.datatypes
Class StringFieldValue
java.lang.Object
com.yahoo.vespa.objects.Selectable
com.yahoo.vespa.objects.Identifiable
com.yahoo.document.datatypes.FieldValue
com.yahoo.document.datatypes.StringFieldValue
- All Implemented Interfaces:
Cloneable,Comparable<FieldValue>
- Direct Known Subclasses:
UriFieldValue
A StringFieldValue is a wrapper class that holds a String in
Documents and
other FieldValues.
String fields can only contain text characters, as defined by Text.isTextCharacter(int)- Author:
- Einar M R Rosenvinge
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new StringFieldValue holding an empty String.StringFieldValue(String value) Creates a new StringFieldValue with the given value. -
Method Summary
Modifier and TypeMethodDescriptionvoidSets a new value for this StringFieldValue.voidclear()Sets the wrapped String to be an empty String, and clears all span trees.clone()Clones this StringFieldValue and its span trees.intcompareTo(FieldValue fieldValue) voiddeserialize(Field field, FieldReader reader) Read a field value from the specified readerbooleanReturnsDataType.STRING.static PrimitiveDataType.FactorygetSpanTree(String name) Returns the span tree associated with the given name, or null if this does not exist.Returns the map of spantrees.Returns an unmodifiable Collection of the span trees with annotations over this String, if any.Returns the String value wrapped by this StringFieldValueReturns the String value wrapped by this StringFieldValueinthashCode()voidDeprecated.removeSpanTree(String name) Removes the span tree associated with the given name.voidserialize(Field field, FieldWriter writer) Write out field value to the specified writersetSpanTree(SpanTree spanTree) Sets the span tree with annotations over this String.voidOnly for use by deserializer to avoid the cost of verifying input.toString()Returns the String value wrapped by this StringFieldValue.Methods inherited from class com.yahoo.document.datatypes.FieldValue
create, deserialize, getRecursiveValue, getRecursiveValue, onDeserialize, onSerialize, serialize, toXmlMethods inherited from class com.yahoo.vespa.objects.Identifiable
create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getRawUtf8Bytes, getUtf8, onGetClassId, putUtf8, registerClass, registerClass, serialize, serializeOptional, serializeWithId, visitMembersMethods inherited from class com.yahoo.vespa.objects.Selectable
select, select, selectMembers
-
Field Details
-
classId
public static final int classId
-
-
Constructor Details
-
StringFieldValue
public StringFieldValue()Creates a new StringFieldValue holding an empty String. -
StringFieldValue
Creates a new StringFieldValue with the given value.- Parameters:
value- the value to wrap.- Throws:
IllegalArgumentException- if the string contains non-text characters as defined byText.isTextCharacter(int)
-
-
Method Details
-
getFactory
-
getDataType
ReturnsDataType.STRING.- Specified by:
getDataTypein classFieldValue- Returns:
- DataType.STRING, always
-
clone
Clones this StringFieldValue and its span trees.- Overrides:
clonein classFieldValue- Returns:
- a new deep-copied StringFieldValue
-
clear
public void clear()Sets the wrapped String to be an empty String, and clears all span trees.- Specified by:
clearin classFieldValue
-
assign
Sets a new value for this StringFieldValue. NOTE that doing so will clear all span trees from this value, since they most certainly will not make sense for a new string value.- Specified by:
assignin classFieldValue- Parameters:
o- the new String to assign to this. An argument of null is equal to calling clear().- Throws:
IllegalArgumentException- if the given argument is a string containing non-text characters as defined byText.isTextCharacter(int)
-
getSpanTrees
Returns an unmodifiable Collection of the span trees with annotations over this String, if any.- Returns:
- an unmodifiable Collection of the span trees with annotations over this String, or an empty Collection
-
getSpanTreeMap
Returns the map of spantrees. Might be null. -
getSpanTree
Returns the span tree associated with the given name, or null if this does not exist.- Parameters:
name- the name of the span tree to return- Returns:
- the span tree associated with the given name, or null if this does not exist.
-
setSpanTree
Sets the span tree with annotations over this String.- Parameters:
spanTree- the span tree with annotations over this String- Returns:
- the input spanTree for chaining
- Throws:
IllegalArgumentException- if a span tree with the given name already exists.
-
removeSpanTree
Removes the span tree associated with the given name.- Parameters:
name- the name of the span tree to remove- Returns:
- the span tree previously associated with the given name, or null if it did not exist
-
getString
Returns the String value wrapped by this StringFieldValue -
getWrappedValue
Returns the String value wrapped by this StringFieldValue- Overrides:
getWrappedValuein classFieldValue
-
printXml
Deprecated.Prints XML in Vespa Document XML format for this StringFieldValue.- Specified by:
printXmlin classFieldValue- Parameters:
xml- the stream to print to
-
toString
Returns the String value wrapped by this StringFieldValue.- Overrides:
toStringin classcom.yahoo.vespa.objects.Identifiable- Returns:
- the String value wrapped by this StringFieldValue.
-
equals
- Overrides:
equalsin classcom.yahoo.vespa.objects.Identifiable
-
hashCode
public int hashCode()- Overrides:
hashCodein classcom.yahoo.vespa.objects.Identifiable
-
serialize
Description copied from class:FieldValueWrite out field value to the specified writer- Specified by:
serializein classFieldValue
-
deserialize
Description copied from class:FieldValueRead a field value from the specified reader- Specified by:
deserializein classFieldValue
-
compareTo
- Specified by:
compareToin interfaceComparable<FieldValue>- Overrides:
compareToin classFieldValue
-
setUnChecked
Only for use by deserializer to avoid the cost of verifying input.
-