SMILA (incubation) API documentation

org.eclipse.smila.search.api.helper
Class AnnotationListAccessor

java.lang.Object
  extended by org.eclipse.smila.search.api.helper.AnnotationListAccessor
Direct Known Subclasses:
Facets, Terms

public class AnnotationListAccessor
extends java.lang.Object

base class for wrappers of list of attribute annotations (like terms or facets). Provides index based methods to the elements in the list and their values and subannotations. Includes a few type conversion helper methods, too.

Author:
jschumacher

Constructor Summary
AnnotationListAccessor(java.lang.String attributeName, java.util.Collection<Annotation> annotations)
          create instance from given data. the collection is copied to a list (based on iteration order) if it is not an instance of List already.
AnnotationListAccessor(java.lang.String attributeName, java.util.List<Annotation> annotations)
          create instance from given data.
 
Method Summary
 Annotation getAnnotation(int index, java.lang.String name)
          get the named subannotation of the n'th annotation from the list.
 java.util.List<Annotation> getAnnotations(int index, java.lang.String name)
          get list of named subannotations of the n'th annotation from the list.
 java.lang.String getAttributeName()
           
 java.lang.Double getFloatProperty(int index, java.lang.String name)
          access named value of n'th annotation in list and convert it to an floating point value.
 java.lang.Integer getIntProperty(int index, java.lang.String name)
          access named value of n'th annotation in list and convert it to an integer.
 java.lang.String getProperty(int index, java.lang.String name)
          access named value of n'th annotation in list.
 java.util.List<Annotation> getSource()
           
 int length()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationListAccessor

public AnnotationListAccessor(java.lang.String attributeName,
                              java.util.List<Annotation> annotations)
create instance from given data.

Parameters:
attributeName - name of annotated attribute.
annotations - list of annotations.

AnnotationListAccessor

public AnnotationListAccessor(java.lang.String attributeName,
                              java.util.Collection<Annotation> annotations)
create instance from given data. the collection is copied to a list (based on iteration order) if it is not an instance of List already.

Parameters:
attributeName - name of annotated attribute.
annotations - collection of annotations.
Method Detail

getAttributeName

public java.lang.String getAttributeName()
Returns:
name of annotated attribute. can be null, if irrelevant for this instance.

length

public int length()
Returns:
size of annotation list.

getAnnotation

public Annotation getAnnotation(int index,
                                java.lang.String name)
get the named subannotation of the n'th annotation from the list. If the index is invalid, null is returned.

Parameters:
index - position in list
name - name of subannotation.
Returns:
subannotation object, or null for invalid names or indexes.

getAnnotations

public java.util.List<Annotation> getAnnotations(int index,
                                                 java.lang.String name)
get list of named subannotations of the n'th annotation from the list. If the index is invalid, an empty list is returned. The returned list cannot be modified.

Parameters:
index - position in list
name - name of subannotation.
Returns:
list of subannotations, or an empty list for invalid names or indexes.

getProperty

public java.lang.String getProperty(int index,
                                    java.lang.String name)
access named value of n'th annotation in list.

Parameters:
index - position in list
name - name of named value.
Returns:
named value, or null for invalid names or indexes.

getIntProperty

public java.lang.Integer getIntProperty(int index,
                                        java.lang.String name)
access named value of n'th annotation in list and convert it to an integer.

Parameters:
index - position in list
name - name of named value.
Returns:
Integer parsed from named value, or null for invalid names, indexes or values not in integer format.

getFloatProperty

public java.lang.Double getFloatProperty(int index,
                                         java.lang.String name)
access named value of n'th annotation in list and convert it to an floating point value.

Parameters:
index - position in list
name - name of named value.
Returns:
Double parsed from named value, or null for invalid names, indexes or values not in double format.

getSource

public java.util.List<Annotation> getSource()
Returns:
underlying list of annotations.

SMILA (incubation) API documentation