org.weblab_project.core.helper.impl
Class Results

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<java.lang.String,java.util.LinkedHashMap<java.lang.String,java.lang.Object>>
              extended by org.weblab_project.core.helper.impl.Results
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.util.LinkedHashMap<java.lang.String,java.lang.Object>>

public class Results
extends java.util.LinkedHashMap<java.lang.String,java.util.LinkedHashMap<java.lang.String,java.lang.Object>>

This class provides simple methods to access results of the selection.
Results are ordered in a map of map.
Let's say your search returns 3 results:
(uri:mySubject#1, uri:myPredicate#1, resource:myObject#1)
(uri:mySubject#1, uri:myPredicate#2, resource:myObject#2)
(uri:mySubject#2, uri:myPredicate#1, resource:myObject#3)

To access the text value of resource:myObject#1, one could write
Results results = SimpleSelector.searchFor(Mydoc);
String valueOfMyObject1 = results.getTypedValue("uri:mySubject#1","uri:myPredicate#1",String.class);


To list all subjects that contain the predicate uri:myPredicate#1, one could write:
Results results = SimpleSelector.searchFor(Mydoc);
List<String> sujbects = results.getSubjects("uri:myPredicate#1",".*");
Remark: the use of a regular expression in the second parameters allow to select any value for this predicate.

Author:
arnaud saval
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  Statements statements
           
 
Constructor Summary
protected Results(Statements statements)
           
 
Method Summary
 java.util.Set<java.lang.String> getSubjects(java.lang.String predicate, java.lang.String object)
          Returns all the subjects that matches the tuple (predicate,object)
<T> T
getTypedValue(java.lang.String subject, java.lang.String property, java.lang.Class<T> clazz)
          Return a typed value rather than an object.
<T> java.util.LinkedList<T>
getTypedValues(java.lang.String subject, java.lang.String property, java.lang.Class<T> clazz)
          Returns a list of typed values.
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Field Detail

statements

protected Statements statements
Constructor Detail

Results

protected Results(Statements statements)
Method Detail

getSubjects

public java.util.Set<java.lang.String> getSubjects(java.lang.String predicate,
                                                   java.lang.String object)
Returns all the subjects that matches the tuple (predicate,object)

Parameters:
predicate -
object -
Returns:
a set of subject

getTypedValue

public <T> T getTypedValue(java.lang.String subject,
                           java.lang.String property,
                           java.lang.Class<T> clazz)
Return a typed value rather than an object.

Type Parameters:
T - the type to be returned
Parameters:
subject - a subject
property - a property
clazz - a class of the type of the value
Returns:
An instance of if the value can be mapped on this type, else null.

getTypedValues

public <T> java.util.LinkedList<T> getTypedValues(java.lang.String subject,
                                                  java.lang.String property,
                                                  java.lang.Class<T> clazz)
Returns a list of typed values.

Type Parameters:
T - the type of the value
Parameters:
subject - the uri of the subject
property - the uri of the subject
clazz - the class of the value
Returns:
a list of typed values.


Copyright © 2004-2010. All Rights Reserved.