KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > om > OMElement


1 /*
2 * Copyright 2004,2005 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16 package org.apache.axis2.om;
17
18 import javax.xml.namespace.QName JavaDoc;
19 import javax.xml.stream.XMLStreamReader;
20 import java.util.Iterator JavaDoc;
21
22 /**
23  * Interface OMElement
24  */

25 public interface OMElement extends OMNode, OMContainer {
26     /**
27      * This will add child to the element. One must preserve the order of children, in this operation
28      * Tip : appending the new child is prefered
29      *
30      * @param omNode
31      */

32     public void addChild(OMNode omNode);
33
34     /**
35      * This will search for children with a given QName and will return an iterator to traverse through
36      * the OMNodes.
37      * This will match localName and namespaceURI only. localName only or namespaceURI only can also be given. But
38      * the other parameter should be set to null
39      * Example : If you want to get all the addressing headers, header.getChildrenWithName(new QName(AddressingNamespace, null))
40      * will do.
41      *
42      * @param elementQName
43      * @return
44      * @throws OMException
45      */

46     public Iterator JavaDoc getChildrenWithName(QName JavaDoc elementQName) throws OMException;
47
48     /**
49      * This will return the first matched child, return null if none found
50      *
51      * @param elementQName
52      * @return
53      * @throws OMException
54      */

55     public OMElement getFirstChildWithName(QName JavaDoc elementQName) throws OMException;
56
57
58     /**
59      * This returns a collection of this element.
60      * Children can be of types OMElement, OMText.
61      *
62      * @return
63      */

64     public Iterator JavaDoc getChildren();
65
66     /**
67      * THis will create a namespace in the current element scope
68      *
69      * @param uri
70      * @param prefix
71      * @return
72      */

73     public OMNamespace declareNamespace(String JavaDoc uri, String JavaDoc prefix);
74
75     /**
76      * @param namespace
77      * @return
78      */

79     public OMNamespace declareNamespace(OMNamespace namespace);
80
81     /**
82      * This will find a namespace with the given uri and prefix, in the scope of the hierarchy.
83      * This will start to find from the current element and goes up in the hiararchy until this finds one.
84      * If none is found, return null
85      *
86      * @param uri
87      * @param prefix
88      * @return
89      * @throws OMException
90      */

91     public OMNamespace findNamespace(String JavaDoc uri, String JavaDoc prefix)
92             throws OMException;
93
94     /**
95      *
96      * @return
97      * @throws OMException
98      */

99     public Iterator JavaDoc getAllDeclaredNamespaces() throws OMException;
100
101
102     /**
103      * This will help to search for an attribute with a given QName within this Element
104      *
105      * @param qname
106      * @return
107      * @throws OMException
108      */

109     public OMAttribute getFirstAttribute(QName JavaDoc qname) throws OMException;
110
111     /**
112      * This will return a List of OMAttributes
113      *
114      * @return
115      */

116     public Iterator JavaDoc getAttributes();
117
118     /**
119      *
120      * @param qname
121      * @return
122      */

123     public Iterator JavaDoc getAttributes(QName JavaDoc qname);
124
125     /**
126      * This will insert attribute to this element. Implementor can decide as to insert this
127      * in the front or at the end of set of attributes
128      *
129      * @param attr
130      * @return
131      */

132     public OMAttribute addAttribute(OMAttribute attr);
133
134     /**
135      * @param attributeName
136      * @param value
137      * @param ns - the namespace has to be one of the in scope namespace. i.e. the passed namespace
138      * must be declared in the parent element of this attribute or ancestors of the parent element of the attribute
139      * @return
140      */

141     public OMAttribute addAttribute(String JavaDoc attributeName, String JavaDoc value,
142                                        OMNamespace ns);
143
144     /**
145      * Method removeAttribute
146      *
147      * @param attr
148      */

149     public void removeAttribute(OMAttribute attr);
150
151     /**
152      * Method setBuilder
153      *
154      * @param wrapper
155      */

156     public void setBuilder(OMXMLParserWrapper wrapper);
157
158     /**
159      * Method getBuilder
160      *
161      * @return
162      */

163     public OMXMLParserWrapper getBuilder();
164
165     /**
166      * Set the first child
167      *
168      * @param node
169      */

170     public void setFirstChild(OMNode node);
171
172     /**
173      * Get the first child
174      *
175      * @return
176      */

177     public OMNode getFirstChild();
178
179     /**
180      * Convenience extension of the getFirstChild
181      * @return
182      */

183
184     public OMElement getFirstElement();
185
186
187
188     /**
189      * Returns the pull parser that will generate the pull
190      * events relevant to THIS element. Caching is on
191      *
192      * @return
193      */

194     public XMLStreamReader getXMLStreamReader();
195
196     /**
197      * Returns the pull parser that will generate the pull
198      * events relevant to THIS element.caching is off
199      *
200      *
201      * @return
202      */

203     public XMLStreamReader getXMLStreamReaderWithoutCaching();
204
205     /**
206      *
207      * @param text
208      */

209     public void setText(String JavaDoc text);
210     /**
211      * This will return the non-empty text children as a String
212      * @return
213      */

214     public String JavaDoc getText();
215
216     /**
217      * Method getLocalName
218      *
219      * @return
220      */

221     public String JavaDoc getLocalName();
222
223     /**
224      * Method setLocalName
225      *
226      * @param localName
227      */

228     public void setLocalName(String JavaDoc localName);
229
230     /**
231      * @return the OMNamespace object associated with this element
232      * @throws OMException
233      */

234     public OMNamespace getNamespace() throws OMException;
235
236     /**
237      * sets the Namespace
238      * @param namespace
239      */

240     public void setNamespace(OMNamespace namespace);
241
242     /**
243      * Get the Qname of this node
244      * @return
245      */

246     public QName JavaDoc getQName();
247
248
249 }
250
Popular Tags