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 DeclarationContextIF
getDeclarationContext()
QueryProcessorIF
getQueryProcessor()
boolean
isTrue(String query)
EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows.boolean
isTrue(String query, Map params)
EXPERIMENTAL: Returns true if the query produces a row and false if the query produces no rows.Map
makeParams(String name, Object value)
EXPERIMENTAL: Utility method for creating parameter maps.List
queryForList(String query)
EXPERIMENTAL: Runs the query, and returns a the single value in each row.List
queryForList(String query, Map params)
EXPERIMENTAL: Runs the query, and returns a the single value in each row.List
queryForList(String query, RowMapperIF mapper)
EXPERIMENTAL: Runs the query, and calls the mapper for each row in the query result.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.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.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.List
queryForMaps(String query)
EXPERIMENTAL: Returns a list of Mapvalues for each row in the query, with the variable name as the key. 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. Object
queryForObject(String query)
EXPERIMENTAL: Returns the value in the first column in the first row of the query result.Object
queryForObject(String query, Map params)
EXPERIMENTAL: Returns the value in the first column in the first row of the query result.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.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.String
queryForString(String query)
EXPERIMENTAL: Returns a String from the first column in the first row of the query result.String
queryForString(String query, Map params)
EXPERIMENTAL: Returns a String from the first column in the first row of the query result.TopicIF
queryForTopic(String query)
EXPERIMENTAL: Returns a topic from the first column in the first row of the query result.TopicIF
queryForTopic(String query, Map params)
EXPERIMENTAL: Returns a topic from the first column in the first row of the query result.void
setDeclarationContext(DeclarationContextIF context)
void
setDeclarations(String declarations)
EXPERIMENTAL: Sets the parsing context for the query processor.int
update(String query)
EXPERIMENTAL: Runs an update statement, returning the number of changed rows.int
update(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
-
-