001 /** 002 * 003 * Copyright 2005 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.codehaus.activesoap.util; 019 020 import org.w3c.dom.Node; 021 import org.apache.xmlbeans.xml.stream.XMLInputStream; 022 import org.apache.xmlbeans.impl.inst2xsd.util.Type; 023 024 import javax.xml.stream.XMLStreamReader; 025 import javax.xml.stream.XMLEventReader; 026 import javax.xml.stream.XMLStreamException; 027 import javax.xml.stream.Location; 028 import javax.xml.stream.events.StartElement; 029 import javax.xml.stream.events.XMLEvent; 030 import javax.xml.namespace.QName; 031 import javax.xml.namespace.NamespaceContext; 032 import java.io.File; 033 034 import javanet.staxutils.helpers.ListEventReader; 035 036 /** 037 * An {@link XMLStreamReader} implementation which delegates to 038 * an {@link XMLEventReader} instance for its content 039 * 040 * @version $Revision: 1.1 $ 041 */ 042 public class XMLEventStreamReader implements XMLStreamReader { 043 private XMLEventReader reader; 044 private XMLEvent nextEvent; 045 private NamespaceContext context; 046 047 public XMLEventStreamReader(XMLEventReader reader) throws XMLStreamException { 048 this.reader = reader; 049 nextEvent = reader.nextEvent(); 050 } 051 052 public void close() throws XMLStreamException { 053 reader.close(); 054 } 055 056 public int getAttributeCount() { 057 return 0; /** TODO */ 058 } 059 060 public String getAttributeLocalName(int index) { 061 return null; /** TODO */ 062 } 063 064 public QName getAttributeName(int index) { 065 return null; /** TODO */ 066 } 067 068 public String getAttributeNamespace(int index) { 069 return null; /** TODO */ 070 } 071 072 public String getAttributePrefix(int index) { 073 return null; /** TODO */ 074 } 075 076 public String getAttributeType(int index) { 077 return null; /** TODO */ 078 } 079 080 public String getAttributeValue(int index) { 081 return null; /** TODO */ 082 } 083 084 public String getAttributeValue(String namespaceURI, String localName) { 085 return null; /** TODO */ 086 } 087 088 public String getCharacterEncodingScheme() { 089 return null; /** TODO */ 090 } 091 092 public String getElementText() throws XMLStreamException { 093 return null; /** TODO */ 094 } 095 096 public String getEncoding() { 097 return null; /** TODO */ 098 } 099 100 public int getEventType() { 101 return nextEvent.getEventType(); 102 } 103 104 public String getLocalName() { 105 return getName().getLocalPart(); 106 } 107 108 public Location getLocation() { 109 return nextEvent.getLocation(); 110 } 111 112 public QName getName() { 113 if (nextEvent.isStartElement()) { 114 return nextEvent.asStartElement().getName(); 115 } 116 else if (nextEvent.isEndElement()) { 117 return nextEvent.asEndElement().getName(); 118 } 119 return null; 120 } 121 122 public NamespaceContext getNamespaceContext() { 123 return context; 124 } 125 126 public int getNamespaceCount() { 127 return 0; /** TODO */ 128 } 129 130 public String getNamespacePrefix(int index) { 131 return null; /** TODO */ 132 } 133 134 public String getNamespaceURI() { 135 return getName().getNamespaceURI(); 136 } 137 138 public String getNamespaceURI(int index) { 139 return null; /** TODO */ 140 } 141 142 public String getNamespaceURI(String prefix) { 143 return null; /** TODO */ 144 } 145 146 public String getPIData() { 147 return null; /** TODO */ 148 } 149 150 public String getPITarget() { 151 return null; /** TODO */ 152 } 153 154 public String getPrefix() { 155 return getName().getPrefix(); 156 } 157 158 public Object getProperty(String name) throws IllegalArgumentException { 159 return null; /** TODO */ 160 } 161 162 public String getText() { 163 return nextEvent.asCharacters().getData(); 164 } 165 166 public char[] getTextCharacters() { 167 return nextEvent.asCharacters().getData().toCharArray(); 168 } 169 170 public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException { 171 return 0; /** TODO */ 172 } 173 174 public int getTextLength() { 175 return getText().length(); 176 } 177 178 public int getTextStart() { 179 return 0; 180 } 181 182 public String getVersion() { 183 return null; /** TODO */ 184 } 185 186 public boolean hasName() { 187 return nextEvent != null && nextEvent.isStartElement(); 188 } 189 190 public boolean hasNext() throws XMLStreamException { 191 if (reader.hasNext()) { 192 nextEvent = reader.nextEvent(); 193 return true; 194 } 195 return false; 196 } 197 198 public boolean hasText() { 199 return nextEvent != null && nextEvent.isCharacters(); 200 } 201 202 public boolean isAttributeSpecified(int index) { 203 return false; /** TODO */ 204 } 205 206 public boolean isCharacters() { 207 return nextEvent != null && nextEvent.isCharacters(); 208 } 209 210 public boolean isEndElement() { 211 return nextEvent != null && nextEvent.isEndElement(); 212 } 213 214 public boolean isStandalone() { 215 return false; /** TODO */ 216 } 217 218 public boolean isStartElement() { 219 return nextEvent != null && nextEvent.isStartElement(); 220 } 221 222 public boolean isWhiteSpace() { 223 return nextEvent != null && nextEvent.isCharacters() && nextEvent.asCharacters().isWhiteSpace(); 224 } 225 226 public int next() throws XMLStreamException { 227 return nextEvent.getEventType(); 228 } 229 230 public int nextTag() throws XMLStreamException { 231 return nextEvent.getEventType(); 232 } 233 234 public void require(int type, String namespaceURI, String localName) throws XMLStreamException { 235 /** TODO */ 236 } 237 238 public boolean standaloneSet() { 239 return false; /** TODO */ 240 } 241 242 protected StartElement startElement() { 243 return nextEvent.asStartElement(); 244 } 245 } 246 247