コード例 #1
0
ファイル: QueryService.java プロジェクト: GerritBoers/exist
 /**
  * Get no more than one item that matches the given query in the context of this object.
  *
  * @param query the query to match
  * @param params
  * @return the item that matches this query, or <code>Item.NULL</code> if none
  */
 public Item optional(String query, Object... params) {
   ItemList result = executeQuery(query, ZERO_OR_ONE, params);
   assert result.size() <= 1 : "expected zero or one results, got " + result.size();
   return result.size() == 0 ? Item.NULL : result.get(0);
 }
コード例 #2
0
ファイル: QueryService.java プロジェクト: GerritBoers/exist
 /**
  * Get the one and only item that matches the given query in the context of this object.
  *
  * @param query the query to match
  * @param params
  * @return the unique item that matches the query
  */
 public Item single(String query, Object... params) {
   ItemList result = executeQuery(query, EXACTLY_ONE, params);
   assert result.size() == 1 : "expected single result, got " + result.size();
   return result.get(0);
 }