net.ontopia.topicmaps.query.utils
Class QueryWrapper

java.lang.Object
  extended by net.ontopia.topicmaps.query.utils.QueryWrapper

public class QueryWrapper
extends java.lang.Object

EXPERIMENTAL: Class a la Spring's JDBC templates to simplify use of the tolog query engine API.

Since:
3.4.4

Constructor Summary
QueryWrapper(TopicMapIF topicmap)
          EXPERIMENTAL: Creates a wrapper for this particular topic map.
 
Method Summary
 DeclarationContextIF getDeclarationContext()
           
 QueryProcessorIF getQueryProcessor()
           
 boolean isTrue(java.lang.String query)
          EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows.
 boolean isTrue(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows.
 java.util.Map makeParams(java.lang.String name, java.lang.Object value)
          EXPERIMENTAL: Utility method for creating parameter maps.
 java.util.List queryForList(java.lang.String query)
          EXPERIMENTAL: Runs the query, and returns a the single value in each row.
 java.util.List queryForList(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Runs the query, and returns a the single value in each row.
 java.util.List queryForList(java.lang.String query, RowMapperIF mapper)
          EXPERIMENTAL: Runs the query, and calls the mapper for each row in the query result.
 java.util.List queryForList(java.lang.String query, RowMapperIF mapper, java.util.Map params)
          EXPERIMENTAL: Runs the query with the given parameters, and calls the mapper for each row in the query result.
 java.util.Map queryForMap(java.lang.String query)
          EXPERIMENTAL: Returns a map of the first row of the query results, with each variable name (without $) as a key and each variable value as the value of the key.
 java.util.Map queryForMap(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Returns a map of the first row of the query results, with each variable name (without $) as a key and each variable value as the value of the key.
 java.util.List queryForMaps(java.lang.String query)
          EXPERIMENTAL: Returns a list of Map values for each row in the query, with the variable name as the key.
 java.util.List queryForMaps(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Returns a list of Map values for each row in the query, with the variable name as the key.
 java.lang.Object queryForObject(java.lang.String query)
          EXPERIMENTAL: Returns the value in the first column in the first row of the query result.
 java.lang.Object queryForObject(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Returns the value in the first column in the first row of the query result.
 java.lang.Object queryForObject(java.lang.String query, RowMapperIF mapper)
          EXPERIMENTAL: Returns the mapping of the value in the first column in the first row of the query result.
 java.lang.Object queryForObject(java.lang.String query, RowMapperIF mapper, java.util.Map params)
          EXPERIMENTAL: Returns the mapping of the value in the first column in the first row of the query result.
 java.lang.String queryForString(java.lang.String query)
          EXPERIMENTAL: Returns a String from the first column in the first row of the query result.
 java.lang.String queryForString(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Returns a String from the first column in the first row of the query result.
 TopicIF queryForTopic(java.lang.String query)
          EXPERIMENTAL: Returns a topic from the first column in the first row of the query result.
 TopicIF queryForTopic(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Returns a topic from the first column in the first row of the query result.
 void setDeclarationContext(DeclarationContextIF context)
           
 void setDeclarations(java.lang.String declarations)
          EXPERIMENTAL: Sets the parsing context for the query processor.
 int update(java.lang.String query)
          EXPERIMENTAL: Runs an update statement, returning the number of changed rows.
 int update(java.lang.String query, java.util.Map params)
          EXPERIMENTAL: Runs an update statement, returning the number of changed rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryWrapper

public QueryWrapper(TopicMapIF topicmap)
EXPERIMENTAL: Creates a wrapper for this particular topic map.

Method Detail

getQueryProcessor

public QueryProcessorIF getQueryProcessor()

getDeclarationContext

public DeclarationContextIF getDeclarationContext()

setDeclarationContext

public void setDeclarationContext(DeclarationContextIF context)

setDeclarations

public void setDeclarations(java.lang.String declarations)
EXPERIMENTAL: Sets the parsing context for the query processor. Each call to this method overwrites the results from previous calls.

Parameters:
declarations - a tolog fragment containing prefix declarations

makeParams

public java.util.Map makeParams(java.lang.String name,
                                java.lang.Object value)
EXPERIMENTAL: Utility method for creating parameter maps.


queryForList

public java.util.List queryForList(java.lang.String query)
EXPERIMENTAL: Runs the query, and returns a the single value in each row.


queryForList

public java.util.List queryForList(java.lang.String query,
                                   java.util.Map params)
EXPERIMENTAL: Runs the query, and returns a the single value in each row.


queryForList

public java.util.List queryForList(java.lang.String query,
                                   RowMapperIF mapper)
EXPERIMENTAL: Runs the query, and calls the mapper for each row in the query result. Returns a list of all the objects produced by the mapper in query result order.


queryForList

public java.util.List queryForList(java.lang.String query,
                                   RowMapperIF mapper,
                                   java.util.Map params)
EXPERIMENTAL: Runs the query with the given parameters, and calls the mapper for each row in the query result. Returns a list of all the objects produced by the mapper in query result order.


queryForMap

public java.util.Map queryForMap(java.lang.String query)
EXPERIMENTAL: Returns a map of the first row of the query results, with each variable name (without $) as a key and each variable value as the value of the key. If the query produces no rows the method returns null; if it produces more than one an exception is thrown.


queryForMap

public java.util.Map queryForMap(java.lang.String query,
                                 java.util.Map params)
EXPERIMENTAL: Returns a map of the first row of the query results, with each variable name (without $) as a key and each variable value as the value of the key. If the query produces no rows the method returns null; if it produces more than one an exception is thrown.


queryForMaps

public java.util.List queryForMaps(java.lang.String query)
EXPERIMENTAL: Returns a list of Map values for each row in the query, with the variable name as the key.

Since:
5.1.0

queryForMaps

public java.util.List queryForMaps(java.lang.String query,
                                   java.util.Map params)
EXPERIMENTAL: Returns a list of Map values for each row in the query, with the variable name as the key.


isTrue

public boolean isTrue(java.lang.String query)
EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows. If the query produces more than one row an exception is thrown.


isTrue

public boolean isTrue(java.lang.String query,
                      java.util.Map params)
EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows. If the query produces more than one row an exception is thrown.


queryForString

public java.lang.String queryForString(java.lang.String query)
EXPERIMENTAL: Returns a String from the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForString

public java.lang.String queryForString(java.lang.String query,
                                       java.util.Map params)
EXPERIMENTAL: Returns a String from the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForTopic

public TopicIF queryForTopic(java.lang.String query)
EXPERIMENTAL: Returns a topic from the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForTopic

public TopicIF queryForTopic(java.lang.String query,
                             java.util.Map params)
EXPERIMENTAL: Returns a topic from the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForObject

public java.lang.Object queryForObject(java.lang.String query)
EXPERIMENTAL: Returns the value in the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForObject

public java.lang.Object queryForObject(java.lang.String query,
                                       RowMapperIF mapper)
EXPERIMENTAL: Returns the mapping of the value in the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForObject

public java.lang.Object queryForObject(java.lang.String query,
                                       java.util.Map params)
EXPERIMENTAL: Returns the value in the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


queryForObject

public java.lang.Object queryForObject(java.lang.String query,
                                       RowMapperIF mapper,
                                       java.util.Map params)
EXPERIMENTAL: Returns the mapping of the value in the first column in the first row of the query result. If the query produces no results null is returned. If the query produces more than one row or more than one column, an exception is thrown.


update

public int update(java.lang.String query)
EXPERIMENTAL: Runs an update statement, returning the number of changed rows. Makes no attempt to handle transactions, as this is an application issue.

Since:
5.1.1

update

public int update(java.lang.String query,
                  java.util.Map params)
EXPERIMENTAL: Runs an update statement, returning the number of changed rows. Makes no attempt to handle transactions, as this is an application issue.

Since:
5.1.1


Copyright © 2000-2012 Ontopia.