本文整理了Java中net.ontopia.topicmaps.query.core.QueryResultIF.close
方法的一些代码示例,展示了QueryResultIF.close
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryResultIF.close
方法的具体详情如下:
包路径:net.ontopia.topicmaps.query.core.QueryResultIF
类名称:QueryResultIF
方法名:close
[英]PUBLIC: Closes the query result, which allows it to free its resources.
[中]
代码示例来源:origin: ontopia/ontopia
@Override
public void write(OutputStream outputStream) throws IOException {
try {
super.write(outputStream);
} finally {
result.close();
}
}
};
代码示例来源:origin: ontopia/ontopia
private boolean istrue(ParsedQueryIF pquery, TopicIF topic) {
QueryResultIF result = null;
try {
result = pquery.execute(Collections.singletonMap("topic", topic));
return result.next();
} catch (InvalidQueryException e) {
throw new OntopiaRuntimeException(e);
} finally {
if (result != null)
result.close();
}
}
代码示例来源:origin: net.ontopia/ontopia-webed
private void runQuery(ParsedQueryIF query, Map args) throws InvalidQueryException {
log.debug("Running query for: " + args.get("topic"));
QueryResultIF result = query.execute(args);
while (result.next()) {
for (int ix = 0; ix < result.getWidth(); ix++) {
log.debug("Removing: " + result.getValue(ix));
((TMObjectIF) result.getValue(ix)).remove();
}
}
result.close();
}
代码示例来源:origin: net.ontopia/ontopoly-editor
/**
* EXPERIMENTAL: Returns true if the query produces a row and
* false if the query produces no rows.
*/
public boolean isTrue(String query, Map<String,?> params) {
QueryResultIF result = null;
try {
result = execute(query, params);
return result.next();
} catch (InvalidQueryException e) {
throw new OntopiaRuntimeException(e);
} finally {
if (result != null)
result.close();
}
}
代码示例来源:origin: ontopia/ontopia
private Object getSortKey(TopicIF topic, ParsedQueryIF skquery) {
if (topic == null) return null;
QueryResultIF result = null;
try {
result = skquery.execute(Collections.singletonMap("topic", topic));
if (result.next())
return result.getValue(0);
else
return null;
} catch (InvalidQueryException e) {
throw new OntopiaRuntimeException(e);
} finally {
if (result != null)
result.close();
}
}
代码示例来源:origin: ontopia/ontopia
/**
* EXPERIMENTAL: Returns true if the query produces a row and
* false if the query produces no rows.
*/
public boolean isTrue(String query, Map<String,?> params) {
QueryResultIF result = null;
try {
result = execute(query, params);
return result.next();
} catch (InvalidQueryException e) {
throw new OntopiaRuntimeException(e);
} finally {
if (result != null)
result.close();
}
}
代码示例来源:origin: ontopia/ontopia
private static Set<TopicIF> queryForSet(TopicMapIF tm, String query)
throws InvalidQueryException {
Set<TopicIF> set = new CompactHashSet<TopicIF>();
QueryProcessorIF proc = QueryUtils.getQueryProcessor(tm);
QueryResultIF result = proc.execute(query);
while (result.next())
set.add((TopicIF) result.getValue(0));
result.close();
return set;
}
代码示例来源:origin: net.ontopia/ontopia-classify
public boolean isClassifiable(TopicIF topic) {
if (topic == null) return false;
TopicMapIF tm = topic.getTopicMap();
if (tm == null) return false;
QueryProcessorIF qp = QueryUtils.getQueryProcessor(tm);
try {
QueryResultIF qr = qp.execute("subject-identifier($PAPERTYPE, \"http://psi.example.org/paper\"), instance-of(%topic%, $PAPERTYPE)?", Collections.singletonMap("topic", topic));
try {
return qr.next();
} finally {
qr.close();
}
} catch (Throwable e) {
throw new OntopiaRuntimeException(e);
}
}
代码示例来源:origin: net.ontopia/ontopia-classify
public boolean isClassifiable(TopicIF topic) {
if (topic == null) return false;
TopicMapIF tm = topic.getTopicMap();
if (tm == null) return false;
QueryProcessorIF qp = QueryUtils.getQueryProcessor(tm);
try {
QueryResultIF qr = qp.execute("import \"classify.tl\" as classify classify:is-classifiable(%topic%)?", Collections.singletonMap("topic", topic));
try {
return qr.next();
} finally {
qr.close();
}
} catch (Throwable e) {
throw new OntopiaRuntimeException(e);
}
}
代码示例来源:origin: ontopia/ontopia
protected void findAny(String query) throws InvalidQueryException {
// verify that we do not get any parse or query errors
QueryResultIF result = processor.execute(query);
try {
while (result.next()) {
// just loop over rows for the sake of it
}
} finally {
result.close();
}
}
代码示例来源:origin: ontopia/ontopia
protected void getParseError(String query, Map parameters) {
QueryResultIF result = null;
try {
result = processor.execute(query, parameters);
fail("query '" + query + "' parsed OK, but shouldn't have");
} catch (InvalidQueryException e) {
} finally {
if (result != null) result.close();
}
}
代码示例来源:origin: net.ontopia/ontopia-db2tm
private void accumulateObjectsFromQuery(String query, Map params, Collection objects) {
QueryProcessorIF qp = getQueryProcessor();
try {
QueryResultIF qr = (params == null ?
qp.execute(query, getDeclarationContext()) :
qp.execute(query, params, getDeclarationContext()));
try {
while (qr.next()) {
objects.add(qr.getValue(0));
}
} finally {
qr.close();
}
} catch (InvalidQueryException e) {
throw new DB2TMConfigException("Invalid extent query: " + query, e);
}
}
代码示例来源:origin: net.ontopia/ontopoly-editor
protected static void removeObjects(TopicMapIF topicMap, DeclarationContextIF dc, String removalQuery) throws InvalidQueryException {
QueryProcessorIF qp = QueryUtils.getQueryProcessor(topicMap);
QueryResultIF qr = null;
try {
qr = qp.execute(removalQuery, dc);
while (qr.next()) {
TMObjectIF tmobject = (TMObjectIF)qr.getValue(0);
if (tmobject.getTopicMap() != null) {
tmobject.remove();
}
}
} finally {
if (qr != null) qr.close();
}
}
代码示例来源:origin: ontopia/ontopia
protected static void removeObjects(TopicMapIF topicMap, DeclarationContextIF dc, String removalQuery) throws InvalidQueryException {
QueryProcessorIF qp = QueryUtils.getQueryProcessor(topicMap);
QueryResultIF qr = null;
try {
qr = qp.execute(removalQuery, dc);
while (qr.next()) {
TMObjectIF tmobject = (TMObjectIF)qr.getValue(0);
if (tmobject.getTopicMap() != null) {
tmobject.remove();
}
}
} finally {
if (qr != null) qr.close();
}
}
代码示例来源:origin: ontopia/ontopia
protected void findNothing(String query) throws InvalidQueryException {
QueryResultIF result = processor.execute(query);
try {
assertTrue("found values, but shouldn't have",
!result.next());
} finally {
result.close();
}
}
代码示例来源:origin: ontopia/ontopia
protected void findNothing(String query, Map args) throws InvalidQueryException {
QueryResultIF result = processor.execute(query, args);
try {
assertTrue("found values, but shouldn't have",
!result.next());
} finally {
result.close();
}
}
代码示例来源:origin: ontopia/ontopia
private int queryCount(String query) {
QueryProcessorIF queryProcessor = QueryUtils.getQueryProcessor(transaction.getTopicMap());
QueryResultIF result = null;
try {
result = queryProcessor.execute(query);
if (result.getWidth() == 0) throw new OntopiaRuntimeException("Counting query did not produce a result");
if (result.next()) {
return ((Integer) result.getValue(0)).intValue();
}
return 0;
} catch (InvalidQueryException iqe) {
throw new OntopiaRuntimeException("Invalid query in statistics index: " + iqe.getMessage(), iqe);
} finally {
if (result != null) result.close();
}
}
代码示例来源:origin: net.ontopia/ontopia-webed
private boolean noOtherReference(OccurrenceIF occurrence) {
try {
QueryProcessorIF processor =
QueryUtils.getQueryProcessor(occurrence.getTopicMap());
QueryResultIF result = processor.execute(
"select $OBJ from " +
"resource($OBJ, \"" + occurrence.getLocator().getAddress() + "\"), " +
"$OBJ /= @" + occurrence.getObjectId() + "?");
boolean other = result.next();
result.close();
return other;
} catch (InvalidQueryException e) {
throw new ActionRuntimeException(e);
}
}
代码示例来源:origin: ontopia/ontopia
public void testOptionalClauseOrdering() throws InvalidQueryException, IOException {
load("opera.ltm");
List matches = new ArrayList();
QueryResultIF result = processor.execute("{ premiere-date($OPERA, $DATE) }, " +
"date-of-birth($PERSON, $DATE)?");
while (result.next())
addMatch(matches,
"OPERA", result.getValue("OPERA"),
"DATE", result.getValue("DATE"),
"PERSON", result.getValue("PERSON"));
result.close();
verifyQuery(matches, "date-of-birth($PERSON, $DATE), " +
"{ premiere-date($OPERA, $DATE) }?");
}
代码示例来源:origin: ontopia/ontopia
/**
* Tests whether the given query returns a single row with no columns,
* i.e. a query match with no unbound variables.
* @param query The query to test.
*/
protected void verifyQuery(String query) throws InvalidQueryException {
// verify that we do not get any parse or query errors
QueryResultIF result = processor.execute(query);
try {
assertTrue(result.next());
assertEquals(0, result.getWidth());
assertFalse(result.next());
} finally {
result.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!