KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > xml > querying > impl > xtas > helper > SimpleStatementHelperImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5
6 package org.exoplatform.services.xml.querying.impl.xtas.helper;
7
8 import org.exoplatform.services.xml.querying.InvalidStatementException;
9 import org.exoplatform.services.xml.querying.Statement;
10 import org.exoplatform.services.xml.querying.XMLData;
11 import org.exoplatform.services.xml.querying.XMLWellFormedData;
12 import org.exoplatform.services.xml.querying.helper.SimpleStatementHelper;
13 import org.exoplatform.services.xml.querying.impl.xtas.QueryType;
14 import org.exoplatform.services.xml.querying.impl.xtas.SimpleStatement;
15 import org.exoplatform.services.xml.querying.impl.xtas.UniFormTree;
16 import org.exoplatform.services.xml.querying.impl.xtas.UniFormTreeFragment;
17 import org.exoplatform.services.xml.querying.impl.xtas.WellFormedUniFormTree;
18
19
20
21 /**
22  * Created by The eXo Platform SARL .
23  *
24  * Just set of static helpers to prepare xtas's SimpleStatement objects
25  *
26 * @author Gennady Azarenkov
27  * @version $Id: SimpleStatementHelperImpl.java 566 2005-01-25 12:50:49Z kravchuk $
28  */

29
30 public class SimpleStatementHelperImpl implements SimpleStatementHelper
31 {
32   /**
33    * Select statement helper
34    * @param match - XPath expression
35    * @return Statement object
36    */

37    public Statement select(String JavaDoc match) throws InvalidStatementException
38    {
39       return select(match, null, null);
40    }
41
42   /**
43    * Select statement helper
44    * @param match - XPath expression
45    * @param resource - XTAS resource identifier (will be used for both source and destination)
46    * @return Statement object
47    */

48     public Statement select(String JavaDoc match, String JavaDoc resource) throws InvalidStatementException
49    {
50       return select(match, resource, resource);
51    }
52
53   /**
54    * Select statement helper
55    * @param match - XPath expression
56    * @param source - XTAS resource identifier for query source
57    * @param destination - XTAS resource identifier for query destination
58    * @return Statement object
59    */

60    public Statement select(String JavaDoc match, String JavaDoc source, String JavaDoc destination) throws InvalidStatementException
61    {
62       return new SimpleStatement( QueryType.SELECT, match, (UniFormTreeFragment)null, source, destination);
63    }
64
65   /**
66    * Delete statement helper
67    * @param match - XPath expression
68    * @return Statement object
69    */

70    public Statement delete(String JavaDoc match) throws InvalidStatementException
71    {
72        return delete(match, null, null);
73    }
74
75   /**
76    * Delete statement helper
77    * @param match - XPath expression
78    * @param resource - XTAS resource identifier (will be used for both source and destination)
79    * @return Statement object
80    */

81    public Statement delete(String JavaDoc match, String JavaDoc resource) throws InvalidStatementException
82    {
83        return delete(match, resource, resource);
84    }
85
86   /**
87    * Delete statement helper
88    * @param match - XPath expression
89    * @param source - XTAS resource identifier for query source
90    * @param destination - XTAS resource identifier for query destination
91    * @return Statement object
92    */

93    public Statement delete(String JavaDoc match, String JavaDoc source, String JavaDoc destination) throws InvalidStatementException
94    {
95         return new SimpleStatement( QueryType.DELETE, match, (UniFormTreeFragment)null, source, destination);
96    }
97
98   /**
99    * Append statement helper
100    * @param match - XPath expression
101    * @param value - new node(set) value
102    * @return Statement object
103    */

104    public Statement append(String JavaDoc match, XMLData value) throws InvalidStatementException
105    {
106         return append(match, null, null, (UniFormTree)value);
107    }
108
109   /**
110    * Append statement helper
111    * @param match - XPath expression
112    * @param resource - XTAS resource identifier (will be used for both source and destination)
113    * @param value - new node(set) value
114    * @return Statement object
115    */

116    public Statement append(String JavaDoc match, String JavaDoc resource, XMLData value) throws InvalidStatementException
117    {
118         return append(match, resource, resource, (UniFormTree)value);
119    }
120
121   /**
122    * Append statement helper
123    * @param match - XPath expression
124    * @param source - XTAS resource identifier for query source
125    * @param destination - XTAS resource identifier for query destination
126    * @param value - new node(set) value
127    * @return Statement object
128    */

129    public Statement append(String JavaDoc match, String JavaDoc source, String JavaDoc destination, XMLData value) throws InvalidStatementException
130    {
131        return new SimpleStatement( QueryType.APPEND, match, (UniFormTree)value, source, destination);
132    }
133
134   /**
135    * Update statement helper
136    * @param match - XPath expression
137    * @param value - new node(set) value
138    * @return Statement object
139    */

140    public Statement update(String JavaDoc match, XMLData value) throws InvalidStatementException
141    {
142        return update(match, null, null, (UniFormTree)value);
143    }
144
145   /**
146    * Update statement helper
147    * @param match - XPath expression
148    * @param resource - XTAS resource identifier (will be used for both source and destination)
149    * @param value - new node(set) value
150    * @return Statement object
151    */

152    public Statement update(String JavaDoc match, String JavaDoc resource, XMLData value) throws InvalidStatementException
153    {
154        return update(match, resource, resource, (UniFormTree)value);
155    }
156
157   /**
158    * Update statement helper
159    * @param match - XPath expression
160    * @param source - XTAS resource identifier for query source
161    * @param destination - XTAS resource identifier for query destination
162    * @param value - new node(set) value
163    * @return Statement object
164    */

165    public Statement update(String JavaDoc match, String JavaDoc source, String JavaDoc destination, XMLData value) throws InvalidStatementException
166    {
167        return new SimpleStatement( QueryType.UPDATE, match, (UniFormTree)value, source, destination);
168    }
169
170   /**
171    * Create Resource statement helper
172    * @param resource - XTAS resource identifier
173    * @param initTree - initial node
174    * @return Statement object
175    */

176    public Statement create(String JavaDoc resource, XMLWellFormedData initTree) throws InvalidStatementException
177    {
178        return new SimpleStatement( QueryType.CREATE, resource, (WellFormedUniFormTree)initTree, null, resource);
179    }
180
181   /**
182    * Drop Resource statement helper
183    * @param resource - XTAS resource identifier
184    * @return Statement object
185    */

186    public Statement drop(String JavaDoc resource) throws InvalidStatementException
187    {
188        return new SimpleStatement( QueryType.DROP, resource, (UniFormTreeFragment)null, null, resource);
189    }
190
191 }
192
Popular Tags