Package com.yahoo.document.annotation
Class Annotation
- java.lang.Object
-
- com.yahoo.document.annotation.Annotation
-
- All Implemented Interfaces:
java.lang.Comparable<Annotation>
public class Annotation extends java.lang.Object implements java.lang.Comparable<Annotation>
An Annotation describes some kind of information associated with aSpanNode
.- Author:
- Einar M R Rosenvinge
- See Also:
SpanNode
,AnnotationType
-
-
Constructor Summary
Constructors Constructor Description Annotation()
Constructs an Annotation without a type. BEWARE! Should only be used during deserialization.Annotation(Annotation other)
Constructs a copy of the input annotation.Annotation(AnnotationType type)
Constructs a new annotation of the specified type.Annotation(AnnotationType type, FieldValue value)
Constructs a new annotation of the specified type, and having the specified value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Annotation annotation)
boolean
equals(java.lang.Object o)
FieldValue
getFieldValue()
Returns the value of the annotation, if any.int
getScratchId()
SpanNode
getSpanNode()
Returns theSpanNode
this Annotation is annotating, if any.SpanNode
getSpanNodeFast()
Returns theSpanNode
this Annotation is annotating, if any.AnnotationType
getType()
Returns the type of this annotation.boolean
hasFieldValue()
Returns true if this Annotation has a value.int
hashCode()
boolean
hasSpanNode()
Returns true if this Annotation is associated with a SpanNode (irrespective of the SpanNode being valid or not).boolean
isSpanNodeValid()
Returns true iff. this Annotation is associated with a SpanNode and the SpanNode is valid.void
setFieldValue(FieldValue fieldValue)
Sets the value of the annotation.void
setScratchId(int id)
void
setSpanNode(SpanNode spanNode)
WARNING! Should only be used by deserializers! Sets the span node that this annotation points to.void
setSpanNodeFast(SpanNode spanNode)
WARNING! Should only be used by deserializers! Sets the span node that this annotation points to.void
setType(AnnotationType type)
Sets the type of this annotation. BEWARE! Should only be used during deserialization.java.lang.String
toString()
-
-
-
Constructor Detail
-
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 annotationvalue
- the value of the new annotation- Throws:
java.lang.UnsupportedOperationException
- if the annotation type does not allow this annotation to have values.
-
-
Method Detail
-
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:
SpanNode.isValid()
-
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:
SpanNode.isValid()
-
getSpanNode
public SpanNode getSpanNode()
Returns theSpanNode
this Annotation is annotating, if any.- Returns:
- the
SpanNode
this Annotation is annotating, or null - Throws:
java.lang.IllegalStateException
- if this Annotation is associated with a SpanNode and the SpanNode is invalid.
-
getSpanNodeFast
public final SpanNode getSpanNodeFast()
Returns theSpanNode
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:
java.lang.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(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(Annotation annotation)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Annotation>
-
-