Package com.yahoo.text.interpretation
Class Annotations
- java.lang.Object
-
- com.yahoo.text.interpretation.Annotations
-
public class Annotations extends java.lang.Object
An annotation is a description of a an area of text, with a given class. For example, an annotation for the- Author:
- Arne Bergene Fossaa
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>
annotations
-
Constructor Summary
Constructors Constructor Description Annotations(Span span)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.String key)
java.lang.Boolean
getBoolean(java.lang.String key)
Helper function to get a Boolean annotation.java.lang.Double
getDouble(java.lang.String key)
Helper function to get a Double annotation.java.lang.Integer
getInteger(java.lang.String key)
Helper function to get a Double annotation.java.util.Map<java.lang.String,java.lang.Object>
getMap()
Span
getSpan()
The span that this annotation is for.java.lang.String
getString(java.lang.String key)
Helper function to get a String from the Annotation.java.lang.String
getSubString()
The text this annotation is for.void
put(java.lang.String key, java.lang.Object o)
Adds an annotation to the the the set of annotations.
-
-
-
Constructor Detail
-
Annotations
public Annotations(Span span)
-
-
Method Detail
-
put
public void put(java.lang.String key, java.lang.Object o)
Adds an annotation to the the the set of annotations.
-
getMap
public java.util.Map<java.lang.String,java.lang.Object> getMap()
-
get
public java.lang.Object get(java.lang.String key)
-
getSpan
public Span getSpan()
The span that this annotation is for.
-
getSubString
public java.lang.String getSubString()
The text this annotation is for.
-
getDouble
public java.lang.Double getDouble(java.lang.String key)
Helper function to get a Double annotation.This function first checks if the Object in a map is a
Number
, and then calls doubleValue() on it If it is not, then Double.parseDouble() is called on the string representation of the object. If the string is not parseable as a double, a NumberFormatException is thrown.
-
getString
public java.lang.String getString(java.lang.String key)
Helper function to get a String from the Annotation. This function will simply calltoString()
on the object saved in the Annotation or return null if the object is null;
-
getInteger
public java.lang.Integer getInteger(java.lang.String key)
Helper function to get a Double annotation.This function first checks if the Object in a map is a
Number
, and intValue() is called on it. If it is not, then Double.parseDouble() is called on the string representation of the object. If the string is not parseable as a double, a NumberFormatException is thrown.
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.String key)
Helper function to get a Boolean annotation.
-
-