org.optimizationservices.oscommon.util
Class XQueryUtil

java.lang.Object
  extended by org.optimizationservices.oscommon.util.XQueryUtil

public class XQueryUtil
extends java.lang.Object

The XQueryUtil class contains methods for performing common basic XQuery-related operations used by various classes in the Optimization Services (OS) framework.

Since:
OS1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin

Constructor Summary
XQueryUtil(java.lang.String xqueryString, java.lang.String xmlData, boolean isFile)
          constructor.
 
Method Summary
static void main(java.lang.String[] args)
          main for test purposes.
static java.lang.String printQueryResult(java.util.List queryResult)
          Print out the query result to a string for easy reading.
 java.util.List query(java.util.HashMap variables)
          Use an XQuery string to query xml data.
 java.lang.String queryFirst(java.util.HashMap variables)
          Use an XQuery string to query xml data and return the first found object in a string.
static java.lang.String queryResultToString(java.util.List queryResult)
          Convert a query result to a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XQueryUtil

public XQueryUtil(java.lang.String xqueryString,
                  java.lang.String xmlData,
                  boolean isFile)
constructor.

Parameters:
xqueryString - holds the XQuery string that can be used to query xml data.
xmlData - holds the name of the xml data to be queried. If null, the xml data will be located from within the xquery, i.e. the doc(...) section of xquery. The xmlData can either be a file name or an actual string that holds the xml data.
isFile - holds whether the xmlData is a a file name or, otherwise (if false) an actual string that holds the xml data.
Method Detail

query

public java.util.List query(java.util.HashMap variables)
Use an XQuery string to query xml data.

Parameters:
variables - holds a hashmap of external variable name-value pairs to be fed into the the xquery.
Returns:
a list of query result in type java.util.List. If there is an error querying, returns null.

queryFirst

public java.lang.String queryFirst(java.util.HashMap variables)
Use an XQuery string to query xml data and return the first found object in a string.

Parameters:
variables - holds a hashmap of external variable name-value paris to be fed into the the xquery.
Returns:
a list of query result in type java.util.List. If there is an error querying, returns null.

printQueryResult

public static java.lang.String printQueryResult(java.util.List queryResult)
Print out the query result to a string for easy reading.

Parameters:
queryResult - holds a list of query result in type java.util.List.
Returns:
the query result in a string for easy reading.

queryResultToString

public static java.lang.String queryResultToString(java.util.List queryResult)
Convert a query result to a string.

Parameters:
queryResult - holds a list of query result in type java.util.List.
Returns:
a string representation of the query result.

main

public static void main(java.lang.String[] args)
main for test purposes.

Parameters:
argv - command line arguments.