Package com.yahoo.document.annotation
Class Annotation
java.lang.Object
com.yahoo.document.annotation.Annotation
- All Implemented Interfaces:
Comparable<Annotation>
An Annotation describes some kind of information associated with a
SpanNode
.- Author:
- Einar M R Rosenvinge
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs an Annotation without a type.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
Modifier and TypeMethodDescriptionint
compareTo
(Annotation annotation) boolean
Returns the value of the annotation, if any.int
Returns theSpanNode
this Annotation is annotating, if any.final SpanNode
Returns theSpanNode
this Annotation is annotating, if any.getType()
Returns the type of this annotation.boolean
Returns true if this Annotation has a value.int
hashCode()
boolean
Returns true if this Annotation is associated with a SpanNode (irrespective of the SpanNode being valid or not).boolean
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.final 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.toString()
-
Constructor Details
-
Annotation
public Annotation()Constructs an Annotation without a type. BEWARE! Should only be used during deserialization. -
Annotation
Constructs a new annotation of the specified type.- Parameters:
type
- the type of the new annotation
-
Annotation
Constructs a copy of the input annotation.- Parameters:
other
- annotation
-
Annotation
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:
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
Returns the type of this annotation.- Returns:
- the type of this annotation
-
setType
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
Returns theSpanNode
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
Returns theSpanNode
this Annotation is annotating, if any.- Returns:
- the
SpanNode
this Annotation is annotating, or null
-
setSpanNode
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
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
Returns the value of the annotation, if any.- Returns:
- the value of the annotation, or null
-
setFieldValue
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
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Annotation>
-