org.semanticweb.triple.application
Class ResultSet

java.lang.Object
  extended byorg.semanticweb.triple.application.ResultSet
All Implemented Interfaces:
java.util.Iterator

public class ResultSet
extends java.lang.Object
implements java.util.Iterator

Results returned by a triple query are stored here. Translation from org.semanticweb.lp.* classes to org.semanticweb.triple.language.* classes. Is the translation of results really needed? If yes, to what level should be translated: org.semanticweb.triple.language? or just java objects (Integer, Float, String) etc? What about Resources? Lots of OMM-related code goes here.

Version:
Author:
Andreas Harth

Constructor Summary
ResultSet(XSBCoreIntf xsbCore, java.util.ArrayList answerVars)
          Constructor.
 
Method Summary
 void addOMMExcluded(java.lang.String resource)
          The strings that are added here are excluded from the result.
 java.util.ArrayList getVariables()
          Return a list with variable substitutions.
 boolean hasNext()
          Returns true if the iteration has more elements.
 boolean isOMMExcluded(java.lang.String resource)
          Check whether result is excluded
 java.lang.Object next()
          Return the next element in the iteration.
 void remove()
          Not supported
 void setJava(boolean flag)
          Determine whether to return Java or org.semanticweb.triple.language objects.
 java.util.ArrayList toArrayList()
          Return an ArrayList of the result values.
 Model toModel()
          Return the result set as RDF/XML.
 java.lang.String toN3()
          Result in N3.
 java.util.ArrayList toOMMArrayList(int numberOfResults)
          Convert a ResultSet object to an ArrayList (sorted) and cuts of numberOfResults result items.
 java.lang.String toOMMPrettyPrint(int numberOfResults)
          Return results in pretty-print format.
 java.lang.String toOMMXML()
          Return results in XML format according to OMM requirements.
 java.lang.String toRDF()
          Result in N3.
 java.lang.String toString()
          Used for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultSet

public ResultSet(XSBCoreIntf xsbCore,
                 java.util.ArrayList answerVars)
Constructor.

Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface java.util.Iterator

setJava

public void setJava(boolean flag)
Determine whether to return Java or org.semanticweb.triple.language objects.


getVariables

public java.util.ArrayList getVariables()
Return a list with variable substitutions.


next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Return the next element in the iteration. Returns Iterator of AnswerSubstitutions.

Specified by:
next in interface java.util.Iterator
Throws:
java.util.NoSuchElementException

remove

public void remove()
Not supported

Specified by:
remove in interface java.util.Iterator

toString

public java.lang.String toString()
Used for debugging. Caution: iterates over iterator and makes it invalid!


toN3

public java.lang.String toN3()
Result in N3. Only if result set adheres to (S, P, O).


toRDF

public java.lang.String toRDF()
Result in N3. Only if result set adheres to (S, P, O).


toModel

public Model toModel()
Return the result set as RDF/XML. Only possible if the results have three variables that resemble a RDF triple (S, P, O). Caution: if you want to use this method, the results of your query must adhere to a certain format (that is, S, P, O).


addOMMExcluded

public void addOMMExcluded(java.lang.String resource)
The strings that are added here are excluded from the result.


isOMMExcluded

public boolean isOMMExcluded(java.lang.String resource)
Check whether result is excluded


toArrayList

public java.util.ArrayList toArrayList()
Return an ArrayList of the result values.


toOMMArrayList

public java.util.ArrayList toOMMArrayList(int numberOfResults)
Convert a ResultSet object to an ArrayList (sorted) and cuts of numberOfResults result items. Caution: sorting is carried out based on a hard-coded property (rank). Also, if resources are in the result set twice, only the resource with the hightes rank is kept.


toOMMXML

public java.lang.String toOMMXML()
                          throws XSBException,
                                 ParseException
Return results in XML format according to OMM requirements.

Throws:
XSBException
ParseException

toOMMPrettyPrint

public java.lang.String toOMMPrettyPrint(int numberOfResults)
                                  throws XSBException,
                                         ParseException
Return results in pretty-print format.

Throws:
XSBException
ParseException