Class StringFieldValue

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<FieldValue>
    Direct Known Subclasses:
    UriFieldValue

    public class StringFieldValue
    extends FieldValue
    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 
      Modifier and Type Field Description
      static int classId  
    • Constructor Summary

      Constructors 
      Constructor Description
      StringFieldValue()
      Creates a new StringFieldValue holding an empty String.
      StringFieldValue​(java.lang.String value)
      Creates a new StringFieldValue with the given value.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assign​(java.lang.Object o)
      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.
      void clear()
      Sets the wrapped String to be an empty String, and clears all span trees.
      StringFieldValue clone()
      Clones this StringFieldValue and its span trees.
      int compareTo​(FieldValue fieldValue)  
      void deserialize​(Field field, FieldReader reader)
      Read a field value from the specified reader
      boolean equals​(java.lang.Object o)  
      DataType getDataType()
      Returns DataType.STRING.
      static PrimitiveDataType.Factory getFactory()  
      SpanTree getSpanTree​(java.lang.String name)
      Returns the span tree associated with the given name, or null if this does not exist.
      java.util.Map<java.lang.String,​SpanTree> getSpanTreeMap()
      Returns the map of spantrees.
      java.util.Collection<SpanTree> getSpanTrees()
      Returns an unmodifiable Collection of the span trees with annotations over this String, if any.
      java.lang.String getString()
      Returns the String value wrapped by this StringFieldValue
      java.lang.Object getWrappedValue()
      Returns the String value wrapped by this StringFieldValue
      int hashCode()  
      void printXml​(XmlStream xml)
      Prints XML in Vespa Document XML format for this StringFieldValue.
      SpanTree removeSpanTree​(java.lang.String name)
      Removes the span tree associated with the given name.
      void serialize​(Field field, FieldWriter writer)
      Write out field value to the specified writer
      SpanTree setSpanTree​(SpanTree spanTree)
      Sets the span tree with annotations over this String.
      void setUnChecked​(java.lang.String s)
      Only for use by deserializer to avoid the cost of verifying input.
      java.lang.String toString()
      Returns the String value wrapped by this StringFieldValue.
      • Methods inherited from class com.yahoo.vespa.objects.Identifiable

        create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getUtf8, onGetClassId, putUtf8, registerClass, serialize, serializeOptional, serializeWithId, visitMembers
      • Methods inherited from class com.yahoo.vespa.objects.Selectable

        select, select, selectMembers
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • classId

        public static final int classId
    • Constructor Detail

      • StringFieldValue

        public StringFieldValue()
        Creates a new StringFieldValue holding an empty String.
      • StringFieldValue

        public StringFieldValue​(java.lang.String value)
        Creates a new StringFieldValue with the given value.
        Parameters:
        value - the value to wrap.
        Throws:
        java.lang.IllegalArgumentException - if the string contains non-text characters as defined by Text.isTextCharacter(int)
    • Method Detail

      • clone

        public StringFieldValue clone()
        Clones this StringFieldValue and its span trees.
        Overrides:
        clone in class FieldValue
        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:
        clear in class FieldValue
      • assign

        public void assign​(java.lang.Object o)
        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:
        assign in class FieldValue
        Parameters:
        o - the new String to assign to this. An argument of null is equal to calling clear().
        Throws:
        java.lang.IllegalArgumentException - if the given argument is a string containing non-text characters as defined by Text.isTextCharacter(int)
      • getSpanTrees

        public java.util.Collection<SpanTree> 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

        public final java.util.Map<java.lang.String,​SpanTree> getSpanTreeMap()
        Returns the map of spantrees. Might be null.
      • getSpanTree

        public SpanTree getSpanTree​(java.lang.String name)
        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

        public SpanTree setSpanTree​(SpanTree spanTree)
        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:
        java.lang.IllegalArgumentException - if a span tree with the given name already exists.
      • removeSpanTree

        public SpanTree removeSpanTree​(java.lang.String name)
        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

        public java.lang.String getString()
        Returns the String value wrapped by this StringFieldValue
      • getWrappedValue

        public java.lang.Object getWrappedValue()
        Returns the String value wrapped by this StringFieldValue
        Overrides:
        getWrappedValue in class FieldValue
      • printXml

        public void printXml​(XmlStream xml)
        Prints XML in Vespa Document XML format for this StringFieldValue.
        Specified by:
        printXml in class FieldValue
        Parameters:
        xml - the stream to print to
      • toString

        public java.lang.String toString()
        Returns the String value wrapped by this StringFieldValue.
        Overrides:
        toString in class com.yahoo.vespa.objects.Identifiable
        Returns:
        the String value wrapped by this StringFieldValue.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class com.yahoo.vespa.objects.Identifiable
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class com.yahoo.vespa.objects.Identifiable
      • setUnChecked

        public void setUnChecked​(java.lang.String s)
        Only for use by deserializer to avoid the cost of verifying input.