|
Protégé-OWL 3.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.smi.protegex.owl.swrl.sqwrl.impl.ResultImpl
public class ResultImpl
This class implements the interfaces SQWRLResult and ResultGenerator. It can be used to generate a result structure and populate it with data; it can also be used to retrieve those data from the result.
This class operates in three phases:
(1) Configuration Phase: In this phase the structure of the result is defined. This phase opened by a call to the configure() method (which will also clear any existing data). In this phase the columns are defined; aggregation or ordering is also specified in this phase. This phase is closed by a call to the configured() method.
(2) Preparation Phase: In this phase data are added to the result. This phase is implicitly opened by the call to the configured() method. It is closed by a call to the prepared() method.
The interface ResultGenerator defines the calls used in these two phases.
(3) Processing Phase: In this phase data may be retrieved from the result. This phase is implicitly opened by the call to the closed() method.
The interface Result defines the calls used in the processing phase.
An example configuration and data generation is:
ResultImpl result = new ResultImpl("TestResult");
result.addColumn("name");
result.addAggregateColumn("average", SQWRLNames.AvgAggregateFunction);
result.configured();<>p
result.openRow();
result.addData(new OWLFactory.createOWLIndividual("Fred"));
result.addData(new Literal(27));
result.closeRow();
result.openRow();
result.addData(new OWLFactory.createOWLIndividual("Joe"));
result.addData(new Literal(34));
result.closeRow();
result.openRow();
result.addData(new OWLFactory.createOWLIndividual("Joe"));
result.addData(new Literal(21));
result.closeRow();
result.prepared();
The result is now available for reading. The interface SQWRLResult defines the assessor methods. A row consists of a list of objects defined by the interface ResultValue. There are four possible types of values (1) DatatypeValue, representing literals; (2) ObjectValue, representing OWL individuals; (3) ClassValue, representing OWL classes; and (4) PropertyValue, representing OWL properties.
while (result.hasNext()) {
ObjectValue nameValue = result.getObjectValue("name");
DatatypeValue averageValue = result.getDatatypeValue("average");
System.out.println("Name: " + nameValue.getIndividualName());
System.out.println("Average: " + averageValue.getInt());
} // while
A convenience method addColumns that takes a list of column names is also supplied.
There is also a convenience method addRow, which takes a list of ResultValues. This method automatically does a row open and close. It is expecting the exact same number of list elements as there are columns in the result.
Constructor Summary | |
---|---|
ResultImpl()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ResultImpl()
Method Detail |
---|
public boolean isConfigured()
isConfigured
in interface ResultGenerator
public boolean isRowOpen()
isRowOpen
in interface ResultGenerator
public boolean isDistinct()
public boolean isPrepared()
isPrepared
in interface ResultGenerator
public boolean isOrdered()
isOrdered
in interface ResultGenerator
public boolean isAscending()
isAscending
in interface ResultGenerator
public void initialize()
initialize
in interface ResultGenerator
public void addColumns(List<String> columnNames) throws SQWRLException
addColumns
in interface ResultGenerator
SQWRLException
public void addColumn(String columnName) throws SQWRLException
addColumn
in interface ResultGenerator
SQWRLException
public void addAggregateColumn(String columnName, String aggregateFunctionName) throws SQWRLException
addAggregateColumn
in interface ResultGenerator
SQWRLException
public void addOrderByColumn(int orderedColumnIndex, boolean ascending) throws SQWRLException
addOrderByColumn
in interface ResultGenerator
SQWRLException
public void addColumnDisplayName(String columnName) throws SQWRLException
addColumnDisplayName
in interface ResultGenerator
SQWRLException
public void configured() throws SQWRLException
configured
in interface ResultGenerator
SQWRLException
public void setIsDistinct()
setIsDistinct
in interface ResultGenerator
public int getNumberOfColumns() throws SQWRLException
getNumberOfColumns
in interface SQWRLResult
SQWRLException
public List<String> getColumnNames() throws SQWRLException
getColumnNames
in interface SQWRLResult
SQWRLException
public String getColumnName(int columnIndex) throws SQWRLException
getColumnName
in interface SQWRLResult
SQWRLException
public void addRow(List<ResultValue> resultValues) throws SQWRLException
addRow
in interface ResultGenerator
SQWRLException
public void openRow() throws SQWRLException
openRow
in interface ResultGenerator
SQWRLException
public void addRowData(ResultValue value) throws SQWRLException
addRowData
in interface ResultGenerator
SQWRLException
public void closeRow() throws SQWRLException
closeRow
in interface ResultGenerator
SQWRLException
public void prepared() throws SQWRLException
prepared
in interface ResultGenerator
SQWRLException
public int getNumberOfRows() throws SQWRLException
getNumberOfRows
in interface SQWRLResult
SQWRLException
public boolean isEmpty() throws SQWRLException
isEmpty
in interface SQWRLResult
SQWRLException
public void reset() throws SQWRLException
reset
in interface SQWRLResult
SQWRLException
public void next() throws SQWRLException
next
in interface SQWRLResult
SQWRLException
public boolean hasNext() throws SQWRLException
hasNext
in interface SQWRLResult
SQWRLException
public List<ResultValue> getRow() throws SQWRLException
getRow
in interface SQWRLResult
SQWRLException
public ResultValue getValue(String columnName) throws SQWRLException
getValue
in interface SQWRLResult
SQWRLException
public ResultValue getValue(int columnIndex) throws SQWRLException
getValue
in interface SQWRLResult
SQWRLException
public ResultValue getValue(int columnIndex, int rowIndex) throws SQWRLException
getValue
in interface SQWRLResult
SQWRLException
public ObjectValue getObjectValue(String columnName) throws SQWRLException
getObjectValue
in interface SQWRLResult
SQWRLException
public ObjectValue getObjectValue(int columnIndex) throws SQWRLException
getObjectValue
in interface SQWRLResult
SQWRLException
public DatatypeValue getDatatypeValue(String columnName) throws SQWRLException
getDatatypeValue
in interface SQWRLResult
SQWRLException
public ClassValue getClassValue(String columnName) throws SQWRLException
getClassValue
in interface SQWRLResult
SQWRLException
public ClassValue getClassValue(int columnIndex) throws SQWRLException
getClassValue
in interface SQWRLResult
SQWRLException
public PropertyValue getPropertyValue(int columnIndex) throws SQWRLException
getPropertyValue
in interface SQWRLResult
SQWRLException
public PropertyValue getPropertyValue(String columnName) throws SQWRLException
getPropertyValue
in interface SQWRLResult
SQWRLException
public DatatypeValue getDatatypeValue(int columnIndex) throws SQWRLException
getDatatypeValue
in interface SQWRLResult
SQWRLException
public List<ResultValue> getColumn(String columnName) throws SQWRLException
getColumn
in interface SQWRLResult
SQWRLException
public List<ResultValue> getColumn(int columnIndex) throws SQWRLException
getColumn
in interface SQWRLResult
SQWRLException
public boolean hasObjectValue(String columnName) throws SQWRLException
hasObjectValue
in interface SQWRLResult
SQWRLException
public boolean hasObjectValue(int columnIndex) throws SQWRLException
hasObjectValue
in interface SQWRLResult
SQWRLException
public boolean hasDatatypeValue(String columnName) throws SQWRLException
hasDatatypeValue
in interface SQWRLResult
SQWRLException
public boolean hasDatatypeValue(int columnIndex) throws SQWRLException
hasDatatypeValue
in interface SQWRLResult
SQWRLException
public boolean hasClassValue(String columnName) throws SQWRLException
hasClassValue
in interface SQWRLResult
SQWRLException
public boolean hasClassValue(int columnIndex) throws SQWRLException
hasClassValue
in interface SQWRLResult
SQWRLException
public boolean hasPropertyValue(String columnName) throws SQWRLException
hasPropertyValue
in interface SQWRLResult
SQWRLException
public boolean hasPropertyValue(int columnIndex) throws SQWRLException
hasPropertyValue
in interface SQWRLResult
SQWRLException
public String toString()
toString
in class Object
|
Protégé-OWL 3.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |