Class Annotations

java.lang.Object
com.yahoo.text.interpretation.Annotations

public class Annotations extends 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 Details

  • Constructor Details

    • Annotations

      public Annotations(Span span)
  • Method Details

    • put

      public void put(String key, Object o)
      Adds an annotation to the the the set of annotations.
    • getMap

      public Map<String,Object> getMap()
    • get

      public Object get(String key)
    • getSpan

      public Span getSpan()
      The span that this annotation is for.
    • getSubString

      public String getSubString()
      The text this annotation is for.
    • getDouble

      public Double getDouble(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 String getString(String key)
      Helper function to get a String from the Annotation. This function will simply call toString() on the object saved in the Annotation or return null if the object is null;
    • getInteger

      public Integer getInteger(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 Boolean getBoolean(String key)
      Helper function to get a Boolean annotation.