Protégé-OWL 3.3.1

edu.stanford.smi.protegex.owl.swrl.bridge.query
Class ResultImpl

java.lang.Object
  extended by edu.stanford.smi.protegex.owl.swrl.bridge.query.ResultImpl
All Implemented Interfaces:
Result, ResultGenerator

public class ResultImpl
extends Object
implements ResultGenerator, Result

This class implements the interfaces Result 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: Result result = new ResultImpl("TestResult"); result.addColumn("name"); result.addAggregateColumn("average", ResultGenerator.AvgAggregateFunction); result.configured(); result.openRow(); result.addData(new IndividualInfo("Fred")); result.addData(new LiteralInfo(27)); result.closeRow(); result.openRow(); result.addData(new IndividualInfo("Joe")); result.addData(new LiteralInfo(34)); result.closeRow(); result.openRow(); result.addData(new IndividualInfo("Joe")); result.addData(new LiteralInfo(21)); result.closeRow(); result.prepared(); The result is now available for reading. The interface Result 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.


Field Summary
 
Fields inherited from interface edu.stanford.smi.protegex.owl.swrl.bridge.query.ResultGenerator
AvgAggregateFunction, CountAggregateFunction, MaxAggregateFunction, MinAggregateFunction, SumAggregateFunction
 
Constructor Summary
ResultImpl()
           
 
Method Summary
 void addAggregateColumn(String columnName, String aggregateFunctionName)
           
 void addColumn(String columnName)
           
 void addColumnDisplayName(String columnName)
           
 void addColumns(List<String> columnNames)
           
 void addOrderByColumn(int orderedColumnIndex, boolean ascending)
           
 void addRow(List<ResultValue> resultValues)
           
 void addRowData(ResultValue value)
           
 void closeRow()
           
 void configured()
           
 ClassValue getClassValue(int columnIndex)
           
 ClassValue getClassValue(String columnName)
           
 List<ResultValue> getColumn(int columnIndex)
           
 List<ResultValue> getColumn(String columnName)
           
 String getColumnName(int columnIndex)
           
 List<String> getColumnNames()
           
 DatatypeValue getDatatypeValue(int columnIndex)
           
 DatatypeValue getDatatypeValue(String columnName)
           
 int getNumberOfColumns()
           
 int getNumberOfRows()
           
 ObjectValue getObjectValue(int columnIndex)
           
 ObjectValue getObjectValue(String columnName)
           
 PropertyValue getPropertyValue(int columnIndex)
           
 PropertyValue getPropertyValue(String columnName)
           
 List<ResultValue> getRow()
           
 ResultValue getValue(int columnIndex)
           
 ResultValue getValue(int columnIndex, int rowIndex)
           
 ResultValue getValue(String columnName)
           
 boolean hasClassValue(int columnIndex)
           
 boolean hasClassValue(String columnName)
           
 boolean hasDatatypeValue(int columnIndex)
           
 boolean hasDatatypeValue(String columnName)
           
 boolean hasNext()
           
 boolean hasObjectValue(int columnIndex)
           
 boolean hasObjectValue(String columnName)
           
 boolean hasPropertyValue(int columnIndex)
           
 boolean hasPropertyValue(String columnName)
           
 void initialize()
           
 boolean isAscending()
           
 boolean isConfigured()
           
 boolean isDistinct()
           
 boolean isOrdered()
           
 boolean isPrepared()
           
 boolean isRowOpen()
           
 void next()
           
 void openRow()
           
 void prepared()
           
 void reset()
           
 void setIsDistinct()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultImpl

public ResultImpl()
Method Detail

isConfigured

public boolean isConfigured()
Specified by:
isConfigured in interface ResultGenerator

isRowOpen

public boolean isRowOpen()
Specified by:
isRowOpen in interface ResultGenerator

isDistinct

public boolean isDistinct()

isPrepared

public boolean isPrepared()
Specified by:
isPrepared in interface ResultGenerator

isOrdered

public boolean isOrdered()
Specified by:
isOrdered in interface ResultGenerator

isAscending

public boolean isAscending()
Specified by:
isAscending in interface ResultGenerator

initialize

public void initialize()
Specified by:
initialize in interface ResultGenerator

addColumns

public void addColumns(List<String> columnNames)
                throws ResultException
Specified by:
addColumns in interface ResultGenerator
Throws:
ResultException

addColumn

public void addColumn(String columnName)
               throws ResultException
Specified by:
addColumn in interface ResultGenerator
Throws:
ResultException

addAggregateColumn

public void addAggregateColumn(String columnName,
                               String aggregateFunctionName)
                        throws ResultException
Specified by:
addAggregateColumn in interface ResultGenerator
Throws:
ResultException

addOrderByColumn

public void addOrderByColumn(int orderedColumnIndex,
                             boolean ascending)
                      throws ResultException
Specified by:
addOrderByColumn in interface ResultGenerator
Throws:
ResultException

addColumnDisplayName

public void addColumnDisplayName(String columnName)
                          throws ResultException
Specified by:
addColumnDisplayName in interface ResultGenerator
Throws:
ResultException

configured

public void configured()
                throws ResultException
Specified by:
configured in interface ResultGenerator
Throws:
ResultException

setIsDistinct

public void setIsDistinct()
Specified by:
setIsDistinct in interface ResultGenerator

