1
2
3
4
5
6
7 package gov.noaa.gdsg.xmldbremote.xmldbClient;
8
9 /***
10 * Wraps the SOAP Calls in a XML:DB Database API compliant Xpath Query Service.
11 *
12 * @author tns
13 * @version $Id: XmldbClientXPathQueryService.java,v 1.2 2004/11/03 23:52:40 mrxtravis Exp $
14 */
15 public class XmldbClientXPathQueryService extends XmldbClientService implements org.xmldb.api.modules.XPathQueryService {
16
17
18
19 /*** Creates a new instance of XmldbClientXPathQueryService
20 * @param service The object reprenting the Service object on the server
21 * @param stub Used to make SOAP calls
22 * @param parentCollection The collection this Service belongs to.
23 */
24 public XmldbClientXPathQueryService(
25 gov.noaa.gdsg.xmldbremote.Service service,
26 gov.noaa.gdsg.xmldbremote.NmmrdbSoapBindingStub stub,
27 gov.noaa.gdsg.xmldbremote.xmldbClient.XmldbClientCollection parentCollection
28 ) {
29 super(service,stub,parentCollection);
30 }
31
32 /***Clears the name space.
33 *@throws org.xmldb.api.base.XMLDBException all is caught and rethrown as one.
34 */
35 public void clearNamespaces() throws org.xmldb.api.base.XMLDBException {
36 try {
37 stub.clearNamespaces(this.service);
38 } catch (java.rmi.RemoteException e){
39 throw new org.xmldb.api.base.XMLDBException(org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e);
40 }
41
42 }
43
44 /***
45 * Returns the namespace of this Service
46 * @param prefix The prefix (stupid comment eh?)
47 * @throws org.xmldb.api.base.XMLDBException all is caught and rethrown as one.
48 * @return The namespace.
49 */
50 public String getNamespace(String prefix) throws org.xmldb.api.base.XMLDBException {
51 try {
52 return stub.getNamespace(this.service, prefix);
53 } catch (java.rmi.RemoteException e){
54 throw new org.xmldb.api.base.XMLDBException(org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e);
55 }
56
57 }
58
59 /***
60 * Runs the specified XPath query.
61 * @return All resources that satisfy the specified query in the
62 * collection as a ResourceSet
63 * @param query The xpath query to execute.
64 * @throws org.xmldb.api.base.XMLDBException all is caught and rethrown as one.
65 */
66 public org.xmldb.api.base.ResourceSet query(String query) throws org.xmldb.api.base.XMLDBException {
67 try {
68 gov.noaa.gdsg.xmldbremote.ResourceSet resourceSetTransport = stub.query(this.service,query);
69 XmldbClientResourceSet resourceSet = new XmldbClientResourceSet(resourceSetTransport,stub, this.parentCollection);
70 return resourceSet;
71 } catch (java.rmi.RemoteException e){
72 throw new org.xmldb.api.base.XMLDBException(org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e);
73 }
74
75 }
76
77 /***
78 * Queries a result
79 * @return All resources that satisfy the query as a ResultSet
80 * @param id The id of the result
81 * @param query The query to run against the result
82 * @throws org.xmldb.api.base.XMLDBException All is caught and rethrown as one.
83 */
84 public org.xmldb.api.base.ResourceSet queryResource(String id, String query) throws org.xmldb.api.base.XMLDBException {
85 try {
86 return (org.xmldb.api.base.ResourceSet) stub.queryResource(this.service,id,query);
87 } catch (java.rmi.RemoteException e){
88 throw new org.xmldb.api.base.XMLDBException(
89 org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e.toString());
90 }
91 }
92
93 /***
94 * Removes the namespace
95 * @param prefix The prefix.
96 * @throws org.xmldb.api.base.XMLDBException All is caught and rethrown as one.
97 */
98 public void removeNamespace(String prefix) throws org.xmldb.api.base.XMLDBException {
99 try {
100 stub.removeNamespace(this.service, prefix);
101 } catch (java.rmi.RemoteException e){
102 throw new org.xmldb.api.base.XMLDBException(org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e);
103 }
104
105 }
106
107 /***Sets the namespace
108 *@param prefix The prefix
109 *@param uri The uri
110 *@throws org.xmldb.api.base.XMLDBException All is caught and rethrown as one.
111 */
112 public void setNamespace(String prefix, String uri) throws org.xmldb.api.base.XMLDBException {
113 try {
114 stub.setNamespace(this.service, prefix, uri);
115 } catch (java.rmi.RemoteException e){
116 throw new org.xmldb.api.base.XMLDBException(org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e);
117 }
118
119 }
120
121 }