Class Annotation

java.lang.Object
com.yahoo.document.annotation.Annotation
All Implemented Interfaces:
Comparable<Annotation>

public class Annotation extends Object implements Comparable<Annotation>
An Annotation describes some kind of information associated with a SpanNode.
Author:
Einar M R Rosenvinge
See Also:
  • Constructor Details

    • Annotation

      public Annotation()
      Constructs an Annotation without a type. BEWARE! Should only be used during deserialization.
    • Annotation

      public Annotation(AnnotationType type)
      Constructs a new annotation of the specified type.
      Parameters:
      type - the type of the new annotation
    • Annotation

      public Annotation(Annotation other)
      Constructs a copy of the input annotation.
      Parameters:
      other - annotation
    • Annotation

      public Annotation(AnnotationType type, FieldValue value)
      Constructs a new annotation of the specified type, and having the specified value.
      Parameters:
      type - the type of the new annotation
      value - the value of the new annotation
      Throws:
      UnsupportedOperationException - if the annotation type does not allow this annotation to have values.
  • Method Details

    • setScratchId

      public void setScratchId(int id)
    • getScratchId

      public int getScratchId()
    • getType

      public AnnotationType getType()
      Returns the type of this annotation.
      Returns:
      the type of this annotation
    • setType

      public void setType(AnnotationType type)
      Sets the type of this annotation. BEWARE! Should only be used during deserialization.
      Parameters:
      type - the type of this annotation
    • hasSpanNode

      public boolean hasSpanNode()
      Returns true if this Annotation is associated with a SpanNode (irrespective of the SpanNode being valid or not).
      Returns:
      true if this Annotation is associated with a SpanNode, false otherwise.
      See Also:
    • isSpanNodeValid

      public boolean isSpanNodeValid()
      Returns true iff this Annotation is associated with a SpanNode and the SpanNode is valid.
      Returns:
      true iff this Annotation is associated with a SpanNode and the SpanNode is valid.
      See Also:
    • getSpanNode

      public SpanNode getSpanNode()
      Returns the SpanNode this Annotation is annotating, if any.
      Returns:
      the SpanNode this Annotation is annotating, or null
      Throws:
      IllegalStateException - if this Annotation is associated with a SpanNode and the SpanNode is invalid.
    • getSpanNodeFast

      public final SpanNode getSpanNodeFast()
      Returns the SpanNode this Annotation is annotating, if any.
      Returns:
      the SpanNode this Annotation is annotating, or null
    • setSpanNode

      public void setSpanNode(SpanNode spanNode)
      WARNING! Should only be used by deserializers! Sets the span node that this annotation points to.
      Parameters:
      spanNode - the span node that this annotation shall point to.
    • setSpanNodeFast

      public final void setSpanNodeFast(SpanNode spanNode)
      WARNING! Should only be used by deserializers! Sets the span node that this annotation points to.
      Parameters:
      spanNode - the span node that this annotation shall point to.
    • getFieldValue

      public FieldValue getFieldValue()
      Returns the value of the annotation, if any.
      Returns:
      the value of the annotation, or null
    • setFieldValue

      public void setFieldValue(FieldValue fieldValue)
      Sets the value of the annotation.
      Parameters:
      fieldValue - the value to set
      Throws:
      UnsupportedOperationException - if the annotation type does not allow this annotation to have values.
    • hasFieldValue

      public boolean hasFieldValue()
      Returns true if this Annotation has a value.
      Returns:
      true if this Annotation has a value, false otherwise.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Annotation annotation)
      Specified by:
      compareTo in interface Comparable<Annotation>