SMILA (incubation) API documentation

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

java.lang.Object
  extended by org.eclipse.smila.search.api.helper.RecordAccessor
Direct Known Subclasses:
QueryRecordAccessor, ResultRecordAccessor

public class RecordAccessor
extends java.lang.Object

methods to make reading of literals and annotations a bit easier, similar to blackboard.

Author:
jschumacher

Constructor Summary
RecordAccessor(Record record)
          create accessor for record.
 
Method Summary
 int annotationSize(java.lang.String annotationName)
          get number of record annotations.
 int annotationSize(java.lang.String attributeName, java.lang.String annotationName)
          get number of attribute annotations with a given name.
 Annotation getAnnotation(java.lang.String annotationName)
          get a record annotation.
 Annotation getAnnotation(java.lang.String attributeName, java.lang.String annotationName)
          get first attribute annotation with a given name.
 java.util.List<Annotation> getAnnotations(java.lang.String annotationName)
          get list of record annotations.
 java.util.List<Annotation> getAnnotations(java.lang.String attributeName, java.lang.String annotationName)
          get all attribute annotations with a given name.
 java.lang.String getAnnotationValue(java.lang.String annotationName, java.lang.String valueName)
          get a named value of record annotation.
 java.util.List<java.lang.String> getAnnotationValues(java.lang.String annotationName)
          get anonymous value list of record annotation.
 Literal getLiteral(java.lang.String attributeName)
          get a literal attribute value.
 java.util.List<Literal> getLiterals(java.lang.String attributeName)
          get literal attribute values.
 Record getRecord()
           
 java.lang.Double getResultAnnotationFloatValue(java.lang.String valueName)
          get named value of result annotation, converted to an Double.
 java.lang.Integer getResultAnnotationIntValue(java.lang.String valueName)
          get named value of result annotation, converted to an Integer.
 java.lang.String getResultAnnotationValue(java.lang.String valueName)
          get named value of result annotation.
 Terms getTerms(java.lang.String attributeName)
          get terms list for an attribute.
 boolean hasAnnotation(java.lang.String annotationName)
          check if a record annotation exists.
 boolean hasAnnotation(java.lang.String attributeName, java.lang.String annotationName)
          check if an attribute annotation exists.
 boolean hasAttribute(java.lang.String attributeName)
          check if an attribute exists.
 boolean hasLiterals(java.lang.String attributeName)
           
 int literalSize(java.lang.String attributeName)
          get number of literals in an attribute.
static
<T> java.util.List<T>
unmodifiableList(java.util.Collection<? extends T> collection)
          convert the collection to a list, if it is not actually a list already, and create a unmodifiable list from it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordAccessor

public RecordAccessor(Record record)
create accessor for record.

Parameters:
record - a record.
Method Detail

hasAttribute

public boolean hasAttribute(java.lang.String attributeName)
check if an attribute exists.

Parameters:
attributeName - an attribute name.
Returns:
true if the record metadata contains the named attribute.

hasLiterals

public boolean hasLiterals(java.lang.String attributeName)
Parameters:
attributeName - an attribute name.
Returns:
true if the record metadata contains the named attribute and it has literal values.

literalSize

public int literalSize(java.lang.String attributeName)
get number of literals in an attribute.

Parameters:
attributeName - an attribute name.
Returns:
number of literal values in the named attribute. 0, if the attribute does not exist.

getLiteral

public Literal getLiteral(java.lang.String attributeName)
get a literal attribute value.

Parameters:
attributeName - an attribute name.
Returns:
first literal value in this attribute, if any, else null.

getLiterals

public java.util.List<Literal> getLiterals(java.lang.String attributeName)
get literal attribute values. The returned list cannot be modified.

Parameters:
attributeName - an attribute name.
Returns:
list of literals in this attribute. returns an empty list, of the attributes does not exist or does not have literals.

hasAnnotation