getNumberOfColumns

public int getNumberOfColumns()
                       throws ResultException
Specified by:
getNumberOfColumns in interface Result
Throws:
ResultException

getColumnNames

public List<String> getColumnNames()
                            throws ResultException
Specified by:
getColumnNames in interface Result
Throws:
ResultException

getColumnName

public String getColumnName(int columnIndex)
                     throws ResultException
Specified by:
getColumnName in interface Result
Throws:
ResultException

addRow

public void addRow(List<ResultValue> resultValues)
            throws ResultException
Specified by:
addRow in interface ResultGenerator
Throws:
ResultException

openRow

public void openRow()
             throws ResultException
Specified by:
openRow in interface ResultGenerator
Throws:
ResultException

addRowData

public void addRowData(ResultValue value)
                throws ResultException
Specified by:
addRowData in interface ResultGenerator
Throws:
ResultException

closeRow

public void closeRow()
              throws ResultException
Specified by:
closeRow in interface ResultGenerator
Throws:
ResultException

prepared

public void prepared()
              throws ResultException
Specified by:
prepared in interface ResultGenerator
Throws:
ResultException

getNumberOfRows

public int getNumberOfRows()
                    throws ResultException
Specified by:
getNumberOfRows in interface Result
Throws:
ResultException

reset

public void reset()
           throws ResultException
Specified by:
reset in interface Result
Throws:
ResultException

next

public void next()
          throws ResultException
Specified by:
next in interface Result
Throws:
ResultException

hasNext

public boolean hasNext()
                throws ResultException
Specified by:
hasNext in interface Result
Throws:
ResultException

getRow

public List<ResultValue> getRow()
                         throws ResultException
Specified by:
getRow in interface Result
Throws:
ResultException

getValue

public ResultValue getValue(String columnName)
                     throws ResultException
Specified by:
getValue in interface Result
Throws:
ResultException

getValue

public ResultValue getValue(int columnIndex)
                     throws ResultException
Specified by:
getValue in interface Result
Throws:
ResultException

getValue

public ResultValue getValue(int columnIndex,
                            int rowIndex)
                     throws ResultException
Specified by:
getValue in interface Result
Throws:
ResultException

getObjectValue

public ObjectValue getObjectValue(String columnName)
                           throws ResultException
Specified by:
getObjectValue in interface Result
Throws:
ResultException

getObjectValue

public ObjectValue getObjectValue(int columnIndex)
                           throws ResultException
Specified by:
getObjectValue in interface Result
Throws:
ResultException

getDatatypeValue

public DatatypeValue getDatatypeValue(String columnName)
                               throws ResultException
Specified by:
getDatatypeValue in interface Result
Throws:
ResultException

getClassValue

public ClassValue getClassValue(String columnName)
                         throws ResultException
Specified by:
getClassValue in interface Result
Throws:
ResultException

getClassValue

public ClassValue getClassValue(int columnIndex)
                         throws ResultException
Specified by:
getClassValue in interface Result
Throws:
ResultException

getPropertyValue

public PropertyValue getPropertyValue(int columnIndex)
                               throws ResultException
Specified by:
getPropertyValue in interface Result
Throws:
ResultException

getPropertyValue

public PropertyValue getPropertyValue(String columnName)
                               throws ResultException
Specified by:
getPropertyValue in interface Result
Throws:
ResultException

getDatatypeValue

public DatatypeValue getDatatypeValue(int columnIndex)
                               throws ResultException
Specified by:
getDatatypeValue in interface Result
Throws:
ResultException

getColumn

public List<ResultValue> getColumn(String columnName)
                            throws ResultException
Specified by:
getColumn in interface Result
Throws:
ResultException

getColumn

public List<ResultValue> getColumn(int columnIndex)
                            throws ResultException
Specified by:
getColumn in interface Result
Throws:
ResultException

hasObjectValue

public boolean hasObjectValue(String columnName)
                       throws ResultException
Specified by:
hasObjectValue in interface Result
Throws:
ResultException

hasObjectValue

public boolean hasObjectValue(int columnIndex)
                       throws ResultException
Specified by:
hasObjectValue in interface Result
Throws:
ResultException

hasDatatypeValue

public boolean hasDatatypeValue(String columnName)
                         throws ResultException
Specified by:
hasDatatypeValue in interface Result
Throws:
ResultException

hasDatatypeValue

public boolean hasDatatypeValue(int columnIndex)
                         throws ResultException
Specified by:
hasDatatypeValue in interface Result
Throws:
ResultException

hasClassValue

public boolean hasClassValue(String columnName)
                      throws ResultException
Specified by:
hasClassValue in interface Result
Throws:
ResultException

hasClassValue

public boolean hasClassValue(int columnIndex)
                      throws ResultException
Specified by:
hasClassValue in interface Result
Throws:
ResultException

hasPropertyValue

public boolean hasPropertyValue(String columnName)
                         throws ResultException
Specified by:
hasPropertyValue in interface Result
Throws:
ResultException

hasPropertyValue

public boolean hasPropertyValue(int columnIndex)
                         throws ResultException
Specified by:
hasPropertyValue in interface Result
Throws:
ResultException

toString

public String toString()
Overrides:
toString in class Object

Protégé-OWL 3.3.1

Submit a bug report or feature request
Copyright (c) 1998-2007 Stanford University.