001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.jaxws.message.util;
020:
021: import org.apache.axis2.jaxws.ExceptionFactory;
022: import org.apache.axis2.jaxws.i18n.Messages;
023:
024: import javax.xml.namespace.NamespaceContext;
025: import javax.xml.namespace.QName;
026: import javax.xml.stream.Location;
027: import javax.xml.stream.XMLStreamException;
028: import javax.xml.stream.XMLStreamReader;
029: import javax.xml.ws.WebServiceException;
030:
031: /**
032: * Reader In many situations, you want the ability to reset an XMLStreamReader. (Or at least ask if
033: * the XMLStreamReader is resettable).
034: * <p/>
035: * The Reader abstract class: - accepts an XMLStreamReader - provides reset() and isResettable()
036: * methods Adds support resettable support to XMLStreamReader
037: * <p/>
038: * Derived classes must pass the initial reader to the constructor and indicate if it is resettable.
039: * Derived classes must also provide an implementation of the newReader() method if resettable.
040: */
041: public abstract class Reader implements XMLStreamReader {
042: protected XMLStreamReader reader;
043: private final boolean resettable;
044:
045: /**
046: * @param reader
047: * @param resettable
048: */
049: Reader(XMLStreamReader reader, boolean resettable) {
050: this .reader = reader;
051: this .resettable = resettable;
052: }
053:
054: /**
055: * Get a newReader from the Object
056: *
057: * @return XMLStreamReader
058: */
059: protected abstract XMLStreamReader newReader();
060:
061: /**
062: * isResettable
063: *
064: * @return true or false
065: */
066: public boolean isResettable() {
067: return resettable;
068: }
069:
070: public void reset() throws WebServiceException {
071: if (!resettable) {
072: throw ExceptionFactory.makeWebServiceException(Messages
073: .getMessage("resetReaderErr"));
074: }
075: reader = newReader();
076: }
077:
078: public void close() throws XMLStreamException {
079: reader.close();
080: }
081:
082: public int getAttributeCount() {
083: return reader.getAttributeCount();
084: }
085:
086: public String getAttributeLocalName(int arg0) {
087: return reader.getAttributeLocalName(arg0);
088: }
089:
090: public QName getAttributeName(int arg0) {
091: return reader.getAttributeName(arg0);
092: }
093:
094: public String getAttributeNamespace(int arg0) {
095: return reader.getAttributeNamespace(arg0);
096: }
097:
098: public String getAttributePrefix(int arg0) {
099: return reader.getAttributePrefix(arg0);
100: }
101:
102: public String getAttributeType(int arg0) {
103: return reader.getAttributeType(arg0);
104: }
105:
106: public String getAttributeValue(int arg0) {
107: return reader.getAttributeValue(arg0);
108: }
109:
110: public String getAttributeValue(String arg0, String arg1) {
111: return reader.getAttributeValue(arg0, arg1);
112: }
113:
114: public String getCharacterEncodingScheme() {
115: return reader.getCharacterEncodingScheme();
116: }
117:
118: public String getElementText() throws XMLStreamException {
119: return reader.getElementText();
120: }
121:
122: public String getEncoding() {
123: return reader.getEncoding();
124: }
125:
126: public int getEventType() {
127: return reader.getEventType();
128: }
129:
130: public String getLocalName() {
131: return reader.getLocalName();
132: }
133:
134: public Location getLocation() {
135: return reader.getLocation();
136: }
137:
138: public QName getName() {
139: return reader.getName();
140: }
141:
142: public NamespaceContext getNamespaceContext() {
143: return reader.getNamespaceContext();
144: }
145:
146: public int getNamespaceCount() {
147: return reader.getNamespaceCount();
148: }
149:
150: public String getNamespacePrefix(int arg0) {
151: return reader.getNamespacePrefix(arg0);
152: }
153:
154: public String getNamespaceURI() {
155: return reader.getNamespaceURI();
156: }
157:
158: public String getNamespaceURI(int arg0) {
159: return reader.getNamespaceURI(arg0);
160: }
161:
162: public String getNamespaceURI(String arg0) {
163: return reader.getNamespaceURI(arg0);
164: }
165:
166: public String getPIData() {
167: return reader.getPIData();
168: }
169:
170: public String getPITarget() {
171: return reader.getPITarget();
172: }
173:
174: public String getPrefix() {
175: return reader.getPrefix();
176: }
177:
178: public Object getProperty(String arg0)
179: throws IllegalArgumentException {
180: return reader.getProperty(arg0);
181: }
182:
183: public String getText() {
184: return reader.getText();
185: }
186:
187: public char[] getTextCharacters() {
188: return reader.getTextCharacters();
189: }
190:
191: public int getTextCharacters(int arg0, char[] arg1, int arg2,
192: int arg3) throws XMLStreamException {
193: return reader.getTextCharacters(arg0, arg1, arg2, arg3);
194: }
195:
196: public int getTextLength() {
197: return reader.getTextLength();
198: }
199:
200: public int getTextStart() {
201: return reader.getTextStart();
202: }
203:
204: public String getVersion() {
205: return reader.getVersion();
206: }
207:
208: public boolean hasName() {
209: return reader.hasName();
210: }
211:
212: public boolean hasNext() throws XMLStreamException {
213: return reader.hasNext();
214: }
215:
216: public boolean hasText() {
217: return reader.hasText();
218: }
219:
220: public boolean isAttributeSpecified(int arg0) {
221: return reader.isAttributeSpecified(arg0);
222: }
223:
224: public boolean isCharacters() {
225: return reader.isCharacters();
226: }
227:
228: public boolean isEndElement() {
229: return reader.isEndElement();
230: }
231:
232: public boolean isStandalone() {
233: return reader.isStandalone();
234: }
235:
236: public boolean isStartElement() {
237: return reader.isStartElement();
238: }
239:
240: public boolean isWhiteSpace() {
241: return reader.isWhiteSpace();
242: }
243:
244: public int next() throws XMLStreamException {
245: return reader.next();
246: }
247:
248: public int nextTag() throws XMLStreamException {
249: return reader.nextTag();
250: }
251:
252: public void require(int arg0, String arg1, String arg2)
253: throws XMLStreamException {
254: reader.require(arg0, arg1, arg2);
255: }
256:
257: public boolean standaloneSet() {
258: return reader.standaloneSet();
259: }
260:
261: }
|