public boolean hasAnnotation(java.lang.String annotationName)
check if a record annotation exists.

Parameters:
annotationName - an annotation name
Returns:
true, if a record annotation with this name exists, else false.

annotationSize

public int annotationSize(java.lang.String annotationName)
get number of record annotations.

Parameters:
annotationName - an annotation name
Returns:
number of record annotations with this name

getAnnotation

public Annotation getAnnotation(java.lang.String annotationName)
get a record annotation.

Parameters:
annotationName - an annotation name
Returns:
first record annotation with this name. null, if no such annotation exists.

getAnnotations

public java.util.List<Annotation> getAnnotations(java.lang.String annotationName)
get list of record annotations. The list cannot be modified.

Parameters:
annotationName - an annotation name
Returns:
list of annotations with this name. The original collection of annotations is only copied to a list, if it is not actually a list already.

getAnnotationValue

public java.lang.String getAnnotationValue(java.lang.String annotationName,
                                           java.lang.String valueName)
get a named value of record annotation.

Parameters:
annotationName - annotation name.
valueName - value name
Returns:
named value of record annotation. null, if the annotation does not exists or does not have the value.

getAnnotationValues

public java.util.List<java.lang.String> getAnnotationValues(java.lang.String annotationName)
get anonymous value list of record annotation. The list cannot be modified.

Parameters:
annotationName - annotation name.
Returns:
list of anon values, of empty list, if annotation does not exist or has no values.

hasAnnotation

public boolean hasAnnotation(java.lang.String attributeName,
                             java.lang.String annotationName)
check if an attribute annotation exists.

Parameters:
attributeName - an attribute name
annotationName - an annotation name
Returns:
true if the attribute exists and has the annotation, else false.

annotationSize

public int annotationSize(java.lang.String attributeName,
                          java.lang.String annotationName)
get number of attribute annotations with a given name.

Parameters:
attributeName - attribute name
annotationName - annotation name
Returns:
number of matching attribute annotations, 0 if attribute does not exist.

getAnnotation

public Annotation getAnnotation(java.lang.String attributeName,
                                java.lang.String annotationName)
get first attribute annotation with a given name.

Parameters:
attributeName - attribute name
annotationName - annotation name
Returns:
first named attribute annotation, null if no such attribute exists.

getAnnotations

public java.util.List<Annotation> getAnnotations(java.lang.String attributeName,
                                                 java.lang.String annotationName)
get all attribute annotations with a given name. The list cannot be modified.

Parameters:
attributeName - attribute name
annotationName - annotation name
Returns:
list of named attribute annotation, empty list if no such attribute exists.

getTerms

public Terms getTerms(java.lang.String attributeName)
get terms list for an attribute.

Parameters:
attributeName - name of attribute.
Returns:
list of terms

getRecord

public Record getRecord()
Returns:
underlying record.

getResultAnnotationValue

public java.lang.String getResultAnnotationValue(java.lang.String valueName)
get named value of result annotation.

Parameters:
valueName - value name.
Returns:
value string of null, if not present

getResultAnnotationIntValue

public java.lang.Integer getResultAnnotationIntValue(java.lang.String valueName)
get named value of result annotation, converted to an Integer.

Parameters:
valueName - value name.
Returns:
value string of null, if not present or not parseable as an integer.

getResultAnnotationFloatValue

public java.lang.Double getResultAnnotationFloatValue(java.lang.String valueName)
get named value of result annotation, converted to an Double.

Parameters:
valueName - value name.
Returns:
value string of null, if not present or not parseable as an Double.

unmodifiableList

public static <T> java.util.List<T> unmodifiableList(java.util.Collection<? extends T> collection)
convert the collection to a list, if it is not actually a list already, and create a unmodifiable list from it.

Type Parameters:
T - type of collection elements.
Parameters:
collection - a collection
Returns:
unmodifiable list with the elements of the collection

SMILA (incubation) API documentation