uk.org.ogsadai.client.toolkit.activity.xmldb
Class XPathQuery

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.xmldb.XPathQuery

public class XPathQuery
extends Activity

This activity queries a resource/collection exposed by an XMLDB data service resource using an XPath expression.

It has no input and one output - the query result in XML. The format of the output is OGSA-DAI specific XML. For example:




xmlns:src="http://xml.apache.org/xindice/Query"
src:col="someCollection" src:key="someKey">





Author:
The OGSA-DAI Project Team

Field Summary
private static?java.lang.String COPYRIGHT_NOTICE
??????????Copyright statement
private ?java.lang.String mCollectionName
??????????Name of collection to query
private ?java.lang.String mExpression
??????????XPath expression
private ?java.util.Map mNamespaces
??????????Namespace bindings used in the XPath expression
private ?java.lang.String mResourceName
??????????Name of resource to query
?
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
?
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
?
Constructor Summary
XPathQuery()
??????????Constructs an XPath query request.
XPathQuery(java.lang.String?expression)
??????????Constructs a request to query a resource/collection using XPath.
?
Method Summary
protected ?java.lang.String generateXML()
??????????Generates the XML representing the activity.
?ActivityOutput getOutput()
??????????Gets the activity's only output - the XPath query result.
?org.xmldb.api.base.ResourceSet getResourceSet()
??????????Get the results of the query as a ResourceSet.
?void setCollectionName(java.lang.String?collectionName)
??????????Set the collection name.
?void setExpression(java.lang.String?expression)
??????????Set the XPath expression.
?void setNamespaceBinding(java.lang.String?prefix, java.lang.String?url)
??????????Add a binding from a namespace prefix used within the XPath query to a namespace URL.
?void setNamespaceBindings(java.util.Map?bindings)
??????????Add a collection of bindings from namespace prefixes used within the XPath query to namespace URLs.
?void setResourceName(java.lang.String?resourceName)
??????????Set the resource name.
?
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
addInput, addOutput, addOutputs, getDataResourceID, getInputParameters, getOutputParameters, getOutputs, replaceSpecialCharacters, setDataResourceID, setInput
?
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
getDataService, getName, getSession, setDataService, setSession
?
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
?

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

mExpression

private java.lang.String mExpression
XPath expression


mResourceName

private java.lang.String mResourceName
Name of resource to query


mCollectionName

private java.lang.String mCollectionName
Name of collection to query


mNamespaces

private java.util.Map mNamespaces
Namespace bindings used in the XPath expression

Constructor Detail

XPathQuery

public XPathQuery()
Constructs an XPath query request. The query expression must be set using setExpression All resources in the base collection and its sub-collections will be queried.


XPathQuery

public XPathQuery(java.lang.String?expression)
Constructs a request to query a resource/collection using XPath. All resources in the base collection and its sub-collections will be queried.

Parameters:
expression - XPath query expression.
Throws:
java.lang.IllegalArgumentException - If expression is null
Method Detail

setExpression

public void setExpression(java.lang.String?expression)
Set the XPath expression.

Parameters:
expression - XPath query expression.
Throws:
java.lang.IllegalArgumentException - If expression is null

setResourceName

public void setResourceName(java.lang.String?resourceName)
Set the resource name. The query will be executed on this resource. If this is set to null then the query will be executed on all the resources in the selected collection.

Parameters:
resourceName - The name of the resource or null.

setCollectionName

public void setCollectionName(java.lang.String?collectionName)
Set the collection name. The query will be executed within this collection. If this is set to null then the query will be executed within the base collection.

Parameters:
collectionName - The name of the collection or null.

setNamespaceBinding

public void setNamespaceBinding(java.lang.String?prefix,
                                java.lang.String?url)
Add a binding from a namespace prefix used within the XPath query to a namespace URL.

Parameters:
prefix - A namespace prefix.
url - A legal URL e.g. http://www.org/test
Throws:
java.lang.IllegalArgumentException - If prefix or url are null or url is not a legal URL.

setNamespaceBindings

public void setNamespaceBindings(java.util.Map?bindings)
Add a collection of bindings from namespace prefixes used within the XPath query to namespace URLs.

Parameters:
bindings - A collection of mappings from prefix strings to URL strings.
Throws:
java.lang.IllegalArgumentException - If bindings is null or contains entries whose prefix or URL are null or whose URLs are not legal.
See Also:
If prefix or url are null or url is not a legal URL.

getOutput

public ActivityOutput getOutput()
Gets the activity's only output - the XPath query result.

Returns:
the activity output.

getResourceSet

public org.xmldb.api.base.ResourceSet getResourceSet()
                                              throws NoActivityOutputException,
                                                     DataFormatException
Get the results of the query as a ResourceSet.

Returns:
ResourceSet.
Throws:
NoActivityOutputException - if there is no output data or the data has not yet been processed to this output or the activity that generates this output has not yet been executed.
DataFormatException - if the output from the activity cannot be parsed into a ResourceSet.

generateXML

protected java.lang.String generateXML()
Description copied from class: RequestComponent
Generates the XML representing the activity. This XML can then be inserted into a perform document that is sent to a data service.

Specified by:
generateXML in class Activity
Returns:
the XML for the activity