Class QueryWrapper
- java.lang.Object
-
- net.ontopia.topicmaps.query.utils.QueryWrapper
-
public class QueryWrapper extends Object
EXPERIMENTAL: Class a la Spring's JDBC templates to simplify use of the tolog query engine API.- Since:
- 3.4.4
-
-
Constructor Summary
Constructors Constructor Description QueryWrapper(TopicMapIF topicmap)EXPERIMENTAL: Creates a wrapper for this particular topic map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeclarationContextIFgetDeclarationContext()QueryProcessorIFgetQueryProcessor()booleanisTrue(String query)EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows.booleanisTrue(String query, Map params)EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows.MapmakeParams(String name, Object value)EXPERIMENTAL: Utility method for creating parameter maps.ListqueryForList(String query)EXPERIMENTAL: Runs the query, and returns a the single value in each row.ListqueryForList(String query, Map params)EXPERIMENTAL: Runs the query, and returns a the single value in each row.ListqueryForList(String query, RowMapperIF mapper)EXPERIMENTAL: Runs the query, and calls the mapper for each row in the query result.ListqueryForList(String query, RowMapperIF mapper, Map params)EXPERIMENTAL: Runs the query with the given parameters, and calls the mapper for each row in the query result.MapqueryForMap(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.MapqueryForMap(String query, 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.ListqueryForMaps(String query)EXPERIMENTAL: Returns a list of Mapvalues for each row in the query, with the variable name as the key. ListqueryForMaps(String query, Map params)EXPERIMENTAL: Returns a list of Mapvalues for each row in the query, with the variable name as the key. ObjectqueryForObject(String query)EXPERIMENTAL: Returns the value in the first column in the first row of the query result.ObjectqueryForObject(String query, Map params)EXPERIMENTAL: Returns the value in the first column in the first row of the query result.ObjectqueryForObject(String query, RowMapperIF mapper)EXPERIMENTAL: Returns the mapping of the value in the first column in the first row of the query result.ObjectqueryForObject(String query, RowMapperIF mapper, Map params)EXPERIMENTAL: Returns the mapping of the value in the first column in the first row of the query result.StringqueryForString(String query)EXPERIMENTAL: Returns a String from the first column in the first row of the query result.StringqueryForString(String query, Map params)EXPERIMENTAL: Returns a String from the first column in the first row of the query result.TopicIFqueryForTopic(String query)EXPERIMENTAL: Returns a topic from the first column in the first row of the query result.TopicIFqueryForTopic(String query, Map params)EXPERIMENTAL: Returns a topic from the first column in the first row of the query result.voidsetDeclarationContext(DeclarationContextIF context)voidsetDeclarations(String declarations)EXPERIMENTAL: Sets the parsing context for the query processor.intupdate(String query)EXPERIMENTAL: Runs an update statement, returning the number of changed rows.intupdate(String query, Map params)EXPERIMENTAL: Runs an update statement, returning the number of changed rows.
-
-
-
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(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 Map makeParams(String name, Object value)
EXPERIMENTAL: Utility method for creating parameter maps.
-
queryForList
public List queryForList(String query)
EXPERIMENTAL: Runs the query, and returns a the single value in each row.
-
queryForList
public List queryForList(String query, Map params)
EXPERIMENTAL: Runs the query, and returns a the single value in each row.
-
queryForList
public List queryForList(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 List queryForList(String query, RowMapperIF mapper, 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 Map queryForMap(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 Map queryForMap(String query, 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 List queryForMaps(String query)
EXPERIMENTAL: Returns a list of Mapvalues for each row in the query, with the variable name as the key. - Since:
- 5.1.0
-
queryForMaps
public List queryForMaps(String query, Map params)
EXPERIMENTAL: Returns a list of Mapvalues for each row in the query, with the variable name as the key.
-
isTrue
public boolean isTrue(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(String query, 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 String queryForString(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 String queryForString(String query, 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(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(String query, 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 Object queryForObject(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 Object queryForObject(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 Object queryForObject(String query, 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 Object queryForObject(String query, RowMapperIF mapper, 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(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
-
-