first commit

This commit is contained in:
MaddoScientisto 2026-03-14 20:04:39 +01:00
commit 4d332ef662
27586 changed files with 3281783 additions and 0 deletions

View file

@ -0,0 +1,10 @@
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_01-b08 (Sun Microsystems Inc.)
Specification-Title: Streaming APIs for XML (JSR 173)
Specification-Version: 1.0
Implementation-Title: Sun Java Streaming XML Parser (SJSXP)
Implementation-Version: 1.0-b26
Implementation-Vendor: Sun Microsystems, Inc.
Extension-Name: com.sun.xml.stream

View file

@ -0,0 +1 @@
com.sun.xml.stream.events.ZephyrEventFactory

View file

@ -0,0 +1 @@
com.sun.xml.stream.ZephyrParserFactory

View file

@ -0,0 +1 @@
com.sun.xml.stream.ZephyrWriterFactory

View file

@ -0,0 +1,93 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.CharBuffer;
public abstract class BufferManager {
protected boolean endOfStream = false;
static boolean DEBUG = false;
public static BufferManager getBufferManager(XMLInputSource inputSource) throws IOException {
InputStream stream = inputSource.getByteStream();
if (stream instanceof FileInputStream) {
if (DEBUG)
System.out.println("Using FileBufferManager");
return new FileBufferManager((FileInputStream)stream, inputSource.getEncoding());
}
if (DEBUG)
System.out.println("Using StreamBufferManager");
return new StreamBufferManager(stream, inputSource.getEncoding());
}
public abstract boolean getMore() throws IOException;
public abstract CharBuffer getCharBuffer();
public abstract boolean arrangeCapacity(int paramInt) throws IOException;
public boolean endOfStream() {
return this.endOfStream;
}
public abstract void close() throws IOException;
public abstract void setEncoding(String paramString) throws IOException;
protected Object[] getEncodingName(byte[] b4, int count) {
if (count < 2)
return new Object[] { "UTF-8", null };
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
if (b0 == 254 && b1 == 255)
return new Object[] { "UTF-16BE", new Boolean(true) };
if (b0 == 255 && b1 == 254)
return new Object[] { "UTF-16LE", new Boolean(false) };
if (count < 3)
return new Object[] { "UTF-8", null };
int b2 = b4[2] & 0xFF;
if (b0 == 239 && b1 == 187 && b2 == 191)
return new Object[] { "UTF-8", null };
if (count < 4)
return new Object[] { "UTF-8", null };
int b3 = b4[3] & 0xFF;
if (b0 == 0 && b1 == 0 && b2 == 0 && b3 == 60)
return new Object[] { "ISO-10646-UCS-4", new Boolean(true) };
if (b0 == 60 && b1 == 0 && b2 == 0 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", new Boolean(false) };
if (b0 == 0 && b1 == 0 && b2 == 60 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", null };
if (b0 == 0 && b1 == 60 && b2 == 0 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", null };
if (b0 == 0 && b1 == 60 && b2 == 0 && b3 == 63)
return new Object[] { "UTF-16BE", new Boolean(true) };
if (b0 == 60 && b1 == 0 && b2 == 63 && b3 == 0)
return new Object[] { "UTF-16LE", new Boolean(false) };
if (b0 == 76 && b1 == 111 && b2 == 167 && b3 == 148)
return new Object[] { "CP037", null };
return new Object[] { "UTF-8", null };
}
public static void main(String[] args) {
try {
File file = new File(args[0]);
System.out.println("url parameter = " + file.toURI().toString());
URL url = new URL(file.toURI().toString());
XMLInputSource inputSource = new XMLInputSource(null, null, null, new FileInputStream(file), "UTF-8");
BufferManager sb = getBufferManager(inputSource);
CharBuffer cb = sb.getCharBuffer();
int i = 0;
while (sb.getMore())
System.out.println("Loop " + i++ + " = " + sb.getCharBuffer());
System.out.println("End of stream reached = " + sb.endOfStream());
System.out.println("Total no. of loops required = " + i);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View file

@ -0,0 +1,311 @@
package com.sun.xml.stream;
import java.util.Enumeration;
import java.util.NoSuchElementException;
public final class Constants {
public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern();
public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern();
public static final String ESCAPE_CHARACTERS = "escapeCharacters";
public static final String STAX_PROPERTIES = "stax-properties";
public static final String STAX_ENTITY_RESOLVER_PROPERTY = "internal/stax-entity-resolver";
public static final String STAX_REPORT_CDATA_EVENT = "report-cdata-event";
public static final String ZEPHYR_PROPERTY_PREFIX = "http://java.sun.com/xml/stream/properties/";
public static final String READER_IN_DEFINED_STATE = "http://java.sun.com/xml/stream/properties/reader-in-defined-state";
public static final String REUSE_INSTANCE = "reuse-instance";
protected static final String ENTITY_MANAGER = "http://apache.org/xml/properties/internal/entity-manager";
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/";
public static final String NAMESPACES_FEATURE = "namespaces";
public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes";
public static final String STRING_INTERNING_FEATURE = "string-interning";
public static final String VALIDATION_FEATURE = "validation";
public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities";
public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities";
public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD";
public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/";
public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler";
public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler";
public static final String DOM_NODE_PROPERTY = "dom-node";
public static final String XML_STRING_PROPERTY = "xml-string";
public static final String JAXP_PROPERTY_PREFIX = "http://java.sun.com/xml/jaxp/properties/";
public static final String SCHEMA_SOURCE = "schemaSource";
public static final String SCHEMA_LANGUAGE = "schemaLanguage";
public static final String INCLUDE_COMMENTS_FEATURE = "include-comments";
public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes";
public static final String LOAD_AS_INFOSET = "load-as-infoset";
public static final String DOM_CANONICAL_FORM = "canonical-form";
public static final String DOM_CDATA_SECTIONS = "cdata-sections";
public static final String DOM_COMMENTS = "comments";
public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = "charset-overrides-xml-encoding";
public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization";
public static final String DOM_ENTITIES = "entities";
public static final String DOM_INFOSET = "infoset";
public static final String DOM_NAMESPACES = "namespaces";
public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations";
public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = "supported-mediatypes-only";
public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema";
public static final String DOM_VALIDATE = "validate";
public static final String DOM_WHITESPACE_IN_ELEMENT_CONTENT = "whitespace-in-element-content";
public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content";
public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters";
public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization";
public static final String DOM_WELLFORMED = "well-formed";
public static final String DOM_SPLIT_CDATA = "split-cdata-sections";
public static final String DOM_IGNORE_CHAR_DENORMALIZATION = "ignore-unknown-character-denomalizations";
public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
public static final String DOM_XMLDECL = "xml-declaration";
public static final String DOM_UNKNOWNCHARS = "unknown-characters";
public static final String DOM_CERTIFIED = "certified";
public static final String DOM_ENTITY_RESOLVER = "entity-resolver";
public static final String DOM_ERROR_HANDLER = "error-handler";
public static final String DOM_SCHEMA_TYPE = "schema-type";
public static final String DOM_SCHEMA_LOCATION = "schema-location";
public static final String DOM_PSVI = "psvi";
public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/";
public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema";
public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value";
public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default";
public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking";
public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi";
public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic";
public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef";
public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef";
public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef";
public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings";
public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl";
public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error";
public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar";
public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd";
public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion";
public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes";
public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace";
public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values";
public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models";
public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes";
public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs";
public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs";
public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant";
public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/";
public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node";
public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name";
public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table";
public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter";
public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler";
public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler";
public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
public static final String SECURITY_MANAGER_PROPERTY = "security-manager";
public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver";
public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool";
public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory";
public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner";
public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner";
public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor";
public static final String VALIDATOR_PROPERTY = "internal/validator";
public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd";
public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema";
public static final String SCHEMA_LOCATION = "schema/external-schemaLocation";
public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation";
public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder";
public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context";
public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
public static final String ELEMENT_PSVI = "ELEMENT_PSVI";
public static final String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI";
public static final short XML_VERSION_1_0 = 1;
public static final short XML_VERSION_1_1 = 2;
private static final String[] fgSAXFeatures = new String[] { "namespaces", "namespace-prefixes", "string-interning", "validation", "external-general-entities", "external-parameter-entities" };
private static final String[] fgSAXProperties = new String[] { "declaration-handler", "lexical-handler", "dom-node", "xml-string" };
private static final String[] fgXercesFeatures = new String[] {
"validation/schema", "validation/schema-full-checking", "validation/dynamic", "validation/warn-on-duplicate-attdef", "validation/warn-on-undeclared-elemdef", "allow-java-encodings", "continue-after-fatal-error", "nonvalidating/load-dtd-grammar", "nonvalidating/load-external-dtd", "dom/create-entity-ref-nodes",
"dom/include-ignorable-whitespace", "validation/default-attribute-values", "validation/validate-content-models", "validation/validate-datatypes", "scanner/notify-char-refs" };
private static final String[] fgXercesProperties = new String[] {
"dom/current-element-node", "dom/document-class-name", "internal/symbol-table", "internal/error-handler", "internal/error-reporter", "internal/entity-manager", "internal/entity-resolver", "internal/grammar-pool", "internal/datatype-validator-factory", "internal/document-scanner",
"internal/dtd-scanner", "internal/validator", "schema/external-schemaLocation", "schema/external-noNamespaceSchemaLocation", "internal/validation-manager" };
private static final String[] zephyrFeatures = new String[] { "http://apache.org/xml/features/namespaces", "http://apache.org/xml/features/validation/warn-on-duplicate-attdef", "http://apache.org/xml/features/validation/warn-on-undeclared-elemdef", "http://apache.org/xml/features/allow-java-encodings" };
private static final String[] zephyrProperties = new String[] { "http://apache.org/xml/properties/internal/symbol-table", "http://apache.org/xml/properties/internal/error-reporter", "http://apache.org/xml/properties/internal/error-handler", "http://apache.org/xml/properties/internal/entity-resolver", "http://apache.org/xml/properties/internal/dtd-scanner" };
private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(new Object[0]);
public static Enumeration getZephyrFeatures() {
return new ArrayEnumeration(zephyrFeatures);
}
public static Enumeration getZephyrProperties() {
return new ArrayEnumeration(zephyrProperties);
}
public static Enumeration getSAXFeatures() {
return (fgSAXFeatures.length > 0) ? new ArrayEnumeration(fgSAXFeatures) : fgEmptyEnumeration;
}
public static Enumeration getSAXProperties() {
return (fgSAXProperties.length > 0) ? new ArrayEnumeration(fgSAXProperties) : fgEmptyEnumeration;
}
public static Enumeration getXercesFeatures() {
return (fgXercesFeatures.length > 0) ? new ArrayEnumeration(fgXercesFeatures) : fgEmptyEnumeration;
}
public static Enumeration getXercesProperties() {
return (fgXercesProperties.length > 0) ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration;
}
static class ArrayEnumeration implements Enumeration {
private Object[] array;
private int index;
public ArrayEnumeration(Object[] array) {
this.array = array;
}
public boolean hasMoreElements() {
return (this.index < this.array.length);
}
public Object nextElement() {
if (this.index < this.array.length)
return this.array[this.index++];
throw new NoSuchElementException();
}
}
public static void main(String[] argv) {
print("SAX features:", "http://xml.org/sax/features/", fgSAXFeatures);
print("SAX properties:", "http://xml.org/sax/properties/", fgSAXProperties);
print("Xerces features:", "http://apache.org/xml/features/", fgXercesFeatures);
print("Xerces properties:", "http://apache.org/xml/properties/", fgXercesProperties);
}
private static void print(String header, String prefix, Object[] array) {
System.out.print(header);
if (array.length > 0) {
System.out.println();
for (int i = 0; i < array.length; i++) {
System.out.print(" ");
System.out.print(prefix);
System.out.println(array[i]);
}
} else {
System.out.println(" none.");
}
}
}

View file

@ -0,0 +1,205 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import java.io.InputStream;
import java.io.Reader;
public abstract class Entity {
public String name;
public boolean inExternalSubset;
public Entity() {
clear();
}
public Entity(String name, boolean inExternalSubset) {
this.name = name;
this.inExternalSubset = inExternalSubset;
}
public boolean isEntityDeclInExternalSubset() {
return this.inExternalSubset;
}
public abstract boolean isExternal();
public abstract boolean isUnparsed();
public void clear() {
this.name = null;
this.inExternalSubset = false;
}
public void setValues(Entity entity) {
this.name = entity.name;
this.inExternalSubset = entity.inExternalSubset;
}
public static class InternalEntity extends Entity {
public String text;
public InternalEntity() {
clear();
}
public InternalEntity(String name, String text, boolean inExternalSubset) {
super(name, inExternalSubset);
this.text = text;
}
public final boolean isExternal() {
return false;
}
public final boolean isUnparsed() {
return false;
}
public void clear() {
super.clear();
this.text = null;
}
public void setValues(Entity entity) {
super.setValues(entity);
this.text = null;
}
public void setValues(InternalEntity entity) {
super.setValues(entity);
this.text = entity.text;
}
}
public static class ExternalEntity extends Entity {
public XMLResourceIdentifier entityLocation;
public String notation;
public ExternalEntity() {
clear();
}
public ExternalEntity(String name, XMLResourceIdentifier entityLocation, String notation, boolean inExternalSubset) {
super(name, inExternalSubset);
this.entityLocation = entityLocation;
this.notation = notation;
}
public final boolean isExternal() {
return true;
}
public final boolean isUnparsed() {
return (this.notation != null);
}
public void clear() {
super.clear();
this.entityLocation = null;
this.notation = null;
}
public void setValues(Entity entity) {
super.setValues(entity);
this.entityLocation = null;
this.notation = null;
}
public void setValues(ExternalEntity entity) {
super.setValues(entity);
this.entityLocation = entity.entityLocation;
this.notation = entity.notation;
}
}
public static class ScannedEntity extends Entity {
public static final int DEFAULT_BUFFER_SIZE = 8192;
public int fBufferSize = 8192;
public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;
public InputStream stream;
public Reader reader;
public XMLResourceIdentifier entityLocation;
public String encoding;
public boolean literal;
public boolean isExternal;
public String version;
public char[] ch = null;
public int position;
public int count;
public int lineNumber = 1;
public int columnNumber = 1;
public int fTotalCountTillLastLoad;
public int fLastCount;
public boolean mayReadChunks;
public String getEncodingName() {
return this.encoding;
}
public String getEntityVersion() {
return this.version;
}
public void setEntityVersion(String version) {
this.version = version;
}
public Reader getEntityReader() {
return this.reader;
}
public InputStream getEntityInputStream() {
return this.stream;
}
public ScannedEntity(String name, XMLResourceIdentifier entityLocation, InputStream stream, Reader reader, String encoding, boolean literal, boolean mayReadChunks, boolean isExternal) {
this.name = name;
this.entityLocation = entityLocation;
this.stream = stream;
this.reader = reader;
this.encoding = encoding;
this.literal = literal;
this.mayReadChunks = mayReadChunks;
this.isExternal = isExternal;
this.ch = new char[isExternal ? this.fBufferSize : 1024];
}
public final boolean isExternal() {
return this.isExternal;
}
public final boolean isUnparsed() {
return false;
}
public String toString() {
StringBuffer str = new StringBuffer();
str.append("name=\"" + this.name + '"');
str.append(",ch=" + new String(this.ch));
str.append(",position=" + this.position);
str.append(",count=" + this.count);
return str.toString();
}
}
}

View file

@ -0,0 +1,63 @@
package com.sun.xml.stream;
import java.util.NoSuchElementException;
import javax.xml.stream.EventFilter;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.util.EventReaderDelegate;
public class EventFilterSupport extends EventReaderDelegate {
EventFilter fEventFilter;
public EventFilterSupport(XMLEventReader eventReader, EventFilter eventFilter) {
setParent(eventReader);
this.fEventFilter = eventFilter;
}
public Object next() {
try {
return nextEvent();
} catch (XMLStreamException ex) {
throw new NoSuchElementException();
}
}
public boolean hasNext() {
try {
return (peek() != null);
} catch (XMLStreamException ex) {
return false;
}
}
public XMLEvent nextEvent() throws XMLStreamException {
if (super.hasNext()) {
XMLEvent event = super.nextEvent();
if (this.fEventFilter.accept(event))
return event;
return nextEvent();
}
throw new NoSuchElementException();
}
public XMLEvent nextTag() throws XMLStreamException {
if (super.hasNext()) {
XMLEvent event = super.nextTag();
if (this.fEventFilter.accept(event))
return event;
return nextTag();
}
throw new NoSuchElementException();
}
public XMLEvent peek() throws XMLStreamException {
XMLEvent event = super.peek();
if (event == null)
return null;
if (this.fEventFilter.accept(event))
return event;
super.next();
return peek();
}
}

View file

@ -0,0 +1,177 @@
package com.sun.xml.stream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
public class FileBufferManager extends BufferManager {
static final int DEFAULT_LENGTH = 8192;
static final int THRESH_HOLD = 81920;
static final boolean DEBUG = false;
CharsetDecoder decoder = null;
FileChannel fChannel = null;
CharBuffer charBuffer = null;
boolean calledGetMore;
long remaining = -1L;
long filepos = 0L;
long filesize = -1L;
public FileBufferManager(FileInputStream stream, String encodingName) throws IOException {
init(stream);
setDecoder("UTF-8");
}
void init(FileInputStream stream) throws IOException {
this.charBuffer = CharBuffer.allocate(16384);
this.fChannel = stream.getChannel();
this.filesize = this.fChannel.size();
this.remaining = this.filesize;
}
public boolean arrangeCapacity(int length) throws IOException {
if (!this.calledGetMore)
getMore();
if (getCharBuffer().limit() - getCharBuffer().position() >= length)
return true;
while (getCharBuffer().limit() - getCharBuffer().position() < length &&
!endOfStream())
getMore();
if (getCharBuffer().limit() - getCharBuffer().position() >= length)
return true;
return false;
}
public ByteBuffer getMoreBytes() throws IOException {
int len = getLength();
if (this.endOfStream)
return ByteBuffer.allocate(0);
ByteBuffer bb = null;
if (this.filesize > 81920L) {
bb = this.fChannel.map(FileChannel.MapMode.READ_ONLY, this.filepos, (long)len);
this.filepos += (long)bb.limit();
} else {
bb = ByteBuffer.allocate(getLength());
this.fChannel.read(bb);
this.filepos = this.fChannel.position();
bb.flip();
}
this.remaining = this.filesize - this.filepos;
if (this.remaining < 1L)
this.endOfStream = true;
return bb;
}
public boolean getMore() throws IOException {
this.calledGetMore = true;
if (this.endOfStream)
return false;
ByteBuffer bb = getMoreBytes();
if (this.charBuffer.position() != 0) {
this.charBuffer.compact();
} else {
this.charBuffer.clear();
}
int before = this.charBuffer.position();
CoderResult cr = this.decoder.decode(bb, this.charBuffer, false);
while (bb.remaining() > 0) {
if (cr.isOverflow())
resizeCharBuffer(this.charBuffer.limit() + bb.remaining());
cr = this.decoder.decode(bb, this.charBuffer, true);
}
if (cr.isUnderflow()) {
cr = this.decoder.decode(bb, this.charBuffer, true);
this.decoder.flush(this.charBuffer);
}
this.decoder.reset();
if (this.charBuffer.position() > before) {
this.charBuffer.flip();
return true;
}
return false;
}
public CharBuffer getCharBuffer() {
return this.charBuffer;
}
CharSequence getCharSequence() {
return this.charBuffer.subSequence(0, this.charBuffer.remaining());
}
CharBuffer resizeCharBuffer(int capacity) {
CharBuffer cb = CharBuffer.allocate(capacity);
this.charBuffer = cb.put((CharBuffer)this.charBuffer.flip());
return this.charBuffer;
}
int getLength() {
return (this.remaining < 16384L) ? (int)this.remaining : 16384;
}
void setDecoder(String encoding) throws IOException {
if (encoding != null) {
this.decoder = Charset.forName(encoding).newDecoder();
} else {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
this.fChannel.read(byteBuffer);
byte[] b = new byte[4];
byteBuffer.get(b);
Object[] array = getEncodingName(b, 4);
this.decoder = Charset.forName((String)array[0]).newDecoder();
}
}
static void printByteBuffer(ByteBuffer bb) {
System.out.println("------------ByteBuffer Details---------");
System.out.println("bb.position = " + bb.position());
System.out.println("bb.remaining() = " + bb.remaining());
System.out.println("bb.limit = " + bb.limit());
System.out.println("bb.capacity = " + bb.capacity());
}
static void printCharBuffer(CharBuffer bb) {
System.out.println("----------- CharBuffer Details---------");
System.out.println("bb.position = " + bb.position());
System.out.println("bb.remaining() = " + bb.remaining());
System.out.println("bb.limit = " + bb.limit());
System.out.println("bb.capacity = " + bb.capacity());
}
public static void main(String[] args) {
try {
FileBufferManager fb = new FileBufferManager(new FileInputStream(args[0]), "UTF-8");
CharBuffer cb = fb.getCharBuffer();
int i = 0;
while (fb.getMore()) {
System.out.println("Loop " + i++ + " = " + fb.getCharBuffer().toString());
System.out.println("------------Loop CharBuffer details--------");
printCharBuffer(cb);
}
System.out.println("End of file reached = " + fb.endOfStream());
System.out.println("Total no. of loops required = " + i);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void close() throws IOException {
if (this.fChannel != null)
this.fChannel.close();
}
public void setEncoding(String encoding) throws IOException {}
}

View file

@ -0,0 +1,98 @@
package com.sun.xml.stream;
import java.util.HashMap;
import javax.xml.stream.XMLResolver;
public class PropertyManager {
protected static final String STAX_NOTATIONS = "javax.xml.stream.notations";
protected static final String STAX_ENTITIES = "javax.xml.stream.entities";
private static final String STRING_INTERNING = "http://xml.org/sax/features/string-interning".intern();
HashMap supportedProps = new HashMap();
public static final int CONTEXT_READER = 1;
public static final int CONTEXT_WRITER = 2;
public PropertyManager(int context) {
switch (context) {
case 1:
initConfigurableReaderProperties();
break;
case 2:
initWriterProps();
break;
}
}
public PropertyManager(PropertyManager propertyManager) {
HashMap properties = propertyManager.getProperties();
this.supportedProps.putAll(properties);
}
private HashMap getProperties() {
return this.supportedProps;
}
private void initConfigurableReaderProperties() {
this.supportedProps.put("javax.xml.stream.isNamespaceAware", Boolean.TRUE);
this.supportedProps.put("javax.xml.stream.isValidating", Boolean.FALSE);
this.supportedProps.put("javax.xml.stream.isReplacingEntityReferences", Boolean.TRUE);
this.supportedProps.put("javax.xml.stream.isSupportingExternalEntities", Boolean.TRUE);
this.supportedProps.put("javax.xml.stream.isCoalescing", Boolean.FALSE);
this.supportedProps.put("javax.xml.stream.supportDTD", Boolean.TRUE);
this.supportedProps.put("javax.xml.stream.reporter", null);
this.supportedProps.put("javax.xml.stream.resolver", null);
this.supportedProps.put("javax.xml.stream.allocator", null);
this.supportedProps.put("javax.xml.stream.notations", null);
this.supportedProps.put("http://xml.org/sax/features/string-interning", new Boolean(true));
this.supportedProps.put("http://apache.org/xml/features/allow-java-encodings", new Boolean(true));
this.supportedProps.put("http://java.sun.com/xml/stream/properties/reader-in-defined-state", new Boolean(true));
this.supportedProps.put("reuse-instance", new Boolean(true));
this.supportedProps.put("http://java.sun.com/xml/stream/properties/report-cdata-event", new Boolean(false));
this.supportedProps.put("http://apache.org/xml/features/validation/warn-on-duplicate-attdef", new Boolean(false));
this.supportedProps.put("http://apache.org/xml/features/warn-on-duplicate-entitydef", new Boolean(false));
this.supportedProps.put("http://apache.org/xml/features/validation/warn-on-undeclared-elemdef", new Boolean(false));
}
private void initWriterProps() {
this.supportedProps.put("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);
this.supportedProps.put("escapeCharacters", Boolean.TRUE);
}
public boolean containsProperty(String property) {
return this.supportedProps.containsKey(property);
}
public Object getProperty(String property) {
if (property == null)
return null;
if (this.supportedProps.containsKey(property))
return this.supportedProps.get(property);
return null;
}
public void setProperty(String property, Object value) {
String equivalentProperty = null;
if (property == "javax.xml.stream.isNamespaceAware" || property.equals("javax.xml.stream.isNamespaceAware")) {
equivalentProperty = "http://apache.org/xml/features/namespaces";
} else if (property == "javax.xml.stream.isValidating" || property.equals("javax.xml.stream.isValidating")) {
if (value instanceof Boolean && (Boolean)value)
throw new IllegalArgumentException("true value of isValidating not supported");
} else if (property == STRING_INTERNING || property.equals(STRING_INTERNING)) {
if (value instanceof Boolean && !((Boolean)value))
throw new IllegalArgumentException("false value of " + STRING_INTERNING + "feature is not supported");
} else if (property == "javax.xml.stream.resolver" || property.equals("javax.xml.stream.resolver")) {
this.supportedProps.put("http://apache.org/xml/properties/internal/stax-entity-resolver", new StaxEntityResolverWrapper((XMLResolver)value));
}
this.supportedProps.put(property, value);
if (equivalentProperty != null)
this.supportedProps.put(equivalentProperty, value);
}
public String toString() {
return this.supportedProps.toString();
}
}

View file

@ -0,0 +1,49 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
public class StaxEntityResolverWrapper {
XMLResolver fStaxResolver;
public StaxEntityResolverWrapper(XMLResolver resolver) {
this.fStaxResolver = resolver;
}
public void setStaxEntityResolver(XMLResolver resolver) {
this.fStaxResolver = resolver;
}
public XMLResolver getStaxEntityResolver() {
return this.fStaxResolver;
}
public StaxXMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
Object object = null;
try {
object = this.fStaxResolver.resolveEntity(resourceIdentifier.getPublicId(), resourceIdentifier.getLiteralSystemId(), resourceIdentifier.getBaseSystemId(), null);
return getStaxInputSource(object);
} catch (XMLStreamException streamException) {
throw new XNIException(streamException);
}
}
StaxXMLInputSource getStaxInputSource(Object object) {
if (object == null)
return null;
if (object instanceof InputStream)
return new StaxXMLInputSource(new XMLInputSource(null, null, null, (InputStream)object, null));
if (object instanceof XMLStreamReader)
return new StaxXMLInputSource((XMLStreamReader)object);
if (object instanceof XMLEventReader)
return new StaxXMLInputSource((XMLEventReader)object);
return null;
}
}

View file

@ -0,0 +1,95 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.impl.msg.XMLMessageFormatter;
import com.sun.xml.stream.xerces.util.MessageFormatter;
import com.sun.xml.stream.xerces.xni.XMLLocator;
import com.sun.xml.stream.xerces.xni.XNIException;
import javax.xml.stream.Location;
import javax.xml.stream.XMLReporter;
import javax.xml.stream.XMLStreamException;
public class StaxErrorReporter extends XMLErrorReporter {
protected XMLReporter fXMLReporter = null;
public StaxErrorReporter(PropertyManager propertyManager) {
putMessageFormatter("http://www.w3.org/TR/1998/REC-xml-19980210", new XMLMessageFormatter());
reset(propertyManager);
}
public StaxErrorReporter() {
putMessageFormatter("http://www.w3.org/TR/1998/REC-xml-19980210", new XMLMessageFormatter());
}
public void reset(PropertyManager propertyManager) {
this.fXMLReporter = (XMLReporter)propertyManager.getProperty("javax.xml.stream.reporter");
}
public void reportError(XMLLocator location, String domain, String key, Object[] arguments, short severity) throws XNIException {
String message;
MessageFormatter messageFormatter = getMessageFormatter(domain);
if (messageFormatter != null) {
message = messageFormatter.formatMessage(this.fLocale, key, arguments);
} else {
StringBuffer str = new StringBuffer();
str.append(domain);
str.append('#');
str.append(key);
int argCount = (arguments != null) ? arguments.length : 0;
if (argCount > 0) {
str.append('?');
for (int i = 0; i < argCount; i++) {
str.append(arguments[i]);
if (i < argCount - 1)
str.append('&');
}
}
message = str.toString();
}
switch (severity) {
case 0:
try {
if (this.fXMLReporter != null)
this.fXMLReporter.report(message, "WARNING", null, convertToStaxLocation(location));
} catch (XMLStreamException ex) {
throw new XNIException(ex);
}
break;
case 1:
try {
if (this.fXMLReporter != null)
this.fXMLReporter.report(message, "ERROR", null, convertToStaxLocation(location));
} catch (XMLStreamException ex) {
throw new XNIException(ex);
}
break;
case 2:
if (!this.fContinueAfterFatalError)
throw new XNIException(message);
break;
}
}
Location convertToStaxLocation(final XMLLocator location) {
return new Location() {
public int getColumnNumber() {
return location.getColumnNumber();
}
public int getLineNumber() {
return location.getLineNumber();
}
public String getPublicId() {
return location.getPublicId();
}
public String getSystemId() {
return location.getLiteralSystemId();
}
public int getCharacterOffset() {
return location.getCharacterOffset();
}
};
}
}

View file

@ -0,0 +1,41 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamReader;
public class StaxXMLInputSource {
XMLStreamReader fStreamReader;
XMLEventReader fEventReader;
XMLInputSource fInputSource;
public StaxXMLInputSource(XMLStreamReader streamReader) {
this.fStreamReader = streamReader;
}
public StaxXMLInputSource(XMLEventReader eventReader) {
this.fEventReader = eventReader;
}
public StaxXMLInputSource(XMLInputSource inputSource) {
this.fInputSource = inputSource;
}
public XMLStreamReader getXMLStreamReader() {
return this.fStreamReader;
}
public XMLEventReader getXMLEventReader() {
return this.fEventReader;
}
public XMLInputSource getXMLInputSource() {
return this.fInputSource;
}
public boolean hasXMLStreamOrXMLEventReader() {
return !(this.fStreamReader == null && this.fEventReader == null);
}
}

View file

@ -0,0 +1,281 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.impl.io.ASCIIReader;
import com.sun.xml.stream.xerces.impl.io.UCSReader;
import com.sun.xml.stream.xerces.impl.io.UTF8Reader;
import com.sun.xml.stream.xerces.util.EncodingMap;
import com.sun.xml.stream.xerces.util.XMLChar;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.CharBuffer;
import java.util.Locale;
public class StreamBufferManager extends BufferManager {
static final int DEFAULT_LENGTH = 8192;
static final boolean DEBUG = false;
CharBuffer charBuffer = null;
Reader fReader = null;
boolean fAllowJavaEncodings = true;
public StreamBufferManager(InputStream stream, String encoding) throws IOException {
init(stream, encoding);
}
void init(InputStream istream, String encoding) throws IOException {
Boolean isBigEndian = null;
InputStream stream = new RewindableInputStream(istream);
if (encoding == null) {
byte[] b4 = new byte[4];
int count = 0;
for (; count < 4; count++)
b4[count] = (byte)stream.read();
if (count == 4) {
Object[] encodingDesc = getEncodingName(b4, count);
encoding = (String)encodingDesc[0];
isBigEndian = (Boolean)encodingDesc[1];
stream.reset();
int offset = 0;
if (count > 2 && encoding.equals("UTF-8")) {
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
int b2 = b4[2] & 0xFF;
if (b0 == 239 && b1 == 187 && b2 == 191)
stream.skip(3L);
}
this.fReader = createReader(stream, encoding, isBigEndian);
} else {
this.fReader = createReader(stream, encoding, isBigEndian);
}
} else {
this.fReader = createReader(stream, encoding, isBigEndian);
}
this.charBuffer = CharBuffer.allocate(8192);
}
public CharBuffer getCharBuffer() {
return this.charBuffer;
}
public boolean getMore() throws IOException {
if (this.charBuffer.position() != 0)
this.charBuffer.compact();
char[] ch = this.charBuffer.array();
int offset = this.charBuffer.position();
int count = this.fReader.read(ch, offset, this.charBuffer.capacity());
if (count == -1) {
this.endOfStream = true;
return false;
}
this.charBuffer = CharBuffer.wrap(ch);
this.charBuffer.limit(count);
if (count > 0)
return true;
return false;
}
protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian) throws IOException {
if (encoding == null)
encoding = "UTF-8";
String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
if (ENCODING.equals("UTF-8"))
return new UTF8Reader(inputStream, 8192, null, Locale.getDefault());
if (ENCODING.equals("US-ASCII"))
return new ASCIIReader(inputStream, 8192, null, Locale.getDefault());
if (ENCODING.equals("ISO-10646-UCS-4")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian;
if (isBE)
return new UCSReader(inputStream, (short)8);
return new UCSReader(inputStream, (short)4);
}
throw new IOException("Encoding byte order not supported");
}
if (ENCODING.equals("ISO-10646-UCS-2")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian;
if (isBE)
return new UCSReader(inputStream, (short)2);
return new UCSReader(inputStream, (short)1);
}
throw new IOException("Encoding byte order not supported");
}
boolean validIANA = XMLChar.isValidIANAEncoding(encoding);
boolean validJava = XMLChar.isValidJavaEncoding(encoding);
if (!validIANA || (this.fAllowJavaEncodings && !validJava))
throw new IOException("Encoding declaration " + encoding + "not valid");
String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING);
if (javaEncoding == null)
if (this.fAllowJavaEncodings) {
javaEncoding = encoding;
} else {
throw new IOException("Encoding " + encoding + " not supported");
}
return new BufferedReader(new InputStreamReader(inputStream, javaEncoding));
}
int getLength() {
return 8192;
}
public static void main(String[] args) {
try {
File file = new File(args[0]);
System.out.println("url parameter = " + file.toURI().toString());
URL url = new URL(file.toURI().toString());
StreamBufferManager sb = new StreamBufferManager(url.openStream(), "UTF-8");
CharBuffer cb = sb.getCharBuffer();
int i = 0;
while (sb.getMore())
System.out.println("Loop " + i++ + " = " + sb.getCharBuffer());
System.out.println("End of stream reached = " + sb.endOfStream());
System.out.println("Total no. of loops required = " + i);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void close() throws IOException {
if (this.fReader != null)
this.fReader.close();
}
public void setEncoding(String encoding) throws IOException {}
public boolean arrangeCapacity(int length) throws IOException {
return false;
}
protected final class RewindableInputStream extends InputStream {
private InputStream fInputStream;
private byte[] fData;
private int fStartOffset;
private int fEndOffset;
private int fOffset;
private int fLength;
private int fMark;
static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
public RewindableInputStream(InputStream is) {
this.fData = new byte[64];
this.fInputStream = is;
this.fStartOffset = 0;
this.fEndOffset = -1;
this.fOffset = 0;
this.fLength = 0;
this.fMark = 0;
}
public void setStartOffset(int offset) {
this.fStartOffset = offset;
}
public void rewind() {
this.fOffset = this.fStartOffset;
}
public int read() throws IOException {
int b = 0;
if (this.fOffset < this.fLength)
return this.fData[this.fOffset++] & 0xFF;
if (this.fOffset == this.fEndOffset)
return -1;
if (this.fOffset == this.fData.length) {
byte[] newData = new byte[this.fOffset << 1];
System.arraycopy(this.fData, 0, newData, 0, this.fOffset);
this.fData = newData;
}
b = this.fInputStream.read();
if (b == -1) {
this.fEndOffset = this.fOffset;
return -1;
}
this.fData[this.fLength++] = (byte)b;
this.fOffset++;
return b & 0xFF;
}
public int read(byte[] b, int off, int len) throws IOException {
int bytesLeft = this.fLength - this.fOffset;
if (bytesLeft == 0) {
if (this.fOffset == this.fEndOffset)
return -1;
return this.fInputStream.read(b, off, len);
}
if (len < bytesLeft) {
if (len <= 0)
return 0;
} else {
len = bytesLeft;
}
if (b != null)
System.arraycopy(this.fData, this.fOffset, b, off, len);
this.fOffset += len;
return len;
}
public long skip(long n) throws IOException {
if (n <= 0L)
return 0L;
int bytesLeft = this.fLength - this.fOffset;
if (bytesLeft == 0) {
if (this.fOffset == this.fEndOffset)
return 0L;
return this.fInputStream.skip(n);
}
if (n <= (long)bytesLeft) {
this.fOffset = (int)((long)this.fOffset + n);
return n;
}
this.fOffset += bytesLeft;
if (this.fOffset == this.fEndOffset)
return (long)bytesLeft;
n -= (long)bytesLeft;
return this.fInputStream.skip(n) + (long)bytesLeft;
}
public int available() throws IOException {
int bytesLeft = this.fLength - this.fOffset;
if (bytesLeft == 0) {
if (this.fOffset == this.fEndOffset)
return -1;
return this.fInputStream.available();
}
return bytesLeft;
}
public void mark(int howMuch) {
this.fMark = this.fOffset;
}
public void reset() {
this.fOffset = this.fMark;
}
public boolean markSupported() {
return true;
}
public void close() throws IOException {
if (this.fInputStream != null) {
this.fInputStream.close();
this.fInputStream = null;
}
}
}
}

View file

@ -0,0 +1,7 @@
package com.sun.xml.stream;
public class Version {
public static void main(String[] args) {
System.out.println("Sun Java Streaming XML Parser Version is '" + Package.getPackage("com.sun.xml.stream").getImplementationVersion() + "'");
}
}

View file

@ -0,0 +1,7 @@
package com.sun.xml.stream;
public interface XMLBufferListener {
void refresh();
void refresh(int paramInt);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,653 @@
package com.sun.xml.stream;
import com.sun.xml.stream.dtd.DTDGrammarUtil;
import com.sun.xml.stream.xerces.util.NamespaceSupport;
import com.sun.xml.stream.xerces.util.XMLChar;
import com.sun.xml.stream.xerces.util.XMLResourceIdentifierImpl;
import com.sun.xml.stream.xerces.util.XMLStringBuffer;
import com.sun.xml.stream.xerces.xni.NamespaceContext;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import com.sun.xml.stream.xerces.xni.parser.XMLDTDScanner;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import java.io.EOFException;
import java.io.IOException;
import java.util.NoSuchElementException;
public class XMLDocumentScannerImpl extends XMLDocumentFragmentScannerImpl {
protected static final int SCANNER_STATE_XML_DECL = 42;
protected static final int SCANNER_STATE_PROLOG = 43;
protected static final int SCANNER_STATE_TRAILING_MISC = 44;
protected static final int SCANNER_STATE_DTD_INTERNAL_DECLS = 45;
protected static final int SCANNER_STATE_DTD_EXTERNAL = 46;
protected static final int SCANNER_STATE_DTD_EXTERNAL_DECLS = 47;
protected static final int SCANNER_STATE_NO_SUCH_ELEMENT_EXCEPTION = 48;
protected static final String LOAD_EXTERNAL_DTD = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
protected static final String DISALLOW_DOCTYPE_DECL_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
protected static final String DTD_SCANNER = "http://apache.org/xml/properties/internal/dtd-scanner";
protected static final String VALIDATION_MANAGER = "http://apache.org/xml/properties/internal/validation-manager";
private static final String[] RECOGNIZED_FEATURES = new String[] { "http://apache.org/xml/features/nonvalidating/load-external-dtd", "http://apache.org/xml/features/disallow-doctype-decl" };
private static final Boolean[] FEATURE_DEFAULTS = new Boolean[] { Boolean.TRUE, Boolean.FALSE };
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://apache.org/xml/properties/internal/dtd-scanner", "http://apache.org/xml/properties/internal/validation-manager" };
private static final Object[] PROPERTY_DEFAULTS = new Object[] { null, null };
protected XMLDTDScanner fDTDScanner = null;
protected XMLStringBuffer fDTDDecl = null;
protected boolean fReadingDTD = false;
protected boolean fEndOfDocument;
protected String fDoctypeName;
protected String fDoctypePublicId;
protected String fDoctypeSystemId;
protected NamespaceContext fNamespaceContext = new NamespaceSupport();
protected boolean fLoadExternalDTD = true;
protected boolean fDisallowDoctype = false;
protected boolean fSeenDoctypeDecl;
protected boolean fBindNamespaces;
protected boolean fScanEndElement;
protected int fScannerLastState;
protected XMLDocumentFragmentScannerImpl.Driver fXMLDeclDriver = new XMLDeclDriver();
protected XMLDocumentFragmentScannerImpl.Driver fPrologDriver = new PrologDriver();
protected XMLDocumentFragmentScannerImpl.Driver fDTDDriver = null;
protected XMLDocumentFragmentScannerImpl.Driver fTrailingMiscDriver = new TrailingMiscDriver();
protected int fStartPos = 0;
protected int fEndPos = 0;
protected boolean fSeenInternalSubset = false;
private String[] fStrings = new String[3];
private XMLString fString = new XMLString();
public static final char[] DOCTYPE = new char[] { 'D', 'O', 'C', 'T', 'Y', 'P', 'E' };
public static final char[] COMMENTSTRING = new char[] { '-', '-' };
protected boolean fReadingAttributes = false;
protected XMLBufferListenerImpl fScannerBufferlistener = new XMLBufferListenerImpl();
public void setInputSource(XMLInputSource inputSource) throws IOException {
this.fEntityManager.setEntityHandler(this);
this.fEntityManager.startDocumentEntity(inputSource);
setScannerState(7);
}
public void reset(PropertyManager propertyManager) {
super.reset(propertyManager);
this.fDoctypeName = null;
this.fDoctypePublicId = null;
this.fDoctypeSystemId = null;
this.fSeenDoctypeDecl = false;
this.fNamespaceContext.reset();
this.fDisallowDoctype = !((Boolean)propertyManager.getProperty("javax.xml.stream.supportDTD"));
this.fBindNamespaces = (Boolean)propertyManager.getProperty("javax.xml.stream.isNamespaceAware");
this.fLoadExternalDTD = true;
this.fEndOfDocument = false;
setScannerState(7);
setDriver(this.fXMLDeclDriver);
this.fSeenInternalSubset = false;
if (this.fDTDScanner != null)
((XMLDTDScannerImpl)this.fDTDScanner).reset(propertyManager);
this.fEndPos = 0;
this.fStartPos = 0;
if (this.fDTDDecl != null)
this.fDTDDecl.clear();
}
public int getScannetState() {
return this.fScannerState;
}
public int next() throws IOException, XNIException {
if (this.fScannerLastState == 2 && this.fBindNamespaces) {
this.fScannerLastState = -1;
this.fNamespaceContext.popContext();
}
return this.fScannerLastState = this.fDriver.next();
}
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
super.reset(componentManager);
this.fDoctypeName = null;
this.fDoctypePublicId = null;
this.fDoctypeSystemId = null;
this.fSeenDoctypeDecl = false;
this.fNamespaceContext.reset();
try {
this.fLoadExternalDTD = componentManager.getFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd");
} catch (XMLConfigurationException e) {
this.fLoadExternalDTD = true;
}
try {
this.fDisallowDoctype = componentManager.getFeature("http://apache.org/xml/features/disallow-doctype-decl");
} catch (XMLConfigurationException e) {
this.fDisallowDoctype = false;
}
this.fDTDScanner = (XMLDTDScanner)componentManager.getProperty("http://apache.org/xml/properties/internal/dtd-scanner");
this.fEndPos = 0;
this.fStartPos = 0;
if (this.fDTDDecl != null)
this.fDTDDecl.clear();
setScannerState(42);
setDriver(this.fXMLDeclDriver);
}
public String[] getRecognizedFeatures() {
String[] featureIds = super.getRecognizedFeatures();
int length = (featureIds != null) ? featureIds.length : 0;
String[] combinedFeatureIds = new String[length + RECOGNIZED_FEATURES.length];
if (featureIds != null)
System.arraycopy(featureIds, 0, combinedFeatureIds, 0, featureIds.length);
System.arraycopy(RECOGNIZED_FEATURES, 0, combinedFeatureIds, length, RECOGNIZED_FEATURES.length);
return combinedFeatureIds;
}
public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
super.setFeature(featureId, state);
if (featureId.startsWith("http://apache.org/xml/features/")) {
String feature = featureId.substring("http://apache.org/xml/features/".length());
if (feature.equals("nonvalidating/load-external-dtd")) {
this.fLoadExternalDTD = state;
return;
}
}
}
public String[] getRecognizedProperties() {
String[] propertyIds = super.getRecognizedProperties();
int length = (propertyIds != null) ? propertyIds.length : 0;
String[] combinedPropertyIds = new String[length + RECOGNIZED_PROPERTIES.length];
if (propertyIds != null)
System.arraycopy(propertyIds, 0, combinedPropertyIds, 0, propertyIds.length);
System.arraycopy(RECOGNIZED_PROPERTIES, 0, combinedPropertyIds, length, RECOGNIZED_PROPERTIES.length);
return combinedPropertyIds;
}
public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
super.setProperty(propertyId, value);
if (propertyId.startsWith("http://apache.org/xml/properties/")) {
String property = propertyId.substring("http://apache.org/xml/properties/".length());
if (property.equals("internal/dtd-scanner"))
this.fDTDScanner = (XMLDTDScanner)value;
return;
}
}
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId))
return FEATURE_DEFAULTS[i];
}
return super.getFeatureDefault(featureId);
}
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId))
return PROPERTY_DEFAULTS[i];
}
return super.getPropertyDefault(propertyId);
}
public void startEntity(String name, XMLResourceIdentifier identifier, String encoding) throws XNIException {
super.startEntity(name, identifier, encoding);
if (!name.equals("[xml]") && this.fEntityScanner.isExternal())
setScannerState(36);
if (this.fDocumentHandler != null && name.equals("[xml]"))
this.fDocumentHandler.startDocument(this.fEntityScanner, encoding, this.fNamespaceContext, null);
}
public void endEntity(String name) throws IOException, XNIException {
super.endEntity(name);
if (name.equals("[xml]")) {
if (this.fMarkupDepth == 0 && this.fDriver == this.fTrailingMiscDriver) {
setScannerState(34);
} else {
throw new EOFException();
}
if (this.fDocumentHandler != null)
this.fDocumentHandler.endDocument(null);
}
}
protected XMLDocumentFragmentScannerImpl.Driver createContentDriver() {
return new ContentDriver();
}
protected boolean scanDoctypeDecl() throws IOException, XNIException {
if (!this.fEntityScanner.skipSpaces())
reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL", null);
this.fDoctypeName = this.fEntityScanner.scanName();
if (this.fDoctypeName == null)
reportFatalError("MSG_ROOT_ELEMENT_TYPE_REQUIRED", null);
if (this.fEntityScanner.skipSpaces()) {
scanExternalID(this.fStrings, false);
this.fDoctypeSystemId = this.fStrings[0];
this.fDoctypePublicId = this.fStrings[1];
this.fEntityScanner.skipSpaces();
}
this.fHasExternalDTD = (this.fDoctypeSystemId != null);
if (this.fDocumentHandler != null)
this.fDocumentHandler.doctypeDecl(this.fDoctypeName, this.fDoctypePublicId, this.fDoctypeSystemId, null);
boolean internalSubset = true;
if (!this.fEntityScanner.skipChar(91)) {
internalSubset = false;
this.fEntityScanner.skipSpaces();
if (!this.fEntityScanner.skipChar(62))
reportFatalError("DoctypedeclUnterminated", new Object[] { this.fDoctypeName });
this.fMarkupDepth--;
}
return internalSubset;
}
protected String getScannerStateName(int state) {
switch (state) {
case 42:
return "SCANNER_STATE_XML_DECL";
case 43:
return "SCANNER_STATE_PROLOG";
case 44:
return "SCANNER_STATE_TRAILING_MISC";
case 45:
return "SCANNER_STATE_DTD_INTERNAL_DECLS";
case 46:
return "SCANNER_STATE_DTD_EXTERNAL";
case 47:
return "SCANNER_STATE_DTD_EXTERNAL_DECLS";
}
return super.getScannerStateName(state);
}
protected final class XMLDeclDriver implements XMLDocumentFragmentScannerImpl.Driver {
public int next() throws IOException, XNIException {
XMLDocumentScannerImpl.this.setScannerState(43);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fPrologDriver);
try {
if (XMLDocumentScannerImpl.this.fEntityScanner.skipString(XMLDocumentFragmentScannerImpl.xmlDecl)) {
XMLDocumentScannerImpl.this.fMarkupDepth++;
if (XMLChar.isName(XMLDocumentScannerImpl.this.fEntityScanner.peekChar())) {
XMLDocumentScannerImpl.this.fStringBuffer.clear();
XMLDocumentScannerImpl.this.fStringBuffer.append("xml");
while (XMLChar.isName(XMLDocumentScannerImpl.this.fEntityScanner.peekChar()))
XMLDocumentScannerImpl.this.fStringBuffer.append((char)XMLDocumentScannerImpl.this.fEntityScanner.scanChar());
String target = XMLDocumentScannerImpl.this.fSymbolTable.addSymbol(XMLDocumentScannerImpl.this.fStringBuffer.ch, XMLDocumentScannerImpl.this.fStringBuffer.offset, XMLDocumentScannerImpl.this.fStringBuffer.length);
XMLDocumentScannerImpl.this.fStringBuffer.clear();
XMLDocumentScannerImpl.this.scanPIData(target, XMLDocumentScannerImpl.this.fStringBuffer);
XMLDocumentScannerImpl.this.fEntityManager.fCurrentEntity.mayReadChunks = true;
return 3;
}
XMLDocumentScannerImpl.this.scanXMLDeclOrTextDecl(false);
XMLDocumentScannerImpl.this.fEntityManager.fCurrentEntity.mayReadChunks = true;
return 7;
}
XMLDocumentScannerImpl.this.fEntityManager.fCurrentEntity.mayReadChunks = true;
return 7;
} catch (EOFException e) {
XMLDocumentScannerImpl.this.reportFatalError("PrematureEOF", null);
return -1;
}
}
}
protected final class PrologDriver implements XMLDocumentFragmentScannerImpl.Driver {
public int next() throws IOException, XNIException {
try {
do {
switch (XMLDocumentScannerImpl.this.fScannerState) {
case 43:
XMLDocumentScannerImpl.this.fEntityScanner.skipSpaces();
if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(60)) {
XMLDocumentScannerImpl.this.setScannerState(21);
} else if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(38)) {
XMLDocumentScannerImpl.this.setScannerState(28);
} else {
XMLDocumentScannerImpl.this.setScannerState(22);
}
break;
case 21:
XMLDocumentScannerImpl.this.fMarkupDepth++;
if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(63)) {
XMLDocumentScannerImpl.this.setScannerState(23);
break;
}
if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(33)) {
if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(45)) {
if (!XMLDocumentScannerImpl.this.fEntityScanner.skipChar(45))
XMLDocumentScannerImpl.this.reportFatalError("InvalidCommentStart", null);
XMLDocumentScannerImpl.this.setScannerState(27);
break;
}
if (XMLDocumentScannerImpl.this.fEntityScanner.skipString(XMLDocumentScannerImpl.DOCTYPE)) {
XMLDocumentScannerImpl.this.setScannerState(24);
Entity entity = XMLDocumentScannerImpl.this.fEntityScanner.getCurrentEntity();
if (entity instanceof Entity.ScannedEntity)
XMLDocumentScannerImpl.this.fStartPos = ((Entity.ScannedEntity)entity).position;
XMLDocumentScannerImpl.this.fReadingDTD = true;
if (XMLDocumentScannerImpl.this.fDTDDecl == null)
XMLDocumentScannerImpl.this.fDTDDecl = new XMLStringBuffer();
XMLDocumentScannerImpl.this.fDTDDecl.append("<!DOCTYPE");
} else {
XMLDocumentScannerImpl.this.reportFatalError("MarkupNotRecognizedInProlog", null);
}
break;
}
if (XMLChar.isNameStart(XMLDocumentScannerImpl.this.fEntityScanner.peekChar())) {
XMLDocumentScannerImpl.this.setScannerState(26);
} else {
XMLDocumentScannerImpl.this.reportFatalError("MarkupNotRecognizedInProlog", null);
}
break;
}
} while (XMLDocumentScannerImpl.this.fScannerState == 43 || XMLDocumentScannerImpl.this.fScannerState == 21);
switch (XMLDocumentScannerImpl.this.fScannerState) {
case 26:
XMLDocumentScannerImpl.this.setScannerState(38);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fContentDriver);
return XMLDocumentScannerImpl.this.fContentDriver.next();
case 27:
XMLDocumentScannerImpl.this.scanComment();
XMLDocumentScannerImpl.this.setScannerState(43);
return 5;
case 23:
XMLDocumentScannerImpl.this.fContentBuffer.clear();
XMLDocumentScannerImpl.this.scanPI(XMLDocumentScannerImpl.this.fContentBuffer);
XMLDocumentScannerImpl.this.setScannerState(43);
return 3;
case 24:
if (XMLDocumentScannerImpl.this.fDisallowDoctype)
XMLDocumentScannerImpl.this.reportFatalError("DoctypeNotAllowed", null);
if (XMLDocumentScannerImpl.this.fSeenDoctypeDecl)
XMLDocumentScannerImpl.this.reportFatalError("AlreadySeenDoctype", null);
XMLDocumentScannerImpl.this.fSeenDoctypeDecl = true;
if (XMLDocumentScannerImpl.this.scanDoctypeDecl()) {
XMLDocumentScannerImpl.this.setScannerState(45);
XMLDocumentScannerImpl.this.fSeenInternalSubset = true;
if (XMLDocumentScannerImpl.this.fDTDDriver == null)
XMLDocumentScannerImpl.this.fDTDDriver = new XMLDocumentScannerImpl.DTDDriver();
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fContentDriver);
return XMLDocumentScannerImpl.this.fDTDDriver.next();
}
if (XMLDocumentScannerImpl.this.fSeenDoctypeDecl) {
Entity entity = XMLDocumentScannerImpl.this.fEntityScanner.getCurrentEntity();
if (entity instanceof Entity.ScannedEntity)
XMLDocumentScannerImpl.this.fEndPos = ((Entity.ScannedEntity)entity).position;
XMLDocumentScannerImpl.this.fReadingDTD = false;
}
if (XMLDocumentScannerImpl.this.fDoctypeSystemId != null && (XMLDocumentScannerImpl.this.fValidation || XMLDocumentScannerImpl.this.fLoadExternalDTD)) {
XMLDocumentScannerImpl.this.setScannerState(46);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fContentDriver);
if (XMLDocumentScannerImpl.this.fDTDDriver == null)
XMLDocumentScannerImpl.this.fDTDDriver = new XMLDocumentScannerImpl.DTDDriver();
return XMLDocumentScannerImpl.this.fDTDDriver.next();
}
XMLDocumentScannerImpl.this.fDTDScanner.setInputSource(null);
XMLDocumentScannerImpl.this.setScannerState(43);
return 11;
case 22:
XMLDocumentScannerImpl.this.reportFatalError("ContentIllegalInProlog", null);
XMLDocumentScannerImpl.this.fEntityScanner.scanChar();
case 28:
XMLDocumentScannerImpl.this.reportFatalError("ReferenceIllegalInProlog", null);
break;
}
} catch (EOFException e) {
XMLDocumentScannerImpl.this.reportFatalError("PrematureEOF", null);
return -1;
}
return -1;
}
}
protected final class DTDDriver implements XMLDocumentFragmentScannerImpl.Driver {
public int next() throws IOException, XNIException {
dispatch(true);
XMLDocumentScannerImpl.this.dtdGrammarUtil = new DTDGrammarUtil(((XMLDTDScannerImpl)XMLDocumentScannerImpl.this.fDTDScanner).getGrammar(), XMLDocumentScannerImpl.this.fSymbolTable);
return 11;
}
public boolean dispatch(boolean complete) throws IOException, XNIException {
XMLDocumentScannerImpl.this.fEntityManager.setEntityHandler(null);
try {
boolean again;
XMLResourceIdentifierImpl resourceIdentifier = new XMLResourceIdentifierImpl();
if (XMLDocumentScannerImpl.this.fDTDScanner == null) {
XMLDocumentScannerImpl.this.fDTDScanner = new XMLDTDScannerImpl();
if (XMLDocumentScannerImpl.this.fPropertyManager != null)
((XMLDTDScannerImpl)XMLDocumentScannerImpl.this.fDTDScanner).reset(XMLDocumentScannerImpl.this.fPropertyManager);
}
do {
boolean bool1;
XMLInputSource xmlInputSource;
boolean completeDTD, bool2;
StaxXMLInputSource staxInputSource;
boolean moreToScan;
Entity entity;
again = false;
switch (XMLDocumentScannerImpl.this.fScannerState) {
case 45:
bool1 = true;
bool2 = XMLDocumentScannerImpl.this.fDTDScanner.scanDTDInternalSubset(bool1, XMLDocumentScannerImpl.this.fStandalone, (XMLDocumentScannerImpl.this.fHasExternalDTD && XMLDocumentScannerImpl.this.fLoadExternalDTD));
entity = XMLDocumentScannerImpl.this.fEntityScanner.getCurrentEntity();
if (entity instanceof Entity.ScannedEntity)
XMLDocumentScannerImpl.this.fEndPos = ((Entity.ScannedEntity)entity).position;
XMLDocumentScannerImpl.this.fReadingDTD = false;
if (!bool2) {
if (!XMLDocumentScannerImpl.this.fEntityScanner.skipChar(93))
XMLDocumentScannerImpl.this.reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET", null);
XMLDocumentScannerImpl.this.fEntityScanner.skipSpaces();
if (!XMLDocumentScannerImpl.this.fEntityScanner.skipChar(62))
XMLDocumentScannerImpl.this.reportFatalError("DoctypedeclUnterminated", new Object[] { XMLDocumentScannerImpl.this.fDoctypeName });
XMLDocumentScannerImpl.this.fMarkupDepth--;
if (XMLDocumentScannerImpl.this.fDoctypeSystemId != null && (XMLDocumentScannerImpl.this.fValidation || XMLDocumentScannerImpl.this.fLoadExternalDTD)) {
XMLDocumentScannerImpl.this.setScannerState(46);
break;
}
XMLDocumentScannerImpl.this.setScannerState(43);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fPrologDriver);
XMLDocumentScannerImpl.this.fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
return true;
}
break;
case 46:
resourceIdentifier.setValues(XMLDocumentScannerImpl.this.fDoctypePublicId, XMLDocumentScannerImpl.this.fDoctypeSystemId, null, null);
xmlInputSource = null;
staxInputSource = XMLDocumentScannerImpl.this.fEntityManager.resolveEntityAsPerStax(resourceIdentifier);
xmlInputSource = staxInputSource.getXMLInputSource();
XMLDocumentScannerImpl.this.fDTDScanner.setInputSource(xmlInputSource);
XMLDocumentScannerImpl.this.setScannerState(47);
again = true;
break;
case 47:
completeDTD = true;
moreToScan = XMLDocumentScannerImpl.this.fDTDScanner.scanDTDExternalSubset(completeDTD);
if (!moreToScan) {
XMLDocumentScannerImpl.this.setScannerState(43);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fPrologDriver);
XMLDocumentScannerImpl.this.fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
return true;
}
break;
default:
throw new XNIException("DTDDriver#dispatch: scanner state=" + XMLDocumentScannerImpl.this.fScannerState + " (" + XMLDocumentScannerImpl.this.getScannerStateName(XMLDocumentScannerImpl.this.fScannerState) + ')');
}
} while (complete || again);
} catch (EOFException e) {
e.printStackTrace();
XMLDocumentScannerImpl.this.reportFatalError("PrematureEOF", null);
return false;
} finally {
XMLDocumentScannerImpl.this.fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
}
return true;
}
}
protected class ContentDriver extends XMLDocumentFragmentScannerImpl.FragmentContentDriver {
protected boolean scanForDoctypeHook() throws IOException, XNIException {
if (XMLDocumentScannerImpl.this.fEntityScanner.skipString(XMLDocumentScannerImpl.DOCTYPE)) {
XMLDocumentScannerImpl.this.setScannerState(24);
return true;
}
return false;
}
protected boolean elementDepthIsZeroHook() throws IOException, XNIException {
XMLDocumentScannerImpl.this.setScannerState(44);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fTrailingMiscDriver);
return true;
}
protected boolean scanRootElementHook() throws IOException, XNIException {
if (XMLDocumentScannerImpl.this.scanStartElement()) {
XMLDocumentScannerImpl.this.setScannerState(44);
XMLDocumentScannerImpl.this.setDriver(XMLDocumentScannerImpl.this.fTrailingMiscDriver);
return true;
}
return false;
}
protected void endOfFileHook(EOFException e) throws IOException, XNIException {
XMLDocumentScannerImpl.this.reportFatalError("PrematureEOF", null);
}
}
protected final class TrailingMiscDriver implements XMLDocumentFragmentScannerImpl.Driver {
public int next() throws IOException, XNIException {
try {
int ch;
if (XMLDocumentScannerImpl.this.fScannerState == 34)
return 8;
do {
switch (XMLDocumentScannerImpl.this.fScannerState) {
case 44:
XMLDocumentScannerImpl.this.fEntityScanner.skipSpaces();
if (XMLDocumentScannerImpl.this.fScannerState == 34)
return 8;
if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(60)) {
XMLDocumentScannerImpl.this.setScannerState(21);
} else {
XMLDocumentScannerImpl.this.setScannerState(22);
}
break;
case 21:
XMLDocumentScannerImpl.this.fMarkupDepth++;
if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(63)) {
XMLDocumentScannerImpl.this.setScannerState(23);
} else if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(33)) {
XMLDocumentScannerImpl.this.setScannerState(27);
} else if (XMLDocumentScannerImpl.this.fEntityScanner.skipChar(47)) {
XMLDocumentScannerImpl.this.reportFatalError("MarkupNotRecognizedInMisc", null);
} else if (XMLChar.isNameStart(XMLDocumentScannerImpl.this.fEntityScanner.peekChar())) {
XMLDocumentScannerImpl.this.reportFatalError("MarkupNotRecognizedInMisc", null);
XMLDocumentScannerImpl.this.scanStartElement();
XMLDocumentScannerImpl.this.setScannerState(22);
} else {
XMLDocumentScannerImpl.this.reportFatalError("MarkupNotRecognizedInMisc", null);
}
break;
}
} while (XMLDocumentScannerImpl.this.fScannerState == 21 || XMLDocumentScannerImpl.this.fScannerState == 44);
switch (XMLDocumentScannerImpl.this.fScannerState) {
case 23:
XMLDocumentScannerImpl.this.fContentBuffer.clear();
XMLDocumentScannerImpl.this.scanPI(XMLDocumentScannerImpl.this.fContentBuffer);
XMLDocumentScannerImpl.this.setScannerState(44);
return 3;
case 27:
if (!XMLDocumentScannerImpl.this.fEntityScanner.skipString(XMLDocumentScannerImpl.COMMENTSTRING))
XMLDocumentScannerImpl.this.reportFatalError("InvalidCommentStart", null);
XMLDocumentScannerImpl.this.scanComment();
XMLDocumentScannerImpl.this.setScannerState(44);
return 5;
case 22:
ch = XMLDocumentScannerImpl.this.fEntityScanner.peekChar();
if (ch == -1) {
XMLDocumentScannerImpl.this.setScannerState(34);
return 8;
}
XMLDocumentScannerImpl.this.reportFatalError("ContentIllegalInTrailingMisc", null);
XMLDocumentScannerImpl.this.fEntityScanner.scanChar();
XMLDocumentScannerImpl.this.setScannerState(44);
return 4;
case 28:
XMLDocumentScannerImpl.this.reportFatalError("ReferenceIllegalInTrailingMisc", null);
XMLDocumentScannerImpl.this.setScannerState(44);
return 9;
case 34:
XMLDocumentScannerImpl.this.setScannerState(48);
return 8;
case 48:
throw new NoSuchElementException("No more events to be parsed");
}
throw new XNIException("Scanner State " + XMLDocumentScannerImpl.this.fScannerState + " not Recognized ");
} catch (EOFException e) {
if (XMLDocumentScannerImpl.this.fMarkupDepth != 0) {
XMLDocumentScannerImpl.this.reportFatalError("PrematureEOF", null);
return -1;
}
System.out.println("EOFException thrown");
XMLDocumentScannerImpl.this.setScannerState(34);
return 8;
}
}
}
protected class XMLBufferListenerImpl implements XMLBufferListener {
public void refresh() {
refresh(0);
}
public void refresh(int refreshPosition) {
if (XMLDocumentScannerImpl.this.fReadingAttributes)
XMLDocumentScannerImpl.this.fAttributes.refresh();
if (XMLDocumentScannerImpl.this.fReadingDTD) {
Entity entity = XMLDocumentScannerImpl.this.fEntityScanner.getCurrentEntity();
if (entity instanceof Entity.ScannedEntity)
XMLDocumentScannerImpl.this.fEndPos = ((Entity.ScannedEntity)entity).position;
XMLDocumentScannerImpl.this.fDTDDecl.append(((Entity.ScannedEntity)entity).ch, XMLDocumentScannerImpl.this.fStartPos, XMLDocumentScannerImpl.this.fEndPos - XMLDocumentScannerImpl.this.fStartPos);
XMLDocumentScannerImpl.this.fStartPos = refreshPosition;
}
if (XMLDocumentScannerImpl.this.fScannerState == 37) {
XMLDocumentScannerImpl.this.fContentBuffer.append(XMLDocumentScannerImpl.this.fTempString);
XMLDocumentScannerImpl.this.fTempString.length = 0;
XMLDocumentScannerImpl.this.fUsebuffer = true;
}
}
}
}

View file

@ -0,0 +1,11 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XNIException;
import java.io.IOException;
public interface XMLEntityHandler {
void startEntity(String paramString1, XMLResourceIdentifier paramXMLResourceIdentifier, String paramString2) throws XNIException;
void endEntity(String paramString) throws XNIException, IOException;
}

View file

@ -0,0 +1,921 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.impl.io.ASCIIReader;
import com.sun.xml.stream.xerces.impl.io.UCSReader;
import com.sun.xml.stream.xerces.impl.io.UTF8Reader;
import com.sun.xml.stream.xerces.util.EncodingMap;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.URI;
import com.sun.xml.stream.xerces.util.XMLChar;
import com.sun.xml.stream.xerces.util.XMLResourceIdentifierImpl;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponent;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import com.sun.xml.stream.xerces.xni.parser.XMLEntityResolver;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Stack;
import java.util.Vector;
public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
public static final int DEFAULT_BUFFER_SIZE = 8192;
public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;
protected static final String VALIDATION = "http://xml.org/sax/features/validation";
protected static final String EXTERNAL_GENERAL_ENTITIES = "http://xml.org/sax/features/external-general-entities";
protected static final String EXTERNAL_PARAMETER_ENTITIES = "http://xml.org/sax/features/external-parameter-entities";
protected static final String ALLOW_JAVA_ENCODINGS = "http://apache.org/xml/features/allow-java-encodings";
protected static final String WARN_ON_DUPLICATE_ENTITYDEF = "http://apache.org/xml/features/warn-on-duplicate-entitydef";
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
protected static final String ENTITY_RESOLVER = "http://apache.org/xml/properties/internal/entity-resolver";
protected static final String STAX_ENTITY_RESOLVER = "http://apache.org/xml/properties/internal/stax-entity-resolver";
protected static final String VALIDATION_MANAGER = "http://apache.org/xml/properties/internal/validation-manager";
protected static final String BUFFER_SIZE = "http://apache.org/xml/properties/input-buffer-size";
private static final String[] RECOGNIZED_FEATURES = new String[] { "http://xml.org/sax/features/validation", "http://xml.org/sax/features/external-general-entities", "http://xml.org/sax/features/external-parameter-entities", "http://apache.org/xml/features/allow-java-encodings", "http://apache.org/xml/features/warn-on-duplicate-entitydef" };
private static final Boolean[] FEATURE_DEFAULTS = new Boolean[] { null, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE };
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://apache.org/xml/properties/internal/symbol-table", "http://apache.org/xml/properties/internal/error-reporter", "http://apache.org/xml/properties/internal/entity-resolver", "http://apache.org/xml/properties/internal/validation-manager", "http://apache.org/xml/properties/input-buffer-size" };
private static final Object[] PROPERTY_DEFAULTS = new Object[] { null, null, null, null, new Integer(8192) };
private static final String XMLEntity = "[xml]".intern();
private static final String DTDEntity = "[dtd]".intern();
private static final boolean DEBUG_BUFFER = false;
private static final boolean DEBUG_ENTITIES = false;
private static final boolean DEBUG_ENCODINGS = false;
private static final boolean DEBUG_RESOLVER = false;
protected boolean fValidation;
protected boolean fExternalGeneralEntities;
protected boolean fExternalParameterEntities;
protected boolean fAllowJavaEncodings = true;
protected SymbolTable fSymbolTable;
protected XMLErrorReporter fErrorReporter;
protected XMLEntityResolver fEntityResolver;
protected StaxEntityResolverWrapper fStaxEntityResolver;
protected PropertyManager fPropertyManager;
protected int fBufferSize = 8192;
protected boolean fStandalone;
protected boolean fInExternalSubset = false;
protected XMLEntityHandler fEntityHandler;
protected XMLEntityReaderImpl fEntityReader;
protected Hashtable fEntities = new Hashtable();
protected Stack fEntityStack = new Stack();
protected Entity.ScannedEntity fCurrentEntity = null;
protected Hashtable fDeclaredEntities;
protected XMLEntityStorage fEntityStorage;
protected final Object[] defaultEncoding = new Object[] { "UTF-8", null };
private final XMLResourceIdentifierImpl fResourceIdentifier = new XMLResourceIdentifierImpl();
public XMLEntityManager() {
this.fEntityStorage = new XMLEntityStorage(this);
this.fEntityReader = new XMLEntityReaderImpl(this);
}
public XMLEntityManager(PropertyManager propertyManager) {
this.fPropertyManager = propertyManager;
this.fEntityStorage = new XMLEntityStorage(this);
this.fEntityReader = new XMLEntityReaderImpl(propertyManager, this);
reset(propertyManager);
}
public XMLEntityStorage getEntityStore() {
return this.fEntityStorage;
}
public XMLEntityReader getEntityReader() {
return this.fEntityReader;
}
public void setStandalone(boolean standalone) {
this.fStandalone = standalone;
}
public boolean isStandalone() {
return this.fStandalone;
}
public void setEntityHandler(XMLEntityHandler entityHandler) {
this.fEntityHandler = entityHandler;
}
public StaxXMLInputSource resolveEntityAsPerStax(XMLResourceIdentifier resourceIdentifier) throws IOException {
if (resourceIdentifier == null)
return null;
String publicId = resourceIdentifier.getPublicId();
String literalSystemId = resourceIdentifier.getLiteralSystemId();
String baseSystemId = resourceIdentifier.getBaseSystemId();
String expandedSystemId = resourceIdentifier.getExpandedSystemId();
boolean needExpand = (expandedSystemId == null);
if (baseSystemId == null && this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) {
baseSystemId = this.fCurrentEntity.entityLocation.getExpandedSystemId();
if (baseSystemId != null)
needExpand = true;
}
if (needExpand)
expandedSystemId = expandSystemId(literalSystemId, baseSystemId);
StaxXMLInputSource xmlInputSource = null;
if (this.fStaxEntityResolver != null) {
XMLResourceIdentifierImpl ri = null;
if (resourceIdentifier instanceof XMLResourceIdentifierImpl) {
ri = (XMLResourceIdentifierImpl)resourceIdentifier;
} else {
this.fResourceIdentifier.clear();
ri = this.fResourceIdentifier;
}
ri.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
xmlInputSource = this.fStaxEntityResolver.resolveEntity(ri);
}
if (xmlInputSource == null) {
xmlInputSource = new StaxXMLInputSource(new XMLInputSource(publicId, literalSystemId, baseSystemId));
} else if (xmlInputSource.hasXMLStreamOrXMLEventReader()) {
}
return xmlInputSource;
}
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws IOException, XNIException {
if (resourceIdentifier == null)
return null;
String publicId = resourceIdentifier.getPublicId();
String literalSystemId = resourceIdentifier.getLiteralSystemId();
String baseSystemId = resourceIdentifier.getBaseSystemId();
String expandedSystemId = resourceIdentifier.getExpandedSystemId();
boolean needExpand = (expandedSystemId == null);
if (baseSystemId == null && this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) {
baseSystemId = this.fCurrentEntity.entityLocation.getExpandedSystemId();
if (baseSystemId != null)
needExpand = true;
}
if (needExpand)
expandedSystemId = expandSystemId(literalSystemId, baseSystemId);
XMLInputSource xmlInputSource = null;
if (this.fEntityResolver != null) {
XMLResourceIdentifierImpl ri = null;
if (resourceIdentifier instanceof XMLResourceIdentifierImpl) {
ri = (XMLResourceIdentifierImpl)resourceIdentifier;
} else {
this.fResourceIdentifier.clear();
ri = this.fResourceIdentifier;
}
ri.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
xmlInputSource = this.fEntityResolver.resolveEntity(ri);
}
if (xmlInputSource == null)
xmlInputSource = new XMLInputSource(publicId, literalSystemId, baseSystemId);
return xmlInputSource;
}
public void startEntity(String entityName, boolean literal) throws IOException, XNIException {
Entity entity = (Entity)this.fEntityStorage.getDeclaredEntities().get(entityName);
if (entity == null) {
if (this.fEntityHandler != null) {
String encoding = null;
this.fResourceIdentifier.clear();
this.fEntityHandler.startEntity(entityName, this.fResourceIdentifier, encoding);
this.fEntityHandler.endEntity(entityName);
}
return;
}
boolean external = entity.isExternal();
if (external) {
boolean unparsed = entity.isUnparsed();
boolean parameter = entityName.startsWith("%");
boolean general = !parameter;
this.fExternalGeneralEntities = external;
if (unparsed || (general && !this.fExternalGeneralEntities) || (parameter && !this.fExternalParameterEntities)) {
if (this.fEntityHandler != null) {
this.fResourceIdentifier.clear();
String encoding = null;
Entity.ExternalEntity externalEntity = (Entity.ExternalEntity)entity;
String extLitSysId = (externalEntity.entityLocation != null) ? externalEntity.entityLocation.getLiteralSystemId() : null;
String extBaseSysId = (externalEntity.entityLocation != null) ? externalEntity.entityLocation.getBaseSystemId() : null;
String expandedSystemId = expandSystemId(extLitSysId, extBaseSysId);
this.fResourceIdentifier.setValues((externalEntity.entityLocation != null) ? externalEntity.entityLocation.getPublicId() : null, extLitSysId, extBaseSysId, expandedSystemId);
this.fEntityHandler.startEntity(entityName, this.fResourceIdentifier, encoding);
}
return;
}
}
int size = this.fEntityStack.size();
for (int i = size; i >= 0; i--) {
Entity activeEntity = (i == size) ? this.fCurrentEntity : this.fEntityStack.elementAt(i);
if (activeEntity.name == entityName) {
String path = entityName;
for (int j = i + 1; j < size; j++) {
activeEntity = this.fEntityStack.elementAt(j);
path = path + " -> " + activeEntity.name;
}
path = path + " -> " + this.fCurrentEntity.name;
path = path + " -> " + entityName;
this.fErrorReporter.reportError(getEntityReader(), "http://www.w3.org/TR/1998/REC-xml-19980210", "RecursiveReference", new Object[] { entityName, path }, (short)2);
if (this.fEntityHandler != null) {
this.fResourceIdentifier.clear();
String encoding = null;
if (external) {
Entity.ExternalEntity externalEntity = (Entity.ExternalEntity)entity;
String extLitSysId = (externalEntity.entityLocation != null) ? externalEntity.entityLocation.getLiteralSystemId() : null;
String extBaseSysId = (externalEntity.entityLocation != null) ? externalEntity.entityLocation.getBaseSystemId() : null;
String expandedSystemId = expandSystemId(extLitSysId, extBaseSysId);
this.fResourceIdentifier.setValues((externalEntity.entityLocation != null) ? externalEntity.entityLocation.getPublicId() : null, extLitSysId, extBaseSysId, expandedSystemId);
}
this.fEntityHandler.startEntity(entityName, this.fResourceIdentifier, encoding);
}
return;
}
}
StaxXMLInputSource staxInputSource = null;
XMLInputSource xmlInputSource = null;
if (external) {
Entity.ExternalEntity externalEntity = (Entity.ExternalEntity)entity;
staxInputSource = resolveEntityAsPerStax(externalEntity.entityLocation);
xmlInputSource = staxInputSource.getXMLInputSource();
} else {
Entity.InternalEntity internalEntity = (Entity.InternalEntity)entity;
Reader reader = new StringReader(internalEntity.text);
xmlInputSource = new XMLInputSource(null, null, null, reader, null);
}
startEntity(entityName, xmlInputSource, literal, external);
}
public void startDocumentEntity(XMLInputSource xmlInputSource) throws IOException, XNIException {
startEntity(XMLEntity, xmlInputSource, false, true);
}
public void startDTDEntity(XMLInputSource xmlInputSource) throws IOException, XNIException {
startEntity(DTDEntity, xmlInputSource, false, true);
}
public void startExternalSubset() {
this.fInExternalSubset = true;
}
public void endExternalSubset() {
this.fInExternalSubset = false;
}
public void startEntity(String name, XMLInputSource xmlInputSource, boolean literal, boolean isExternal) throws IOException, XNIException {
String publicId = xmlInputSource.getPublicId();
String literalSystemId = xmlInputSource.getSystemId();
String baseSystemId = xmlInputSource.getBaseSystemId();
String encoding = xmlInputSource.getEncoding();
Boolean isBigEndian = null;
InputStream stream = null;
Reader reader = xmlInputSource.getCharacterStream();
String expandedSystemId = expandSystemId(literalSystemId, baseSystemId);
if (baseSystemId == null)
baseSystemId = expandedSystemId;
if (reader == null) {
stream = xmlInputSource.getByteStream();
if (stream == null)
stream = new BufferedInputStream(new URL(expandedSystemId).openStream());
stream = new RewindableInputStream(stream);
if (encoding == null) {
byte[] b4 = new byte[4];
int count = 0;
for (; count < 4; count++)
b4[count] = (byte)stream.read();
if (count == 4) {
Object[] encodingDesc = getEncodingName(b4, count);
encoding = (String)encodingDesc[0];
isBigEndian = (Boolean)encodingDesc[1];
stream.reset();
int offset = 0;
if (count > 2 && encoding.equals("UTF-8")) {
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
int b2 = b4[2] & 0xFF;
if (b0 == 239 && b1 == 187 && b2 == 191)
stream.skip(3L);
}
reader = createReader(stream, encoding, isBigEndian);
} else {
reader = createReader(stream, encoding, isBigEndian);
}
} else {
reader = createReader(stream, encoding, isBigEndian);
}
}
if (this.fCurrentEntity != null)
this.fEntityStack.push(this.fCurrentEntity);
this.fCurrentEntity = new Entity.ScannedEntity(name, new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandedSystemId), stream, reader, encoding, literal, false, isExternal);
this.fEntityReader.setCurrentEntity(this.fCurrentEntity);
this.fResourceIdentifier.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
if (this.fEntityHandler != null)
this.fEntityHandler.startEntity(name, this.fResourceIdentifier, encoding);
}
public Entity.ScannedEntity getCurrentEntity() {
return this.fCurrentEntity;
}
protected Vector fOwnReaders = new Vector();
private static String gUserDir;
private static String gEscapedUserDir;
public void closeReaders() {
for (int i = this.fOwnReaders.size() - 1; i >= 0; i--) {
try {
this.fOwnReaders.elementAt(i).close();
} catch (IOException e) {}
}
this.fOwnReaders.removeAllElements();
}
public void endEntity() throws IOException, XNIException {
if (this.fEntityHandler != null)
this.fEntityHandler.endEntity(this.fCurrentEntity.name);
if (this.fCurrentEntity != null)
try {
this.fCurrentEntity.reader.close();
} catch (IOException ex) {
throw new XNIException(ex);
}
this.fCurrentEntity = (this.fEntityStack.size() > 0) ? this.fEntityStack.pop() : null;
this.fEntityReader.setCurrentEntity(this.fCurrentEntity);
}
public void reset(PropertyManager propertyManager) {
this.fEntityStorage.reset(propertyManager);
this.fEntityReader.reset(propertyManager);
this.fSymbolTable = (SymbolTable)propertyManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)propertyManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
try {
this.fStaxEntityResolver = (StaxEntityResolverWrapper)propertyManager.getProperty("http://apache.org/xml/properties/internal/stax-entity-resolver");
} catch (XMLConfigurationException e) {
this.fStaxEntityResolver = null;
}
this.fEntities.clear();
this.fEntityStack.removeAllElements();
this.fCurrentEntity = null;
this.fValidation = false;
this.fExternalGeneralEntities = false;
this.fExternalParameterEntities = false;
this.fAllowJavaEncodings = true;
}
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
try {
this.fValidation = componentManager.getFeature("http://xml.org/sax/features/validation");
} catch (XMLConfigurationException e) {
this.fValidation = false;
}
try {
this.fExternalGeneralEntities = componentManager.getFeature("http://xml.org/sax/features/external-general-entities");
} catch (XMLConfigurationException e) {
this.fExternalGeneralEntities = true;
}
try {
this.fExternalParameterEntities = componentManager.getFeature("http://xml.org/sax/features/external-parameter-entities");
} catch (XMLConfigurationException e) {
this.fExternalParameterEntities = true;
}
try {
this.fAllowJavaEncodings = componentManager.getFeature("http://apache.org/xml/features/allow-java-encodings");
} catch (XMLConfigurationException e) {
this.fAllowJavaEncodings = false;
}
this.fSymbolTable = (SymbolTable)componentManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)componentManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
try {
this.fEntityResolver = (XMLEntityResolver)componentManager.getProperty("http://apache.org/xml/properties/internal/entity-resolver");
} catch (XMLConfigurationException e) {
this.fEntityResolver = null;
}
try {
this.fStaxEntityResolver = (StaxEntityResolverWrapper)componentManager.getProperty("http://apache.org/xml/properties/internal/stax-entity-resolver");
} catch (XMLConfigurationException e) {
this.fStaxEntityResolver = null;
}
this.fStandalone = false;
this.fEntities.clear();
this.fEntityStack.removeAllElements();
this.fCurrentEntity = null;
if (this.fDeclaredEntities != null) {
Enumeration keys = this.fDeclaredEntities.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = this.fDeclaredEntities.get(key);
this.fEntities.put(key, value);
}
}
}
public String[] getRecognizedFeatures() {
return (String[])RECOGNIZED_FEATURES.clone();
}
public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
if (featureId.startsWith("http://apache.org/xml/features/")) {
String feature = featureId.substring("http://apache.org/xml/features/".length());
if (feature.equals("allow-java-encodings"))
this.fAllowJavaEncodings = state;
}
}
public void setProperty(String name, Object value) {}
public String[] getRecognizedProperties() {
return (String[])RECOGNIZED_PROPERTIES.clone();
}
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId))
return FEATURE_DEFAULTS[i];
}
return null;
}
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId))
return PROPERTY_DEFAULTS[i];
}
return null;
}
public static String expandSystemId(String systemId) {
return expandSystemId(systemId, null);
}
private static boolean[] gNeedEscaping = new boolean[128];
private static char[] gAfterEscaping1 = new char[128];
private static char[] gAfterEscaping2 = new char[128];
private static char[] gHexChs = new char[] {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
static {
for (int i = 0; i <= 31; i++) {
gNeedEscaping[i] = true;
gAfterEscaping1[i] = gHexChs[i >> 4];
gAfterEscaping2[i] = gHexChs[i & 0xF];
}
gNeedEscaping[127] = true;
gAfterEscaping1[127] = '7';
gAfterEscaping2[127] = 'F';
char[] escChs = {
' ', '<', '>', '#', '%', '"', '{', '}', '|', '\\',
'^', '~', '[', ']', '`' };
int len = escChs.length;
for (int j = 0; j < len; j++) {
char ch = escChs[j];
gNeedEscaping[ch] = true;
gAfterEscaping1[ch] = gHexChs[ch >> 4];
gAfterEscaping2[ch] = gHexChs[ch & 0xF];
}
}
private static synchronized String getUserDir() {
String userDir = "";
try {
userDir = System.getProperty("user.dir");
} catch (SecurityException se) {}
if (userDir.length() == 0)
return "";
if (userDir.equals(gUserDir))
return gEscapedUserDir;
gUserDir = userDir;
char separator = File.separatorChar;
userDir = userDir.replace(separator, '/');
int len = userDir.length();
StringBuffer buffer = new StringBuffer(len * 3);
if (len >= 2 && userDir.charAt(1) == ':') {
int ch = Character.toUpperCase(userDir.charAt(0));
if (ch >= 65 && ch <= 90)
buffer.append('/');
}
int i = 0;
for (; i < len; i++) {
int ch = userDir.charAt(i);
if (ch >= 128)
break;
if (gNeedEscaping[ch]) {
buffer.append('%');
buffer.append(gAfterEscaping1[ch]);
buffer.append(gAfterEscaping2[ch]);
} else {
buffer.append((char)ch);
}
}
if (i < len) {
byte[] bytes = null;
try {
bytes = userDir.substring(i).getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
return userDir;
}
len = bytes.length;
for (i = 0; i < len; i++) {
byte b = bytes[i];
if (b < 0) {
int ch = b + 256;
buffer.append('%');
buffer.append(gHexChs[ch >> 4]);
buffer.append(gHexChs[ch & 0xF]);
} else if (gNeedEscaping[b]) {
buffer.append('%');
buffer.append(gAfterEscaping1[b]);
buffer.append(gAfterEscaping2[b]);
} else {
buffer.append((char)b);
}
}
}
if (!userDir.endsWith("/"))
buffer.append('/');
gEscapedUserDir = buffer.toString();
return gEscapedUserDir;
}
public static String expandSystemId(String systemId, String baseSystemId) {
if (systemId == null || systemId.length() == 0)
return systemId;
try {
URI uRI = new URI(systemId);
if (uRI != null)
return systemId;
} catch (URI.MalformedURIException e) {}
String id = fixURI(systemId);
URI base = null;
URI uri = null;
try {
if (baseSystemId == null || baseSystemId.length() == 0 || baseSystemId.equals(systemId)) {
String dir = getUserDir();
base = new URI("file", "", dir, null, null);
} else {
try {
base = new URI(fixURI(baseSystemId));
} catch (URI.MalformedURIException e) {
if (baseSystemId.indexOf(':') != -1) {
base = new URI("file", "", fixURI(baseSystemId), null, null);
} else {
String dir = getUserDir();
dir = dir + fixURI(baseSystemId);
base = new URI("file", "", dir, null, null);
}
}
}
uri = new URI(base, id);
} catch (Exception e) {}
if (uri == null)
return systemId;
return uri.toString();
}
protected Object[] getEncodingName(byte[] b4, int count) {
if (count < 2)
return this.defaultEncoding;
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
if (b0 == 254 && b1 == 255)
return new Object[] { "UTF-16BE", new Boolean(true) };
if (b0 == 255 && b1 == 254)
return new Object[] { "UTF-16LE", new Boolean(false) };
if (count < 3)
return this.defaultEncoding;
int b2 = b4[2] & 0xFF;
if (b0 == 239 && b1 == 187 && b2 == 191)
return this.defaultEncoding;
if (count < 4)
return this.defaultEncoding;
int b3 = b4[3] & 0xFF;
if (b0 == 0 && b1 == 0 && b2 == 0 && b3 == 60)
return new Object[] { "ISO-10646-UCS-4", new Boolean(true) };
if (b0 == 60 && b1 == 0 && b2 == 0 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", new Boolean(false) };
if (b0 == 0 && b1 == 0 && b2 == 60 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", null };
if (b0 == 0 && b1 == 60 && b2 == 0 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", null };
if (b0 == 0 && b1 == 60 && b2 == 0 && b3 == 63)
return new Object[] { "UTF-16BE", new Boolean(true) };
if (b0 == 60 && b1 == 0 && b2 == 63 && b3 == 0)
return new Object[] { "UTF-16LE", new Boolean(false) };
if (b0 == 76 && b1 == 111 && b2 == 167 && b3 == 148)
return new Object[] { "CP037", null };
return this.defaultEncoding;
}
protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian) throws IOException {
if (encoding == null)
encoding = "UTF-8";
String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
if (ENCODING.equals("UTF-8"))
return new UTF8Reader(inputStream, this.fBufferSize, this.fErrorReporter.getMessageFormatter("http://www.w3.org/TR/1998/REC-xml-19980210"), this.fErrorReporter.getLocale());
if (ENCODING.equals("US-ASCII"))
return new ASCIIReader(inputStream, this.fBufferSize, this.fErrorReporter.getMessageFormatter("http://www.w3.org/TR/1998/REC-xml-19980210"), this.fErrorReporter.getLocale());
if (ENCODING.equals("ISO-10646-UCS-4")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian;
if (isBE)
return new UCSReader(inputStream, (short)8);
return new UCSReader(inputStream, (short)4);
}
this.fErrorReporter.reportError(getEntityReader(), "http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingByteOrderUnsupported", new Object[] { encoding }, (short)2);
}
if (ENCODING.equals("ISO-10646-UCS-2")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian;
if (isBE)
return new UCSReader(inputStream, (short)2);
return new UCSReader(inputStream, (short)1);
}
this.fErrorReporter.reportError(getEntityReader(), "http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingByteOrderUnsupported", new Object[] { encoding }, (short)2);
}
boolean validIANA = XMLChar.isValidIANAEncoding(encoding);
boolean validJava = XMLChar.isValidJavaEncoding(encoding);
if (!validIANA || (this.fAllowJavaEncodings && !validJava)) {
this.fErrorReporter.reportError(getEntityReader(), "http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingDeclInvalid", new Object[] { encoding }, (short)2);
encoding = "ISO-8859-1";
}
String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING);
if (javaEncoding == null)
if (this.fAllowJavaEncodings) {
javaEncoding = encoding;
} else {
this.fErrorReporter.reportError(getEntityReader(), "http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingDeclInvalid", new Object[] { encoding }, (short)2);
javaEncoding = "ISO8859_1";
}
return new BufferedReader(new InputStreamReader(inputStream, javaEncoding));
}
public String getPublicId() {
return (this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) ? this.fCurrentEntity.entityLocation.getPublicId() : null;
}
public String getExpandedSystemId() {
if (this.fCurrentEntity != null) {
if (this.fCurrentEntity.entityLocation != null && this.fCurrentEntity.entityLocation.getExpandedSystemId() != null)
return this.fCurrentEntity.entityLocation.getExpandedSystemId();
int size = this.fEntityStack.size();
for (int i = size - 1; i >= 0; i--) {
Entity.ScannedEntity externalEntity = this.fEntityStack.elementAt(i);
if (externalEntity.entityLocation != null && externalEntity.entityLocation.getExpandedSystemId() != null)
return externalEntity.entityLocation.getExpandedSystemId();
}
}
return null;
}
public String getLiteralSystemId() {
if (this.fCurrentEntity != null) {
if (this.fCurrentEntity.entityLocation != null && this.fCurrentEntity.entityLocation.getLiteralSystemId() != null)
return this.fCurrentEntity.entityLocation.getLiteralSystemId();
int size = this.fEntityStack.size();
for (int i = size - 1; i >= 0; i--) {
Entity.ScannedEntity externalEntity = this.fEntityStack.elementAt(i);
if (externalEntity.entityLocation != null && externalEntity.entityLocation.getLiteralSystemId() != null)
return externalEntity.entityLocation.getLiteralSystemId();
}
}
return null;
}
public int getLineNumber() {
if (this.fCurrentEntity != null) {
if (this.fCurrentEntity.isExternal())
return this.fCurrentEntity.lineNumber;
int size = this.fEntityStack.size();
for (int i = size - 1; i > 0; i--) {
Entity.ScannedEntity firstExternalEntity = this.fEntityStack.elementAt(i);
if (firstExternalEntity.isExternal())
return firstExternalEntity.lineNumber;
}
}
return -1;
}
public int getColumnNumber() {
if (this.fCurrentEntity != null) {
if (this.fCurrentEntity.isExternal())
return this.fCurrentEntity.columnNumber;
int size = this.fEntityStack.size();
for (int i = size - 1; i > 0; i--) {
Entity.ScannedEntity firstExternalEntity = this.fEntityStack.elementAt(i);
if (firstExternalEntity.isExternal())
return firstExternalEntity.columnNumber;
}
}
return -1;
}
protected static String fixURI(String str) {
str = str.replace(File.separatorChar, '/');
if (str.length() >= 2) {
char ch1 = str.charAt(1);
if (ch1 == ':') {
char ch0 = Character.toUpperCase(str.charAt(0));
if (ch0 >= 'A' && ch0 <= 'Z')
str = "/" + str;
} else if (ch1 == '/' && str.charAt(0) == '/') {
str = "file:" + str;
}
}
return str;
}
final void print() {}
protected final class RewindableInputStream extends InputStream {
private InputStream fInputStream;
private byte[] fData;
private int fStartOffset;
private int fEndOffset;
private int fOffset;
private int fLength;
private int fMark;
public RewindableInputStream(InputStream is) {
this.fData = new byte[64];
this.fInputStream = is;
this.fStartOffset = 0;
this.fEndOffset = -1;
this.fOffset = 0;
this.fLength = 0;
this.fMark = 0;
}
public void setStartOffset(int offset) {
this.fStartOffset = offset;
}
public void rewind() {
this.fOffset = this.fStartOffset;
}
public int read() throws IOException {
int b = 0;
if (this.fOffset < this.fLength)
return this.fData[this.fOffset++] & 0xFF;
if (this.fOffset == this.fEndOffset)
return -1;
if (this.fOffset == this.fData.length) {
byte[] newData = new byte[this.fOffset << 1];
System.arraycopy(this.fData, 0, newData, 0, this.fOffset);
this.fData = newData;
}
b = this.fInputStream.read();
if (b == -1) {
this.fEndOffset = this.fOffset;
return -1;
}
this.fData[this.fLength++] = (byte)b;
this.fOffset++;
return b & 0xFF;
}
public int read(byte[] b, int off, int len) throws IOException {
int bytesLeft = this.fLength - this.fOffset;
if (bytesLeft == 0) {
if (this.fOffset == this.fEndOffset)
return -1;
return this.fInputStream.read(b, off, len);
}
if (len < bytesLeft) {
if (len <= 0)
return 0;
} else {
len = bytesLeft;
}
if (b != null)
System.arraycopy(this.fData, this.fOffset, b, off, len);
this.fOffset += len;
return len;
}
public long skip(long n) throws IOException {
if (n <= 0L)
return 0L;
int bytesLeft = this.fLength - this.fOffset;
if (bytesLeft == 0) {
if (this.fOffset == this.fEndOffset)
return 0L;
return this.fInputStream.skip(n);
}
if (n <= (long)bytesLeft) {
this.fOffset = (int)((long)this.fOffset + n);
return n;
}
this.fOffset += bytesLeft;
if (this.fOffset == this.fEndOffset)
return (long)bytesLeft;
n -= (long)bytesLeft;
return this.fInputStream.skip(n) + (long)bytesLeft;
}
public int available() throws IOException {
int bytesLeft = this.fLength - this.fOffset;
if (bytesLeft == 0) {
if (this.fOffset == this.fEndOffset)
return -1;
return XMLEntityManager.this.fCurrentEntity.mayReadChunks ? this.fInputStream.available() : 0;
}
return bytesLeft;
}
public void mark(int howMuch) {
this.fMark = this.fOffset;
}
public void reset() {
this.fOffset = this.fMark;
}
public boolean markSupported() {
return true;
}
public void close() throws IOException {
if (this.fInputStream != null) {
this.fInputStream.close();
this.fInputStream = null;
}
}
}
public void test() {
this.fEntityStorage.addExternalEntity("entityUsecase1", null, "/space/home/stax/sun/6thJan2004/zephyr/data/test.txt", "/space/home/stax/sun/6thJan2004/zephyr/data/entity.xml");
this.fEntityStorage.addInternalEntity("entityUsecase2", "<Test>value</Test>");
this.fEntityStorage.addInternalEntity("entityUsecase3", "value3");
this.fEntityStorage.addInternalEntity("text", "Hello World.");
this.fEntityStorage.addInternalEntity("empty-element", "<foo/>");
this.fEntityStorage.addInternalEntity("balanced-element", "<foo></foo>");
this.fEntityStorage.addInternalEntity("balanced-element-with-text", "<foo>Hello, World</foo>");
this.fEntityStorage.addInternalEntity("balanced-element-with-entity", "<foo>&text;</foo>");
this.fEntityStorage.addInternalEntity("unbalanced-entity", "<foo>");
this.fEntityStorage.addInternalEntity("recursive-entity", "<foo>&recursive-entity2;</foo>");
this.fEntityStorage.addInternalEntity("recursive-entity2", "<bar>&recursive-entity3;</bar>");
this.fEntityStorage.addInternalEntity("recursive-entity3", "<baz>&recursive-entity;</baz>");
this.fEntityStorage.addInternalEntity("ch", "&#x00A9;");
this.fEntityStorage.addInternalEntity("ch1", "&#84;");
this.fEntityStorage.addInternalEntity("% ch2", "param");
}
}

View file

@ -0,0 +1,45 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.util.XMLStringBuffer;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLLocator;
import com.sun.xml.stream.xerces.xni.XMLString;
import java.io.IOException;
public abstract class XMLEntityReader implements XMLLocator {
public abstract void setEncoding(String paramString) throws IOException;
public abstract String getEncoding();
public abstract int getCharacterOffset();
public abstract void setVersion(String paramString);
public abstract String getVersion();
public abstract boolean isExternal();
public abstract int peekChar() throws IOException;
public abstract int scanChar() throws IOException;
public abstract String scanNmtoken() throws IOException;
public abstract String scanName() throws IOException;
public abstract boolean scanQName(QName paramQName) throws IOException;
public abstract int scanContent(XMLString paramXMLString) throws IOException;
public abstract int scanLiteral(int paramInt, XMLString paramXMLString) throws IOException;
public abstract boolean scanData(String paramString, XMLStringBuffer paramXMLStringBuffer) throws IOException;
public abstract boolean skipChar(int paramInt) throws IOException;
public abstract boolean skipSpaces() throws IOException;
public abstract boolean skipString(String paramString) throws IOException;
public abstract void registerListener(XMLBufferListener paramXMLBufferListener);
}

View file

@ -0,0 +1,961 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.impl.io.ASCIIReader;
import com.sun.xml.stream.xerces.impl.io.UCSReader;
import com.sun.xml.stream.xerces.impl.io.UTF8Reader;
import com.sun.xml.stream.xerces.util.EncodingMap;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.XMLChar;
import com.sun.xml.stream.xerces.util.XMLStringBuffer;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Locale;
import java.util.Vector;
public class XMLEntityReaderImpl extends XMLEntityReader {
protected Entity.ScannedEntity fCurrentEntity = null;
protected XMLEntityManager fEntityManager;
private static final boolean DEBUG_ENCODINGS = false;
private Vector listeners = new Vector();
public static final boolean[] validContent = new boolean[127];
public static final boolean[] validNames = new boolean[127];
private static final boolean DEBUG_BUFFER = false;
private static final boolean DEBUG_SKIP_STRING = false;
protected SymbolTable fSymbolTable = null;
protected XMLErrorReporter fErrorReporter = null;
int[] whiteSpaceLookup = new int[100];
int whiteSpaceLen = 0;
boolean whiteSpaceInfoNeeded = true;
char[] scannedName = null;
protected boolean fAllowJavaEncodings;
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
protected static final String ALLOW_JAVA_ENCODINGS = "http://apache.org/xml/features/allow-java-encodings";
protected PropertyManager fPropertyManager = null;
boolean isExternal = false;
static {
for (char c = ' '; c < '\u007F'; c = (char)(c + 1))
validContent[c] = true;
validContent[9] = true;
validContent[38] = false;
validContent[60] = false;
for (int k = 65; k <= 90; k++)
validNames[k] = true;
for (int j = 97; j <= 122; j++)
validNames[j] = true;
for (int i = 48; i <= 57; i++)
validNames[i] = true;
validNames[45] = true;
validNames[46] = true;
validNames[58] = true;
validNames[95] = true;
}
public XMLEntityReaderImpl(XMLEntityManager entityManager) {
this.fEntityManager = entityManager;
}
public XMLEntityReaderImpl(PropertyManager propertyManager, XMLEntityManager entityManager) {
this.fEntityManager = entityManager;
reset(propertyManager);
}
public void reset(PropertyManager propertyManager) {
this.fSymbolTable = (SymbolTable)propertyManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)propertyManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
this.fCurrentEntity = null;
this.whiteSpaceLen = 0;
this.whiteSpaceInfoNeeded = true;
this.scannedName = null;
this.listeners.clear();
}
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
try {
this.fAllowJavaEncodings = componentManager.getFeature("http://apache.org/xml/features/allow-java-encodings");
} catch (XMLConfigurationException e) {
this.fAllowJavaEncodings = false;
}
this.fSymbolTable = (SymbolTable)componentManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)componentManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
}
public void setCurrentEntity(Entity.ScannedEntity scannedEntity) {
this.fCurrentEntity = scannedEntity;
if (this.fCurrentEntity != null)
this.isExternal = this.fCurrentEntity.isExternal();
}
public Entity.ScannedEntity getCurrentEntity() {
return this.fCurrentEntity;
}
public String getBaseSystemId() {
return (this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) ? this.fCurrentEntity.entityLocation.getExpandedSystemId() : null;
}
public int getLineNumber() {
return (this.fCurrentEntity != null) ? this.fCurrentEntity.lineNumber : -1;
}
public int getColumnNumber() {
return (this.fCurrentEntity != null) ? this.fCurrentEntity.columnNumber : -1;
}
public int getCharacterOffset() {
return (this.fCurrentEntity != null) ? (this.fCurrentEntity.fTotalCountTillLastLoad + this.fCurrentEntity.position) : -1;
}
public String getExpandedSystemId() {
return (this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) ? this.fCurrentEntity.entityLocation.getExpandedSystemId() : null;
}
public String getLiteralSystemId() {
return (this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) ? this.fCurrentEntity.entityLocation.getLiteralSystemId() : null;
}
public String getPublicId() {
return (this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null) ? this.fCurrentEntity.entityLocation.getPublicId() : null;
}
public void setVersion(String version) {
this.fCurrentEntity.version = version;
}
public String getVersion() {
return this.fCurrentEntity.version;
}
public String getEncoding() {
return this.fCurrentEntity.encoding;
}
public void setEncoding(String encoding) throws IOException {
if (this.fCurrentEntity.stream != null)
if (this.fCurrentEntity.encoding == null || !this.fCurrentEntity.encoding.equals(encoding)) {
if (this.fCurrentEntity.encoding != null && this.fCurrentEntity.encoding.startsWith("UTF-16")) {
String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
if (ENCODING.equals("UTF-16"))
return;
if (ENCODING.equals("ISO-10646-UCS-4")) {
if (this.fCurrentEntity.encoding.equals("UTF-16BE")) {
this.fCurrentEntity.reader = new UCSReader(this.fCurrentEntity.stream, (short)8);
} else {
this.fCurrentEntity.reader = new UCSReader(this.fCurrentEntity.stream, (short)4);
}
return;
}
if (ENCODING.equals("ISO-10646-UCS-2")) {
if (this.fCurrentEntity.encoding.equals("UTF-16BE")) {
this.fCurrentEntity.reader = new UCSReader(this.fCurrentEntity.stream, (short)2);
} else {
this.fCurrentEntity.reader = new UCSReader(this.fCurrentEntity.stream, (short)1);
}
return;
}
}
this.fCurrentEntity.reader = createReader(this.fCurrentEntity.stream, encoding, null);
this.fCurrentEntity.encoding = encoding;
}
}
public boolean isExternal() {
return this.fCurrentEntity.isExternal();
}
public int getChar(int relative) throws IOException {
if (arrangeCapacity(relative + 1, false))
return this.fCurrentEntity.ch[this.fCurrentEntity.position + relative];
return -1;
}
public int peekChar() throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
int c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (this.isExternal)
return (c != 13) ? c : 10;
return c;
}
public int scanChar() throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
int c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (c == 10 || (c == 13 && this.isExternal)) {
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(1);
this.fCurrentEntity.ch[0] = (char)c;
load(1, false);
}
if (c == 13 && this.isExternal) {
if (this.fCurrentEntity.ch[this.fCurrentEntity.position++] != '\n')
this.fCurrentEntity.position--;
c = 10;
}
}
this.fCurrentEntity.columnNumber++;
return c;
}
public String scanNmtoken() throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
int offset = this.fCurrentEntity.position;
boolean vc = false;
while (true) {
char c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (c < '\u007F') {
vc = validNames[c];
} else {
vc = XMLChar.isName(c);
}
if (!vc)
break;
if (++this.fCurrentEntity.position == this.fCurrentEntity.count) {
int i = this.fCurrentEntity.position - offset;
invokeListeners(i);
if (i == this.fCurrentEntity.fBufferSize) {
char[] tmp = new char[this.fCurrentEntity.fBufferSize * 2];
System.arraycopy(this.fCurrentEntity.ch, offset, tmp, 0, i);
this.fCurrentEntity.ch = tmp;
this.fCurrentEntity.fBufferSize *= 2;
} else {
System.arraycopy(this.fCurrentEntity.ch, offset, this.fCurrentEntity.ch, 0, i);
}
offset = 0;
if (load(i, false))
break;
}
}
int length = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += length;
String symbol = null;
if (length > 0)
symbol = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, offset, length);
return symbol;
}
public String scanName() throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
int offset = this.fCurrentEntity.position;
if (XMLChar.isNameStart(this.fCurrentEntity.ch[offset])) {
if (++this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(1);
this.fCurrentEntity.ch[0] = this.fCurrentEntity.ch[offset];
offset = 0;
if (load(1, false)) {
this.fCurrentEntity.columnNumber++;
String str = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, 0, 1);
this.scannedName = this.fSymbolTable.getCharArray();
return str;
}
}
boolean vc = false;
while (true) {
char c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (c < '\u007F') {
vc = validNames[c];
} else {
vc = XMLChar.isName(c);
}
if (!vc)
break;
if (++this.fCurrentEntity.position == this.fCurrentEntity.count) {
int i = this.fCurrentEntity.position - offset;
invokeListeners(i);
if (i == this.fCurrentEntity.fBufferSize) {
char[] tmp = new char[this.fCurrentEntity.fBufferSize * 2];
System.arraycopy(this.fCurrentEntity.ch, offset, tmp, 0, i);
this.fCurrentEntity.ch = tmp;
this.fCurrentEntity.fBufferSize *= 2;
} else {
System.arraycopy(this.fCurrentEntity.ch, offset, this.fCurrentEntity.ch, 0, i);
}
offset = 0;
if (load(i, false))
break;
}
}
}
int length = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += length;
String symbol = null;
if (length > 0) {
symbol = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, offset, length);
this.scannedName = this.fSymbolTable.getCharArray();
}
return symbol;
}
public boolean scanQName(QName qname) throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
int offset = this.fCurrentEntity.position;
if (XMLChar.isNameStart(this.fCurrentEntity.ch[offset])) {
if (++this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(1);
this.fCurrentEntity.ch[0] = this.fCurrentEntity.ch[offset];
offset = 0;
if (load(1, false)) {
this.fCurrentEntity.columnNumber++;
String name = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, 0, 1);
qname.setValues(null, name, name, null);
qname.characters = this.fSymbolTable.getCharArray();
return true;
}
}
int index = -1;
boolean vc = false;
while (true) {
char c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (c < '\u007F') {
vc = validNames[c];
} else {
vc = XMLChar.isName(c);
}
if (!vc)
break;
if (c == ':') {
if (index != -1)
break;
index = this.fCurrentEntity.position;
}
if (++this.fCurrentEntity.position == this.fCurrentEntity.count) {
int i = this.fCurrentEntity.position - offset;
invokeListeners(i);
if (i == this.fCurrentEntity.fBufferSize) {
char[] tmp = new char[this.fCurrentEntity.fBufferSize * 2];
System.arraycopy(this.fCurrentEntity.ch, offset, tmp, 0, i);
this.fCurrentEntity.ch = tmp;
this.fCurrentEntity.fBufferSize *= 2;
} else {
System.arraycopy(this.fCurrentEntity.ch, offset, this.fCurrentEntity.ch, 0, i);
}
if (index != -1)
index -= offset;
offset = 0;
if (load(i, false))
break;
}
}
int length = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += length;
if (length > 0) {
String prefix = null;
String localpart = null;
String rawname = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, offset, length);
qname.characters = this.fSymbolTable.getCharArray();
if (index != -1) {
int prefixLength = index - offset;
prefix = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, offset, prefixLength);
int len = length - prefixLength - 1;
localpart = this.fSymbolTable.addSymbol(this.fCurrentEntity.ch, index + 1, len);
} else {
localpart = rawname;
}
qname.setValues(prefix, localpart, rawname, null);
return true;
}
}
return false;
}
public int scanContent(XMLString content) throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
} else if (this.fCurrentEntity.position == this.fCurrentEntity.count - 1) {
invokeListeners(0);
this.fCurrentEntity.ch[0] = this.fCurrentEntity.ch[this.fCurrentEntity.count - 1];
load(1, false);
this.fCurrentEntity.position = 0;
}
int offset = this.fCurrentEntity.position;
int c = this.fCurrentEntity.ch[offset];
int newlines = 0;
if (c == 10 || (c == 13 && this.isExternal)) {
do {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (c == 13 && this.isExternal) {
newlines++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
offset = 0;
invokeListeners(newlines);
this.fCurrentEntity.position = newlines;
if (load(newlines, false))
break;
}
if (this.fCurrentEntity.ch[this.fCurrentEntity.position] == '\n') {
this.fCurrentEntity.position++;
offset++;
} else {
newlines++;
}
} else if (c == 10) {
newlines++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
offset = 0;
invokeListeners(newlines);
this.fCurrentEntity.position = newlines;
if (load(newlines, false))
break;
}
} else {
this.fCurrentEntity.position--;
break;
}
} while (this.fCurrentEntity.position < this.fCurrentEntity.count - 1);
for (int i = offset; i < this.fCurrentEntity.position; i++)
this.fCurrentEntity.ch[i] = '\n';
int j = this.fCurrentEntity.position - offset;
if (this.fCurrentEntity.position == this.fCurrentEntity.count - 1) {
content.setValues(this.fCurrentEntity.ch, offset, j);
return -1;
}
}
boolean vc = false;
while (this.fCurrentEntity.position < this.fCurrentEntity.count) {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (c < 127) {
vc = validContent[c];
} else {
vc = XMLChar.isContent(c);
}
if (!vc) {
this.fCurrentEntity.position--;
break;
}
}
int length = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += length - newlines;
content.setValues(this.fCurrentEntity.ch, offset, length);
if (this.fCurrentEntity.position != this.fCurrentEntity.count) {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (c == 13 && this.isExternal)
c = 10;
} else {
c = -1;
}
return c;
}
public int scanLiteral(int quote, XMLString content) throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
} else if (this.fCurrentEntity.position == this.fCurrentEntity.count - 1) {
invokeListeners(0);
this.fCurrentEntity.ch[0] = this.fCurrentEntity.ch[this.fCurrentEntity.count - 1];
load(1, false);
this.fCurrentEntity.position = 0;
}
int offset = this.fCurrentEntity.position;
int c = this.fCurrentEntity.ch[offset];
int newlines = 0;
if (this.whiteSpaceInfoNeeded)
this.whiteSpaceLen = 0;
if (c == 10 || (c == 13 && this.isExternal)) {
do {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (c == 13 && this.isExternal) {
newlines++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(newlines);
offset = 0;
this.fCurrentEntity.position = newlines;
if (load(newlines, false))
break;
}
if (this.fCurrentEntity.ch[this.fCurrentEntity.position] == '\n') {
this.fCurrentEntity.position++;
offset++;
} else {
newlines++;
}
} else if (c == 10) {
newlines++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
offset = 0;
invokeListeners(newlines);
this.fCurrentEntity.position = newlines;
if (load(newlines, false))
break;
}
} else {
this.fCurrentEntity.position--;
break;
}
} while (this.fCurrentEntity.position < this.fCurrentEntity.count - 1);
int i = 0;
for (i = offset; i < this.fCurrentEntity.position; i++) {
this.fCurrentEntity.ch[i] = '\n';
this.whiteSpaceLookup[this.whiteSpaceLen++] = i;
}
int j = this.fCurrentEntity.position - offset;
if (this.fCurrentEntity.position == this.fCurrentEntity.count - 1) {
content.setValues(this.fCurrentEntity.ch, offset, j);
return -1;
}
}
boolean vc = true;
while (this.fCurrentEntity.position < this.fCurrentEntity.count) {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if ((c == quote && (!this.fCurrentEntity.literal || this.isExternal)) || c == 37) {
this.fCurrentEntity.position--;
break;
}
if (c < 127) {
vc = validContent[c];
} else {
vc = XMLChar.isContent(c);
}
if (!vc) {
this.fCurrentEntity.position--;
break;
}
if (this.whiteSpaceInfoNeeded && (
c == 32 || c == 9)) {
if (this.whiteSpaceLen < this.whiteSpaceLookup.length) {
this.whiteSpaceLookup[this.whiteSpaceLen++] = this.fCurrentEntity.position - 1;
continue;
}
int[] tmp = new int[this.whiteSpaceLookup.length + 20];
System.arraycopy(this.whiteSpaceLookup, 0, tmp, 0, this.whiteSpaceLookup.length);
this.whiteSpaceLookup = tmp;
this.whiteSpaceLookup[this.whiteSpaceLen++] = this.fCurrentEntity.position - 1;
}
}
int length = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += length - newlines;
content.setValues(this.fCurrentEntity.ch, offset, length);
if (this.fCurrentEntity.position != this.fCurrentEntity.count) {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (c == quote && this.fCurrentEntity.literal)
c = -1;
} else {
c = -1;
}
return c;
}
public boolean scanData(String delimiter, XMLStringBuffer buffer) throws IOException {
boolean done = false;
int delimLen = delimiter.length();
char charAt0 = delimiter.charAt(0);
while (true) {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
} else if (this.fCurrentEntity.position >= this.fCurrentEntity.count - delimLen) {
invokeListeners(this.fCurrentEntity.count - this.fCurrentEntity.position);
System.arraycopy(this.fCurrentEntity.ch, this.fCurrentEntity.position, this.fCurrentEntity.ch, 0, this.fCurrentEntity.count - this.fCurrentEntity.position);
load(this.fCurrentEntity.count - this.fCurrentEntity.position, false);
this.fCurrentEntity.position = 0;
}
if (this.fCurrentEntity.position >= this.fCurrentEntity.count - delimLen) {
invokeListeners(0);
int i = this.fCurrentEntity.count - this.fCurrentEntity.position;
buffer.append(this.fCurrentEntity.ch, this.fCurrentEntity.position, i);
this.fCurrentEntity.columnNumber += this.fCurrentEntity.count;
this.fCurrentEntity.position = this.fCurrentEntity.count;
load(0, true);
return false;
}
int offset = this.fCurrentEntity.position;
int c = this.fCurrentEntity.ch[offset];
int newlines = 0;
if (c == 10 || (c == 13 && this.isExternal)) {
do {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (c == 13 && this.isExternal) {
newlines++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
offset = 0;
invokeListeners(newlines);
this.fCurrentEntity.position = newlines;
if (load(newlines, false))
break;
}
if (this.fCurrentEntity.ch[this.fCurrentEntity.position] == '\n') {
this.fCurrentEntity.position++;
offset++;
} else {
newlines++;
}
} else if (c == 10) {
newlines++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
offset = 0;
invokeListeners(newlines);
this.fCurrentEntity.position = newlines;
this.fCurrentEntity.count = newlines;
if (load(newlines, false))
break;
}
} else {
this.fCurrentEntity.position--;
break;
}
} while (this.fCurrentEntity.position < this.fCurrentEntity.count - 1);
for (int i = offset; i < this.fCurrentEntity.position; i++)
this.fCurrentEntity.ch[i] = '\n';
int j = this.fCurrentEntity.position - offset;
if (this.fCurrentEntity.position == this.fCurrentEntity.count - 1) {
buffer.append(this.fCurrentEntity.ch, offset, j);
return true;
}
}
label81: while (this.fCurrentEntity.position < this.fCurrentEntity.count) {
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (c == charAt0) {
int delimOffset = this.fCurrentEntity.position - 1;
for (int i = 1; i < delimLen; i++) {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
this.fCurrentEntity.position -= i;
break label81;
}
c = this.fCurrentEntity.ch[this.fCurrentEntity.position++];
if (delimiter.charAt(i) != c) {
this.fCurrentEntity.position -= i;
break;
}
}
if (this.fCurrentEntity.position == delimOffset + delimLen) {
done = true;
break;
}
continue;
}
if (c == 10 || (this.isExternal && c == 13)) {
this.fCurrentEntity.position--;
break;
}
if (XMLChar.isInvalid(c)) {
this.fCurrentEntity.position--;
int i = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += i - newlines;
buffer.append(this.fCurrentEntity.ch, offset, i);
return true;
}
}
int length = this.fCurrentEntity.position - offset;
this.fCurrentEntity.columnNumber += length - newlines;
if (done)
length -= delimLen;
buffer.append(this.fCurrentEntity.ch, offset, length);
if (done)
return !done;
}
}
public boolean skipChar(int c) throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
int cc = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (cc == c) {
this.fCurrentEntity.position++;
if (c == 10) {
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
} else {
this.fCurrentEntity.columnNumber++;
}
return true;
}
if (c == 10 && cc == 13 && this.isExternal) {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(1);
this.fCurrentEntity.ch[0] = (char)cc;
load(1, false);
}
this.fCurrentEntity.position++;
if (this.fCurrentEntity.ch[this.fCurrentEntity.position] == '\n')
this.fCurrentEntity.position++;
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
return true;
}
return false;
}
public boolean isSpace(char ch) {
return (ch == ' ' || ch == '\n' || ch == '\t' || ch == '\r');
}
public boolean skipSpaces() throws IOException {
if (this.fCurrentEntity.position == this.fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
if (this.fCurrentEntity == null)
return false;
int c = this.fCurrentEntity.ch[this.fCurrentEntity.position];
if (XMLChar.isSpace(c)) {
do {
boolean entityChanged = false;
if (c == 10 || (this.isExternal && c == 13)) {
this.fCurrentEntity.lineNumber++;
this.fCurrentEntity.columnNumber = 1;
if (this.fCurrentEntity.position == this.fCurrentEntity.count - 1) {
invokeListeners(0);
this.fCurrentEntity.ch[0] = (char)c;
entityChanged = load(1, true);
if (!entityChanged) {
this.fCurrentEntity.position = 0;
} else if (this.fCurrentEntity == null) {
return true;
}
}
if (c == 13 && this.isExternal)
if (this.fCurrentEntity.ch[++this.fCurrentEntity.position] != '\n')
this.fCurrentEntity.position--;
} else {
this.fCurrentEntity.columnNumber++;
}
if (!entityChanged)
this.fCurrentEntity.position++;
if (this.fCurrentEntity.position != this.fCurrentEntity.count)
continue;
invokeListeners(0);
load(0, true);
if (this.fCurrentEntity == null)
return true;
} while (XMLChar.isSpace(c = this.fCurrentEntity.ch[this.fCurrentEntity.position]));
return true;
}
return false;
}
public boolean arrangeCapacity(int length) throws IOException {
return arrangeCapacity(length, false);
}
public boolean arrangeCapacity(int length, boolean changeEntity) throws IOException {
if (this.fCurrentEntity.count - this.fCurrentEntity.position >= length)
return true;
boolean entityChanged = false;
while (this.fCurrentEntity.count - this.fCurrentEntity.position < length) {
if (this.fCurrentEntity.ch.length - this.fCurrentEntity.position < length) {
invokeListeners(0);
System.arraycopy(this.fCurrentEntity.ch, this.fCurrentEntity.position, this.fCurrentEntity.ch, 0, this.fCurrentEntity.count - this.fCurrentEntity.position);
this.fCurrentEntity.count -= this.fCurrentEntity.position;
this.fCurrentEntity.position = 0;
}
if (this.fCurrentEntity.count - this.fCurrentEntity.position < length) {
int pos = this.fCurrentEntity.position;
invokeListeners(pos);
entityChanged = load(this.fCurrentEntity.count, changeEntity);
this.fCurrentEntity.position = pos;
if (entityChanged)
break;
}
}
if (this.fCurrentEntity.count - this.fCurrentEntity.position >= length)
return true;
return false;
}
public boolean skipString(String s) throws IOException {
int length = s.length();
if (arrangeCapacity(length, false)) {
int beforeSkip = this.fCurrentEntity.position;
int afterSkip = this.fCurrentEntity.position + length - 1;
int i = length - 1;
while (s.charAt(i--) == this.fCurrentEntity.ch[afterSkip]) {
if (afterSkip-- == beforeSkip) {
this.fCurrentEntity.position += length;
this.fCurrentEntity.columnNumber += length;
return true;
}
}
}
return false;
}
public boolean skipString(char[] s) throws IOException {
int length = s.length;
if (arrangeCapacity(length, false)) {
int beforeSkip = this.fCurrentEntity.position;
int afterSkip = this.fCurrentEntity.position + length;
for (int i = 0; i < length; i++) {
if (this.fCurrentEntity.ch[beforeSkip++] != s[i])
return false;
}
this.fCurrentEntity.position += length;
this.fCurrentEntity.columnNumber += length;
return true;
}
return false;
}
final boolean load(int offset, boolean changeEntity) throws IOException {
this.fCurrentEntity.fTotalCountTillLastLoad += this.fCurrentEntity.fLastCount;
int length = this.fCurrentEntity.mayReadChunks ? (this.fCurrentEntity.ch.length - offset) : 64;
int count = this.fCurrentEntity.reader.read(this.fCurrentEntity.ch, offset, length);
boolean entityChanged = false;
if (count != -1) {
if (count != 0) {
this.fCurrentEntity.fLastCount = count;
this.fCurrentEntity.count = count + offset;
this.fCurrentEntity.position = offset;
}
} else {
this.fCurrentEntity.count = offset;
this.fCurrentEntity.position = offset;
entityChanged = true;
if (changeEntity) {
this.fEntityManager.endEntity();
if (this.fCurrentEntity == null)
return true;
if (this.fCurrentEntity.position == this.fCurrentEntity.count)
load(0, true);
}
}
return entityChanged;
}
protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian) throws IOException {
if (encoding == null)
encoding = "UTF-8";
String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
if (ENCODING.equals("UTF-8"))
return new UTF8Reader(inputStream, this.fCurrentEntity.fBufferSize, this.fErrorReporter.getMessageFormatter("http://www.w3.org/TR/1998/REC-xml-19980210"), this.fErrorReporter.getLocale());
if (ENCODING.equals("US-ASCII"))
return new ASCIIReader(inputStream, this.fCurrentEntity.fBufferSize, this.fErrorReporter.getMessageFormatter("http://www.w3.org/TR/1998/REC-xml-19980210"), this.fErrorReporter.getLocale());
if (ENCODING.equals("ISO-10646-UCS-4")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian;
if (isBE)
return new UCSReader(inputStream, (short)8);
return new UCSReader(inputStream, (short)4);
}
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingByteOrderUnsupported", new Object[] { encoding }, (short)2);
}
if (ENCODING.equals("ISO-10646-UCS-2")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian;
if (isBE)
return new UCSReader(inputStream, (short)2);
return new UCSReader(inputStream, (short)1);
}
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingByteOrderUnsupported", new Object[] { encoding }, (short)2);
}
boolean validIANA = XMLChar.isValidIANAEncoding(encoding);
boolean validJava = XMLChar.isValidJavaEncoding(encoding);
if (!validIANA || (this.fAllowJavaEncodings && !validJava)) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingDeclInvalid", new Object[] { encoding }, (short)2);
encoding = "ISO-8859-1";
}
String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING);
if (javaEncoding == null)
if (this.fAllowJavaEncodings) {
javaEncoding = encoding;
} else {
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "EncodingDeclInvalid", new Object[] { encoding }, (short)2);
javaEncoding = "ISO8859_1";
}
return new InputStreamReader(inputStream, javaEncoding);
}
protected Object[] getEncodingName(byte[] b4, int count) {
if (count < 2)
return new Object[] { "UTF-8", null };
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
if (b0 == 254 && b1 == 255)
return new Object[] { "UTF-16BE", new Boolean(true) };
if (b0 == 255 && b1 == 254)
return new Object[] { "UTF-16LE", new Boolean(false) };
if (count < 3)
return new Object[] { "UTF-8", null };
int b2 = b4[2] & 0xFF;
if (b0 == 239 && b1 == 187 && b2 == 191)
return new Object[] { "UTF-8", null };
if (count < 4)
return new Object[] { "UTF-8", null };
int b3 = b4[3] & 0xFF;
if (b0 == 0 && b1 == 0 && b2 == 0 && b3 == 60)
return new Object[] { "ISO-10646-UCS-4", new Boolean(true) };
if (b0 == 60 && b1 == 0 && b2 == 0 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", new Boolean(false) };
if (b0 == 0 && b1 == 0 && b2 == 60 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", null };
if (b0 == 0 && b1 == 60 && b2 == 0 && b3 == 0)
return new Object[] { "ISO-10646-UCS-4", null };
if (b0 == 0 && b1 == 60 && b2 == 0 && b3 == 63)
return new Object[] { "UTF-16BE", new Boolean(true) };
if (b0 == 60 && b1 == 0 && b2 == 63 && b3 == 0)
return new Object[] { "UTF-16LE", new Boolean(false) };
if (b0 == 76 && b1 == 111 && b2 == 167 && b3 == 148)
return new Object[] { "CP037", null };
return new Object[] { "UTF-8", null };
}
final void print() {}
public void registerListener(XMLBufferListener listener) {
if (!this.listeners.contains(listener))
this.listeners.add(listener);
}
private void invokeListeners(int loadPos) {
for (int i = 0; i < this.listeners.size(); i++) {
XMLBufferListener listener = this.listeners.get(i);
listener.refresh(loadPos);
}
}
}

View file

@ -0,0 +1,271 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.util.URI;
import com.sun.xml.stream.xerces.util.XMLResourceIdentifierImpl;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
public class XMLEntityStorage {
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
protected static final String WARN_ON_DUPLICATE_ENTITYDEF = "http://apache.org/xml/features/warn-on-duplicate-entitydef";
protected boolean fWarnDuplicateEntityDef;
protected Hashtable fEntities = new Hashtable();
protected Entity.ScannedEntity fCurrentEntity;
private XMLEntityManager fEntityManager;
protected XMLErrorReporter fErrorReporter;
protected PropertyManager fPropertyManager;
private static String gUserDir;
private static String gEscapedUserDir;
public XMLEntityStorage(PropertyManager propertyManager) {
this.fPropertyManager = propertyManager;
}
public XMLEntityStorage(XMLEntityManager entityManager) {
this.fEntityManager = entityManager;
}
public void reset(PropertyManager propertyManager) {
this.fErrorReporter = (XMLErrorReporter)propertyManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
this.fEntities.clear();
this.fCurrentEntity = null;
}
public void reset() {
this.fEntities.clear();
this.fCurrentEntity = null;
}
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
try {
this.fWarnDuplicateEntityDef = componentManager.getFeature("http://apache.org/xml/features/warn-on-duplicate-entitydef");
} catch (XMLConfigurationException e) {
this.fWarnDuplicateEntityDef = false;
}
this.fErrorReporter = (XMLErrorReporter)componentManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
this.fEntities.clear();
this.fCurrentEntity = null;
}
public Hashtable getDeclaredEntities() {
return this.fEntities;
}
public void addInternalEntity(String name, String text) {
if (!this.fEntities.containsKey(name)) {
this.fCurrentEntity = this.fEntityManager.getCurrentEntity();
Entity entity = new Entity.InternalEntity(name, text, false);
this.fEntities.put(name, entity);
} else if (this.fWarnDuplicateEntityDef) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[] { name }, (short)0);
}
}
public void addExternalEntity(String name, String publicId, String literalSystemId, String baseSystemId) {
if (!this.fEntities.containsKey(name)) {
if (baseSystemId == null)
if (this.fCurrentEntity != null && this.fCurrentEntity.entityLocation != null)
baseSystemId = this.fCurrentEntity.entityLocation.getExpandedSystemId();
this.fCurrentEntity = this.fEntityManager.getCurrentEntity();
Entity entity = new Entity.ExternalEntity(name, new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandSystemId(literalSystemId, baseSystemId)), null, true);
this.fEntities.put(name, entity);
} else if (this.fWarnDuplicateEntityDef) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[] { name }, (short)0);
}
}
public boolean isExternalEntity(String entityName) {
Entity entity = (Entity)this.fEntities.get(entityName);
if (entity == null)
return false;
return entity.isExternal();
}
public boolean isEntityDeclInExternalSubset(String entityName) {
Entity entity = (Entity)this.fEntities.get(entityName);
if (entity == null)
return false;
return entity.isEntityDeclInExternalSubset();
}
public void addUnparsedEntity(String name, String publicId, String systemId, String baseSystemId, String notation) {
this.fCurrentEntity = this.fEntityManager.getCurrentEntity();
if (!this.fEntities.containsKey(name)) {
Entity entity = new Entity.ExternalEntity(name, new XMLResourceIdentifierImpl(publicId, systemId, baseSystemId, null), notation, false);
this.fEntities.put(name, entity);
} else if (this.fWarnDuplicateEntityDef) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1998/REC-xml-19980210", "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[] { name }, (short)0);
}
}
public boolean isUnparsedEntity(String entityName) {
Entity entity = (Entity)this.fEntities.get(entityName);
if (entity == null)
return false;
return entity.isUnparsed();
}
public boolean isDeclaredEntity(String entityName) {
Entity entity = (Entity)this.fEntities.get(entityName);
return (entity != null);
}
public static String expandSystemId(String systemId) {
return expandSystemId(systemId, null);
}
private static boolean[] gNeedEscaping = new boolean[128];
private static char[] gAfterEscaping1 = new char[128];
private static char[] gAfterEscaping2 = new char[128];
private static char[] gHexChs = new char[] {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
static {
for (int i = 0; i <= 31; i++) {
gNeedEscaping[i] = true;
gAfterEscaping1[i] = gHexChs[i >> 4];
gAfterEscaping2[i] = gHexChs[i & 0xF];
}
gNeedEscaping[127] = true;
gAfterEscaping1[127] = '7';
gAfterEscaping2[127] = 'F';
char[] escChs = {
' ', '<', '>', '#', '%', '"', '{', '}', '|', '\\',
'^', '~', '[', ']', '`' };
int len = escChs.length;
for (int j = 0; j < len; j++) {
char ch = escChs[j];
gNeedEscaping[ch] = true;
gAfterEscaping1[ch] = gHexChs[ch >> 4];
gAfterEscaping2[ch] = gHexChs[ch & 0xF];
}
}
private static synchronized String getUserDir() {
String userDir = "";
try {
userDir = System.getProperty("user.dir");
} catch (SecurityException se) {}
if (userDir.length() == 0)
return "";
if (userDir.equals(gUserDir))
return gEscapedUserDir;
gUserDir = userDir;
char separator = File.separatorChar;
userDir = userDir.replace(separator, '/');
int len = userDir.length();
StringBuffer buffer = new StringBuffer(len * 3);
if (len >= 2 && userDir.charAt(1) == ':') {
int ch = Character.toUpperCase(userDir.charAt(0));
if (ch >= 65 && ch <= 90)
buffer.append('/');
}
int i = 0;
for (; i < len; i++) {
int ch = userDir.charAt(i);
if (ch >= 128)
break;
if (gNeedEscaping[ch]) {
buffer.append('%');
buffer.append(gAfterEscaping1[ch]);
buffer.append(gAfterEscaping2[ch]);
} else {
buffer.append((char)ch);
}
}
if (i < len) {
byte[] bytes = null;
try {
bytes = userDir.substring(i).getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
return userDir;
}
len = bytes.length;
for (i = 0; i < len; i++) {
byte b = bytes[i];
if (b < 0) {
int ch = b + 256;
buffer.append('%');
buffer.append(gHexChs[ch >> 4]);
buffer.append(gHexChs[ch & 0xF]);
} else if (gNeedEscaping[b]) {
buffer.append('%');
buffer.append(gAfterEscaping1[b]);
buffer.append(gAfterEscaping2[b]);
} else {
buffer.append((char)b);
}
}
}
if (!userDir.endsWith("/"))
buffer.append('/');
gEscapedUserDir = buffer.toString();
return gEscapedUserDir;
}
public static String expandSystemId(String systemId, String baseSystemId) {
if (systemId == null || systemId.length() == 0)
return systemId;
try {
URI uRI = new URI(systemId);
if (uRI != null)
return systemId;
} catch (URI.MalformedURIException e) {}
String id = fixURI(systemId);
URI base = null;
URI uri = null;
try {
if (baseSystemId == null || baseSystemId.length() == 0 || baseSystemId.equals(systemId)) {
String dir = getUserDir();
base = new URI("file", "", dir, null, null);
} else {
try {
base = new URI(fixURI(baseSystemId));
} catch (URI.MalformedURIException e) {
if (baseSystemId.indexOf(':') != -1) {
base = new URI("file", "", fixURI(baseSystemId), null, null);
} else {
String dir = getUserDir();
dir = dir + fixURI(baseSystemId);
base = new URI("file", "", dir, null, null);
}
}
}
uri = new URI(base, id);
} catch (Exception e) {}
if (uri == null)
return systemId;
return uri.toString();
}
protected static String fixURI(String str) {
str = str.replace(File.separatorChar, '/');
if (str.length() >= 2) {
char ch1 = str.charAt(1);
if (ch1 == ':') {
char ch0 = Character.toUpperCase(str.charAt(0));
if (ch0 >= 'A' && ch0 <= 'Z')
str = "/" + str;
} else if (ch1 == '/' && str.charAt(0) == '/') {
str = "file:" + str;
}
}
return str;
}
}

View file

@ -0,0 +1,178 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.util.DefaultErrorHandler;
import com.sun.xml.stream.xerces.util.MessageFormatter;
import com.sun.xml.stream.xerces.xni.XMLLocator;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponent;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import com.sun.xml.stream.xerces.xni.parser.XMLErrorHandler;
import com.sun.xml.stream.xerces.xni.parser.XMLParseException;
import java.util.Hashtable;
import java.util.Locale;
public class XMLErrorReporter implements XMLComponent {
public static final short SEVERITY_WARNING = 0;
public static final short SEVERITY_ERROR = 1;
public static final short SEVERITY_FATAL_ERROR = 2;
protected static final String CONTINUE_AFTER_FATAL_ERROR = "http://apache.org/xml/features/continue-after-fatal-error";
protected static final String ERROR_HANDLER = "http://apache.org/xml/properties/internal/error-handler";
private static final String[] RECOGNIZED_FEATURES = new String[] { "http://apache.org/xml/features/continue-after-fatal-error" };
private static final Boolean[] FEATURE_DEFAULTS = new Boolean[] { null };
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://apache.org/xml/properties/internal/error-handler" };
private static final Object[] PROPERTY_DEFAULTS = new Object[] { null };
protected Locale fLocale;
protected Hashtable fMessageFormatters = new Hashtable();
protected XMLErrorHandler fErrorHandler;
protected XMLLocator fLocator;
protected boolean fContinueAfterFatalError;
protected XMLErrorHandler fDefaultErrorHandler;
public void setLocale(Locale locale) {
this.fLocale = locale;
}
public Locale getLocale() {
return this.fLocale;
}
public void setDocumentLocator(XMLLocator locator) {
this.fLocator = locator;
}
public void putMessageFormatter(String domain, MessageFormatter messageFormatter) {
this.fMessageFormatters.put(domain, messageFormatter);
}
public MessageFormatter getMessageFormatter(String domain) {
return (MessageFormatter)this.fMessageFormatters.get(domain);
}
public MessageFormatter removeMessageFormatter(String domain) {
return (MessageFormatter)this.fMessageFormatters.remove(domain);
}
public void reportError(String domain, String key, Object[] arguments, short severity) throws XNIException {
reportError(this.fLocator, domain, key, arguments, severity);
}
public void reportError(XMLLocator location, String domain, String key, Object[] arguments, short severity) throws XNIException {
String message;
MessageFormatter messageFormatter = getMessageFormatter(domain);
if (messageFormatter != null) {
message = messageFormatter.formatMessage(this.fLocale, key, arguments);
} else {
StringBuffer str = new StringBuffer();
str.append(domain);
str.append('#');
str.append(key);
int argCount = (arguments != null) ? arguments.length : 0;
if (argCount > 0) {
str.append('?');
for (int i = 0; i < argCount; i++) {
str.append(arguments[i]);
if (i < argCount - 1)
str.append('&');
}
}
message = str.toString();
}
XMLParseException parseException = new XMLParseException(location, message);
XMLErrorHandler errorHandler = this.fErrorHandler;
if (errorHandler == null) {
if (this.fDefaultErrorHandler == null)
this.fDefaultErrorHandler = new DefaultErrorHandler();
errorHandler = this.fDefaultErrorHandler;
}
switch (severity) {
case 0:
errorHandler.warning(domain, key, parseException);
break;
case 1:
errorHandler.error(domain, key, parseException);
break;
case 2:
errorHandler.fatalError(domain, key, parseException);
if (!this.fContinueAfterFatalError)
throw parseException;
break;
}
}
public void reset(XMLComponentManager componentManager) throws XNIException {
try {
this.fContinueAfterFatalError = componentManager.getFeature("http://apache.org/xml/features/continue-after-fatal-error");
} catch (XNIException e) {
this.fContinueAfterFatalError = false;
}
this.fErrorHandler = (XMLErrorHandler)componentManager.getProperty("http://apache.org/xml/properties/internal/error-handler");
}
public String[] getRecognizedFeatures() {
return (String[])RECOGNIZED_FEATURES.clone();
}
public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
if (featureId.startsWith("http://apache.org/xml/features/")) {
String feature = featureId.substring("http://apache.org/xml/features/".length());
if (feature.equals("continue-after-fatal-error"))
this.fContinueAfterFatalError = state;
}
}
public boolean getFeature(String featureId) throws XMLConfigurationException {
if (featureId.startsWith("http://apache.org/xml/features/")) {
String feature = featureId.substring("http://apache.org/xml/features/".length());
if (feature.equals("continue-after-fatal-error"))
return this.fContinueAfterFatalError;
}
return false;
}
public String[] getRecognizedProperties() {
return (String[])RECOGNIZED_PROPERTIES.clone();
}
public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
if (propertyId.startsWith("http://apache.org/xml/properties/")) {
String property = propertyId.substring("http://apache.org/xml/properties/".length());
if (property.equals("internal/error-handler"))
this.fErrorHandler = (XMLErrorHandler)value;
}
}
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId))
return FEATURE_DEFAULTS[i];
}
return null;
}
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId))
return PROPERTY_DEFAULTS[i];
}
return null;
}
public XMLErrorHandler getErrorHandler() {
return this.fErrorHandler;
}
}

View file

@ -0,0 +1,150 @@
package com.sun.xml.stream;
import com.sun.xml.stream.events.XMLEventAllocatorImpl;
import java.util.NoSuchElementException;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.EntityReference;
import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.util.XMLEventAllocator;
public class XMLEventReaderImpl implements XMLEventReader {
protected XMLStreamReader fXMLReader;
protected XMLEventAllocator fXMLEventAllocator;
private XMLEvent fPeekedEvent;
private XMLEvent fLastEvent;
public XMLEventReaderImpl(XMLStreamReader reader) throws XMLStreamException {
this.fXMLReader = reader;
this.fXMLEventAllocator = (XMLEventAllocator)reader.getProperty("javax.xml.stream.allocator");
if (this.fXMLEventAllocator == null)
this.fXMLEventAllocator = new XMLEventAllocatorImpl();
}
public boolean hasNext() {
if (this.fPeekedEvent != null)
return true;
boolean next = false;
try {
next = this.fXMLReader.hasNext();
} catch (XMLStreamException ex) {
return false;
}
return next;
}
public XMLEvent nextEvent() throws XMLStreamException {
if (this.fPeekedEvent != null) {
this.fLastEvent = this.fPeekedEvent;
this.fPeekedEvent = null;
return this.fLastEvent;
}
if (this.fXMLReader.hasNext()) {
this.fXMLReader.next();
return this.fLastEvent = this.fXMLEventAllocator.allocate(this.fXMLReader);
}
this.fLastEvent = null;
throw new NoSuchElementException();
}
public void remove() {
throw new UnsupportedOperationException();
}
public void close() throws XMLStreamException {
this.fXMLReader.close();
}
public String getElementText() throws XMLStreamException {
if (this.fLastEvent.getEventType() != 1)
throw new XMLStreamException("parser must be on START_ELEMENT to read next text", this.fLastEvent.getLocation());
if (this.fPeekedEvent != null) {
XMLEvent event = this.fPeekedEvent;
this.fPeekedEvent = null;
int type = event.getEventType();
String data = null;
if (type == 4 || type == 6 || type == 12) {
data = event.asCharacters().getData();
} else if (type == 9) {
data = ((EntityReference)event).getDeclaration().getReplacementText();
} else if (type != 5 && type != 3) {
if (type == 1)
throw new XMLStreamException("elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
if (type == 2)
return "";
}
StringBuffer buffer = new StringBuffer();
if (data != null && data.length() > 0)
buffer.append(data);
event = nextEvent();
while (event.getEventType() != 2) {
if (type == 4 || type == 6 || type == 12) {
data = event.asCharacters().getData();
} else if (type == 9) {
data = ((EntityReference)event).getDeclaration().getReplacementText();
} else if (type != 5 && type != 3) {
if (type == 8)
throw new XMLStreamException("unexpected end of document when reading element text content");
if (type == 1)
throw new XMLStreamException("elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
throw new XMLStreamException("Unexpected event type " + type, event.getLocation());
}
if (data != null && data.length() > 0)
buffer.append(data);
}
return buffer.toString();
}
return this.fXMLReader.getElementText();
}
public Object getProperty(String name) throws IllegalArgumentException {
return this.fXMLReader.getProperty(name);
}
public XMLEvent nextTag() throws XMLStreamException {
if (this.fPeekedEvent != null) {
XMLEvent event = this.fPeekedEvent;
this.fPeekedEvent = null;
int eventType = event.getEventType();
if ((event.isCharacters() && event.asCharacters().isWhiteSpace()) || eventType == 3 || eventType == 5) {
event = nextEvent();
eventType = event.getEventType();
}
while ((event.isCharacters() && event.asCharacters().isWhiteSpace()) || eventType == 3 || eventType == 5) {
event = nextEvent();
eventType = event.getEventType();
}
if (eventType != 1 && eventType != 2)
throw new XMLStreamException("expected start or end tag", event.getLocation());
return event;
}
this.fXMLReader.nextTag();
return this.fXMLEventAllocator.allocate(this.fXMLReader);
}
public Object next() {
Object object = null;
try {
object = nextEvent();
} catch (XMLStreamException streamException) {
this.fLastEvent = null;
throw new NoSuchElementException();
}
return object;
}
public XMLEvent peek() throws XMLStreamException {
if (this.fPeekedEvent != null)
return this.fPeekedEvent;
if (hasNext()) {
this.fXMLReader.next();
this.fPeekedEvent = this.fXMLEventAllocator.allocate(this.fXMLReader);
return this.fPeekedEvent;
}
return null;
}
}

View file

@ -0,0 +1,266 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.util.XMLAttributesImpl;
import com.sun.xml.stream.xerces.util.XMLStringBuffer;
import com.sun.xml.stream.xerces.util.XMLSymbols;
import com.sun.xml.stream.xerces.xni.NamespaceContext;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import java.io.IOException;
public class XMLNSDocumentScannerImpl extends XMLDocumentScannerImpl {
protected boolean fPerformValidation;
private boolean fEmptyElement = false;
private XMLDocumentScannerImpl.XMLBufferListenerImpl listener = new XMLDocumentScannerImpl.XMLBufferListenerImpl(this);
private boolean fClearAttributes = true;
public void reset(PropertyManager propertyManager) {
setPropertyManager(propertyManager);
super.reset(propertyManager);
try {
if (!this.fAttributeCacheInitDone) {
for (int i = 0; i < this.initialCacheCount; i++) {
this.attributeValueCache.add(new XMLString());
this.stringBufferCache.add(new XMLStringBuffer());
}
this.fAttributeCacheInitDone = true;
}
this.fStringBufferIndex = 0;
this.fAttributeCacheUsedCount = 0;
this.fEntityScanner.registerListener(this.listener);
this.dtdGrammarUtil = null;
this.fClearAttributes = true;
} catch (RuntimeException ex) {}
}
public QName getElementQName() {
if (this.fScannerLastState == 2)
this.fElementQName.setValues(this.fElementStack.getLastPoppedElement());
return this.fElementQName;
}
protected boolean scanStartElement() throws IOException, XNIException {
assert false : "Decompilation failed at line #175 -> offsets [0]";
assert false : "Decompilation failed at line #179 -> offsets [14]";
assert false : "Decompilation failed at line #186 -> offsets [22]";
assert false : "Decompilation failed at line #188 -> offsets [37]";
assert false : "Decompilation failed at line #192 -> offsets [44]";
assert false : "Decompilation failed at line #193 -> offsets [51]";
assert false : "Decompilation failed at line #194 -> offsets [56]";
assert false : "Decompilation failed at line #196 -> offsets [59]";
assert false : "Decompilation failed at line #206 -> offsets [66]";
assert false : "Decompilation failed at line #208 -> offsets [80]";
assert false : "Decompilation failed at line #210 -> offsets [91]";
assert false : "Decompilation failed at line #211 -> offsets [98]";
assert false : "Decompilation failed at line #212 -> offsets [110]";
assert false : "Decompilation failed at line #214 -> offsets [113]";
assert false : "Decompilation failed at line #215 -> offsets [121]";
assert false : "Decompilation failed at line #218 -> offsets [132]";
assert false : "Decompilation failed at line #230 -> offsets [146]";
assert false : "Decompilation failed at line #232 -> offsets [153]";
assert false : "Decompilation failed at line #236 -> offsets [165]";
assert false : "Decompilation failed at line #238 -> offsets [173]";
assert false : "Decompilation failed at line #239 -> offsets [181]";
assert false : "Decompilation failed at line #240 -> offsets [188]";
assert false : "Decompilation failed at line #241 -> offsets [197]";
assert false : "Decompilation failed at line #242 -> offsets [206]";
assert false : "Decompilation failed at line #243 -> offsets [213]";
assert false : "Decompilation failed at line #248 -> offsets [233]";
assert false : "Decompilation failed at line #249 -> offsets [251]";
assert false : "Decompilation failed at line #259 -> offsets [278]";
assert false : "Decompilation failed at line #260 -> offsets [283]";
assert false : "Decompilation failed at line #261 -> offsets [290]";
assert false : "Decompilation failed at line #262 -> offsets [297]";
assert false : "Decompilation failed at line #263 -> offsets [304]";
assert false : "Decompilation failed at line #264 -> offsets [309]";
assert false : "Decompilation failed at line #265 -> offsets [314]";
assert false : "Decompilation failed at line #266 -> offsets [319]";
assert false : "Decompilation failed at line #267 -> offsets [324]";
assert false : "Decompilation failed at line #269 -> offsets [329]";
assert false : "Decompilation failed at line #270 -> offsets [337]";
assert false : "Decompilation failed at line #271 -> offsets [344]";
assert false : "Decompilation failed at line #272 -> offsets [349]";
assert false : "Decompilation failed at line #273 -> offsets [352]";
assert false : "Decompilation failed at line #276 -> offsets [357]";
assert false : "Decompilation failed at line #278 -> offsets [364]";
assert false : "Decompilation failed at line #279 -> offsets [377]";
assert false : "Decompilation failed at line #286 -> offsets [403]";
assert false : "Decompilation failed at line #289 -> offsets [427]";
assert false : "Decompilation failed at line #291 -> offsets [444]";
assert false : "Decompilation failed at line #293 -> offsets [458]";
assert false : "Decompilation failed at line #294 -> offsets [478]";
assert false : "Decompilation failed at line #296 -> offsets [488]";
assert false : "Decompilation failed at line #297 -> offsets [508]";
assert false : "Decompilation failed at line #304 -> offsets [544]";
assert false : "Decompilation failed at line #306 -> offsets [552, 711]";
assert false : "Decompilation failed at line #307 -> offsets [561]";
assert false : "Decompilation failed at line #309 -> offsets [574]";
assert false : "Decompilation failed at line #311 -> offsets [599]";
assert false : "Decompilation failed at line #314 -> offsets [612]";
assert false : "Decompilation failed at line #316 -> offsets [634]";
assert false : "Decompilation failed at line #318 -> offsets [637]";
assert false : "Decompilation failed at line #319 -> offsets [645]";
assert false : "Decompilation failed at line #320 -> offsets [654]";
assert false : "Decompilation failed at line #321 -> offsets [659]";
assert false : "Decompilation failed at line #326 -> offsets [700]";
assert false : "Decompilation failed at line #331 -> offsets [717]";
assert false : "Decompilation failed at line #332 -> offsets [722]";
assert false : "Decompilation failed at line #333 -> offsets [731]";
assert false : "Decompilation failed at line #334 -> offsets [736]";
assert false : "Decompilation failed at line #335 -> offsets [744]";
assert false : "Decompilation failed at line #339 -> offsets [786]";
assert false : "Decompilation failed at line #341 -> offsets [789]";
assert false : "Decompilation failed at line #351 -> offsets [823]";
assert false : "Decompilation failed at line #353 -> offsets [830]";
assert false : "Decompilation failed at line #356 -> offsets [840]";
assert false : "Decompilation failed at line #357 -> offsets [858]";
assert false : "Decompilation failed at line #361 -> offsets [878]";
assert false : "Decompilation failed at line #362 -> offsets [885]";
assert false : "Decompilation failed at line #367 -> offsets [903]";
assert false : "Decompilation failed at line #373 -> offsets [908]";
assert false : "Decompilation failed at line #375 -> offsets [916]";
assert false : "Decompilation failed at line #376 -> offsets [919]";
assert false : "Decompilation failed at line #377 -> offsets [926]";
assert false : "Decompilation failed at line #378 -> offsets [937]";
assert false : "Decompilation failed at line #385 -> offsets [944]";
}
private boolean seekCloseOfStartTag() throws IOException, XNIException {
boolean sawSpace = this.fEntityScanner.skipSpaces();
int c = this.fEntityScanner.peekChar();
if (c == 62) {
this.fEntityScanner.scanChar();
return true;
}
if (c == 47) {
this.fEntityScanner.scanChar();
if (!this.fEntityScanner.skipChar(62))
reportFatalError("ElementUnterminated", new Object[] { this.fElementQName.rawname });
this.fEmptyElement = true;
return true;
}
if (!isValidNameStartChar(c) || !sawSpace)
reportFatalError("ElementUnterminated", new Object[] { this.fElementQName.rawname });
return false;
}
protected void scanAttribute(XMLAttributesImpl attributes) throws IOException, XNIException {
this.fEntityScanner.scanQName(this.fAttributeQName);
this.fEntityScanner.skipSpaces();
if (!this.fEntityScanner.skipChar(61))
reportFatalError("EqRequiredInAttribute", new Object[] { this.fCurrentElement.rawname, this.fAttributeQName.rawname });
this.fEntityScanner.skipSpaces();
int attrIndex = 0;
boolean isVC = (this.fHasExternalDTD && !this.fStandalone);
XMLString tmpStr = getString();
scanAttributeValue(tmpStr, this.fTempString2, this.fAttributeQName.rawname, attributes, attrIndex, isVC);
String value = null;
if (this.fBindNamespaces) {
String localpart = this.fAttributeQName.localpart;
String prefix = (this.fAttributeQName.prefix != null) ? this.fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
if (prefix == XMLSymbols.PREFIX_XMLNS || (prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS)) {
String uri = this.fSymbolTable.addSymbol(tmpStr.ch, tmpStr.offset, tmpStr.length);
value = uri;
if (prefix == XMLSymbols.PREFIX_XMLNS && localpart == XMLSymbols.PREFIX_XMLNS)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXMLNS", new Object[] { this.fAttributeQName }, (short)2);
if (uri == NamespaceContext.XMLNS_URI)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXMLNS", new Object[] { this.fAttributeQName }, (short)2);
if (localpart == XMLSymbols.PREFIX_XML) {
if (uri != NamespaceContext.XML_URI)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXML", new Object[] { this.fAttributeQName }, (short)2);
} else if (uri == NamespaceContext.XML_URI) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXML", new Object[] { this.fAttributeQName }, (short)2);
}
prefix = (localpart != XMLSymbols.PREFIX_XMLNS) ? localpart : XMLSymbols.EMPTY_STRING;
if (uri == XMLSymbols.EMPTY_STRING && localpart != XMLSymbols.PREFIX_XMLNS)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "EmptyPrefixedAttName", new Object[] { this.fAttributeQName }, (short)2);
this.fNamespaceContext.declarePrefix(prefix, (uri.length() != 0) ? uri : null);
return;
}
}
if (this.fBindNamespaces) {
attrIndex = attributes.getLength();
attributes.addAttributeNS(this.fAttributeQName, XMLSymbols.fCDATASymbol, null);
} else {
int oldLen = attributes.getLength();
attrIndex = attributes.addAttribute(this.fAttributeQName, XMLSymbols.fCDATASymbol, null);
if (oldLen == attributes.getLength())
reportFatalError("AttributeNotUnique", new Object[] { this.fCurrentElement.rawname, this.fAttributeQName.rawname });
}
attributes.setValue(attrIndex, value, tmpStr);
attributes.setSpecified(attrIndex, true);
if (this.fAttributeQName.prefix != null)
attributes.setURI(attrIndex, this.fNamespaceContext.getURI(this.fAttributeQName.prefix));
}
protected int scanEndElement() throws IOException, XNIException {
QName endElementName = this.fElementStack.popElement();
String rawname = endElementName.rawname;
if (!this.fEntityScanner.skipString(endElementName.characters))
reportFatalError("ETagRequired", new Object[] { rawname });
this.fEntityScanner.skipSpaces();
if (!this.fEntityScanner.skipChar(62))
reportFatalError("ETagUnterminated", new Object[] { rawname });
this.fMarkupDepth--;
this.fMarkupDepth--;
if (this.fMarkupDepth < this.fEntityStack[this.fEntityDepth - 1])
reportFatalError("ElementEntityMismatch", new Object[] { rawname });
if (this.fDocumentHandler != null);
if (this.dtdGrammarUtil != null)
this.dtdGrammarUtil.endElement(endElementName);
this.fScanEndElement = true;
return this.fMarkupDepth;
}
public NamespaceContext getNamespaceContext() {
return this.fNamespaceContext;
}
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
super.reset(componentManager);
this.fPerformValidation = false;
this.fBindNamespaces = false;
}
protected XMLDocumentFragmentScannerImpl.Driver createContentDriver() {
return new NSContentDriver();
}
protected final class NSContentDriver extends XMLDocumentScannerImpl.ContentDriver {
protected boolean scanRootElementHook() throws IOException, XNIException {
if (XMLNSDocumentScannerImpl.this.scanStartElement()) {
XMLNSDocumentScannerImpl.this.setScannerState(44);
XMLNSDocumentScannerImpl.this.setDriver(XMLNSDocumentScannerImpl.this.fTrailingMiscDriver);
return true;
}
return false;
}
}
XMLString getString() {
if (this.fAttributeCacheUsedCount < this.initialCacheCount || this.fAttributeCacheUsedCount < this.attributeValueCache.size())
return this.attributeValueCache.get(this.fAttributeCacheUsedCount++);
XMLString str = new XMLString();
this.fAttributeCacheUsedCount++;
this.attributeValueCache.add(str);
return str;
}
public XMLStringBuffer getDTDDecl() {
Entity entity = this.fEntityScanner.getCurrentEntity();
this.fDTDDecl.append(((Entity.ScannedEntity)entity).ch, this.fStartPos, this.fEndPos - this.fStartPos);
if (this.fSeenInternalSubset)
this.fDTDDecl.append("]>");
return this.fDTDDecl;
}
public String getCharacterEncodingScheme() {
return this.fDeclaredEncoding;
}
}

View file

@ -0,0 +1,336 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.util.NamespaceSupport;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.XMLSymbols;
import com.sun.xml.stream.xerces.xni.Augmentations;
import com.sun.xml.stream.xerces.xni.NamespaceContext;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLAttributes;
import com.sun.xml.stream.xerces.xni.XMLDocumentHandler;
import com.sun.xml.stream.xerces.xni.XMLLocator;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponent;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import com.sun.xml.stream.xerces.xni.parser.XMLDocumentFilter;
import com.sun.xml.stream.xerces.xni.parser.XMLDocumentSource;
public class XMLNamespaceBinder implements XMLComponent, XMLDocumentFilter {
protected static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
private static final String[] RECOGNIZED_FEATURES = new String[] { "http://xml.org/sax/features/namespaces" };
private static final Boolean[] FEATURE_DEFAULTS = new Boolean[] { null };
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://apache.org/xml/properties/internal/symbol-table", "http://apache.org/xml/properties/internal/error-reporter" };
private static final Object[] PROPERTY_DEFAULTS = new Object[] { null, null };
protected boolean fNamespaces;
protected SymbolTable fSymbolTable;
protected XMLErrorReporter fErrorReporter;
protected XMLDocumentHandler fDocumentHandler;
protected XMLDocumentSource fDocumentSource;
protected NamespaceSupport fNamespaceSupport = new NamespaceSupport();
protected boolean fOnlyPassPrefixMappingEvents;
private NamespaceContext fNamespaceContext;
private QName fAttributeQName = new QName();
public XMLNamespaceBinder() {
this(null);
}
public XMLNamespaceBinder(NamespaceContext namespaceContext) {
this.fNamespaceContext = namespaceContext;
}
public NamespaceContext getNamespaceContext() {
return this.fNamespaceSupport;
}
public void setOnlyPassPrefixMappingEvents(boolean onlyPassPrefixMappingEvents) {
this.fOnlyPassPrefixMappingEvents = onlyPassPrefixMappingEvents;
}
public boolean getOnlyPassPrefixMappingEvents() {
return this.fOnlyPassPrefixMappingEvents;
}
public void reset(XMLComponentManager componentManager) throws XNIException {
try {
this.fNamespaces = componentManager.getFeature("http://xml.org/sax/features/namespaces");
} catch (XMLConfigurationException e) {
this.fNamespaces = true;
}
this.fSymbolTable = (SymbolTable)componentManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)componentManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
this.fNamespaceSupport.reset();
NamespaceContext context = this.fNamespaceContext;
while (context != null) {
int count = context.getDeclaredPrefixCount();
for (int i = 0; i < count; i++) {
String prefix = context.getDeclaredPrefixAt(i);
if (this.fNamespaceSupport.getURI(prefix) == null) {
String uri = context.getURI(prefix);
this.fNamespaceSupport.declarePrefix(prefix, uri);
}
}
}
}
public String[] getRecognizedFeatures() {
return (String[])RECOGNIZED_FEATURES.clone();
}
public void setFeature(String featureId, boolean state) throws XMLConfigurationException {}
public String[] getRecognizedProperties() {
return (String[])RECOGNIZED_PROPERTIES.clone();
}
public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
if (propertyId.startsWith("http://apache.org/xml/properties/")) {
String property = propertyId.substring("http://apache.org/xml/properties/".length());
if (property.equals("internal/symbol-table")) {
this.fSymbolTable = (SymbolTable)value;
} else if (property.equals("internal/error-reporter")) {
this.fErrorReporter = (XMLErrorReporter)value;
}
return;
}
}
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId))
return FEATURE_DEFAULTS[i];
}
return null;
}
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId))
return PROPERTY_DEFAULTS[i];
}
return null;
}
public void setDocumentHandler(XMLDocumentHandler documentHandler) {
this.fDocumentHandler = documentHandler;
}
public XMLDocumentHandler getDocumentHandler() {
return this.fDocumentHandler;
}
public void setDocumentSource(XMLDocumentSource source) {
this.fDocumentSource = source;
}
public XMLDocumentSource getDocumentSource() {
return this.fDocumentSource;
}
public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.startGeneralEntity(name, identifier, encoding, augs);
}
public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.textDecl(version, encoding, augs);
}
public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.startDocument(locator, encoding, this.fNamespaceSupport, augs);
}
public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.xmlDecl(version, encoding, standalone, augs);
}
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.doctypeDecl(rootElement, publicId, systemId, augs);
}
public void comment(XMLString text, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.comment(text, augs);
}
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.processingInstruction(target, data, augs);
}
public void startPrefixMapping(String prefix, String uri, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null)
this.fDocumentHandler.startPrefixMapping(prefix, uri, augs);
}
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
if (this.fNamespaces) {
handleStartElement(element, attributes, augs, false);
} else if (this.fDocumentHandler != null) {
this.fDocumentHandler.startElement(element, attributes, augs);
}
}
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
if (this.fNamespaces) {
handleStartElement(element, attributes, augs, true);
handleEndElement(element, augs, true);
} else if (this.fDocumentHandler != null) {
this.fDocumentHandler.emptyElement(element, attributes, augs);
}
}
public void characters(XMLString text, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.characters(text, augs);
}
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.ignorableWhitespace(text, augs);
}
public void endElement(QName element, Augmentations augs) throws XNIException {
if (this.fNamespaces) {
handleEndElement(element, augs, false);
} else if (this.fDocumentHandler != null) {
this.fDocumentHandler.endElement(element, augs);
}
}
public void endPrefixMapping(String prefix, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null)
this.fDocumentHandler.endPrefixMapping(prefix, augs);
}
public void startCDATA(Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.startCDATA(augs);
}
public void endCDATA(Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.endCDATA(augs);
}
public void endDocument(Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.endDocument(augs);
}
public void endGeneralEntity(String name, Augmentations augs) throws XNIException {
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
this.fDocumentHandler.endGeneralEntity(name, augs);
}
protected void handleStartElement(QName element, XMLAttributes attributes, Augmentations augs, boolean isEmpty) throws XNIException {
this.fNamespaceSupport.pushContext();
if (element.prefix == XMLSymbols.PREFIX_XMLNS)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "ElementXMLNSPrefix", new Object[] { element.rawname }, (short)2);
int length = attributes.getLength();
for (int i = 0; i < length; i++) {
String localpart = attributes.getLocalName(i);
String str1 = attributes.getPrefix(i);
if (str1 == XMLSymbols.PREFIX_XMLNS || (str1 == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS)) {
String uri = this.fSymbolTable.addSymbol(attributes.getValue(i));
if (str1 == XMLSymbols.PREFIX_XMLNS && localpart == XMLSymbols.PREFIX_XMLNS)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXMLNS", new Object[] { attributes.getQName(i) }, (short)2);
if (uri == NamespaceContext.XMLNS_URI)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXMLNS", new Object[] { attributes.getQName(i) }, (short)2);
if (localpart == XMLSymbols.PREFIX_XML) {
if (uri != NamespaceContext.XML_URI)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXML", new Object[] { attributes.getQName(i) }, (short)2);
} else if (uri == NamespaceContext.XML_URI) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "CantBindXML", new Object[] { attributes.getQName(i) }, (short)2);
}
str1 = (localpart != XMLSymbols.PREFIX_XMLNS) ? localpart : XMLSymbols.EMPTY_STRING;
if (uri == XMLSymbols.EMPTY_STRING && localpart != XMLSymbols.PREFIX_XMLNS) {
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "EmptyPrefixedAttName", new Object[] { attributes.getQName(i) }, (short)2);
} else {
this.fNamespaceSupport.declarePrefix(str1, (uri.length() != 0) ? uri : null);
if (this.fDocumentHandler != null)
this.fDocumentHandler.startPrefixMapping(str1, uri, augs);
}
}
}
String prefix = (element.prefix != null) ? element.prefix : XMLSymbols.EMPTY_STRING;
element.uri = this.fNamespaceSupport.getURI(prefix);
if (element.prefix == null && element.uri != null)
element.prefix = XMLSymbols.EMPTY_STRING;
if (element.prefix != null && element.uri == null)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "ElementPrefixUnbound", new Object[] { element.prefix, element.rawname }, (short)2);
for (int j = 0; j < length; j++) {
attributes.getName(j, this.fAttributeQName);
String aprefix = (this.fAttributeQName.prefix != null) ? this.fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
String arawname = this.fAttributeQName.rawname;
if (arawname == XMLSymbols.PREFIX_XMLNS) {
this.fAttributeQName.uri = this.fNamespaceSupport.getURI(XMLSymbols.PREFIX_XMLNS);
attributes.setName(j, this.fAttributeQName);
} else if (aprefix != XMLSymbols.EMPTY_STRING) {
this.fAttributeQName.uri = this.fNamespaceSupport.getURI(aprefix);
if (this.fAttributeQName.uri == null)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "AttributePrefixUnbound", new Object[] { aprefix, arawname }, (short)2);
attributes.setName(j, this.fAttributeQName);
}
}
int attrCount = attributes.getLength();
for (int k = 0; k < attrCount - 1; k++) {
String alocalpart = attributes.getLocalName(k);
String auri = attributes.getURI(k);
for (int m = k + 1; m < attrCount; m++) {
String blocalpart = attributes.getLocalName(m);
String buri = attributes.getURI(m);
if (alocalpart == blocalpart && auri == buri)
this.fErrorReporter.reportError("http://www.w3.org/TR/1999/REC-xml-names-19990114", "AttributeNSNotUnique", new Object[] { element.rawname, alocalpart, auri }, (short)2);
}
}
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents)
if (isEmpty) {
this.fDocumentHandler.emptyElement(element, attributes, augs);
} else {
this.fDocumentHandler.startElement(element, attributes, augs);
}
}
protected void handleEndElement(QName element, Augmentations augs, boolean isEmpty) throws XNIException {
String eprefix = (element.prefix != null) ? element.prefix : XMLSymbols.EMPTY_STRING;
element.uri = this.fNamespaceSupport.getURI(eprefix);
if (element.uri != null)
element.prefix = eprefix;
if (this.fDocumentHandler != null && !this.fOnlyPassPrefixMappingEvents &&
!isEmpty)
this.fDocumentHandler.endElement(element, augs);
if (this.fDocumentHandler != null) {
int count = this.fNamespaceSupport.getDeclaredPrefixCount();
for (int i = count - 1; i >= 0; i--) {
String prefix = this.fNamespaceSupport.getDeclaredPrefixAt(i);
this.fDocumentHandler.endPrefixMapping(prefix, augs);
}
}
this.fNamespaceSupport.popContext();
}
}

View file

@ -0,0 +1,665 @@
package com.sun.xml.stream;
import com.sun.xml.stream.dtd.nonvalidating.DTDGrammar;
import com.sun.xml.stream.dtd.nonvalidating.XMLNotationDecl;
import com.sun.xml.stream.events.EntityDeclarationImpl;
import com.sun.xml.stream.events.NotationDeclarationImpl;
import com.sun.xml.stream.xerces.util.NamespaceContextWrapper;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.XMLChar;
import com.sun.xml.stream.xerces.util.XMLStringBuffer;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.xml.sax.InputSource;
public class XMLReaderImpl implements XMLStreamReader {
protected static final String ENTITY_MANAGER = "http://apache.org/xml/properties/internal/entity-manager";
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String READER_IN_DEFINED_STATE = "http://java.sun.com/xml/stream/properties/reader-in-defined-state";
private SymbolTable fSymbolTable = new SymbolTable();
protected XMLNSDocumentScannerImpl fScanner = new XMLNSDocumentScannerImpl();
protected NamespaceContextWrapper fNamespaceContextWrapper = new NamespaceContextWrapper(this.fScanner.getNamespaceContext());
protected XMLEntityManager fEntityManager = new XMLEntityManager();
protected StaxErrorReporter fErrorReporter = new StaxErrorReporter();
protected XMLEntityReaderImpl fEntityScanner = null;
protected XMLInputSource fInputSource = null;
protected PropertyManager fPropertyManager = null;
private int fEventType;
static final boolean DEBUG = false;
private boolean fReuse = true;
private boolean fReaderInDefinedState = true;
private boolean fBindNamespaces = true;
private String fDTDDecl = null;
public XMLReaderImpl(InputStream inputStream, PropertyManager props) throws XMLStreamException {
init(props);
XMLInputSource inputSource = new XMLInputSource(null, null, null, inputStream, null);
setInputSource(inputSource);
}
public XMLReaderImpl(String systemid, PropertyManager props) throws XMLStreamException {
init(props);
XMLInputSource inputSource = new XMLInputSource(null, systemid, null);
setInputSource(inputSource);
}
public XMLReaderImpl(InputStream inputStream, String encoding, PropertyManager props) throws XMLStreamException {
init(props);
XMLInputSource inputSource = new XMLInputSource(null, null, null, new BufferedInputStream(inputStream), encoding);
setInputSource(inputSource);
}
public XMLReaderImpl(Reader reader, PropertyManager props) throws XMLStreamException {
init(props);
XMLInputSource inputSource = new XMLInputSource(null, null, null, new BufferedReader(reader), null);
setInputSource(inputSource);
}
public XMLReaderImpl(XMLInputSource inputSource, PropertyManager props) throws XMLStreamException {
init(props);
setInputSource(inputSource);
}
public void setInputSource(XMLInputSource inputSource) throws XMLStreamException {
this.fReuse = false;
try {
this.fScanner.setInputSource(inputSource);
if (this.fReaderInDefinedState)
this.fEventType = this.fScanner.next();
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void setInputSource(InputSource inputSource) throws XMLStreamException {
setInputSource(convertSAXInputSource2XMLInputSource(inputSource));
}
XMLInputSource convertSAXInputSource2XMLInputSource(InputSource inputSource) {
XMLInputSource xmlInputSource = new XMLInputSource(inputSource.getPublicId(), inputSource.getSystemId(), null);
InputStream inputStream = inputSource.getByteStream();
if (inputStream != null && !(inputStream instanceof java.io.ByteArrayInputStream) && !(inputStream instanceof BufferedInputStream))
inputStream = new BufferedInputStream(inputStream);
xmlInputSource.setByteStream(inputStream);
Reader reader = inputSource.getCharacterStream();
if (reader != null && !(reader instanceof BufferedReader) && !(reader instanceof java.io.CharArrayReader) && !(reader instanceof java.io.StringReader))
reader = new BufferedReader(reader);
xmlInputSource.setCharacterStream(reader);
xmlInputSource.setEncoding(inputSource.getEncoding());
return xmlInputSource;
}
void init(PropertyManager propertyManager) throws XMLStreamException {
this.fPropertyManager = propertyManager;
propertyManager.setProperty("http://apache.org/xml/properties/internal/symbol-table", this.fSymbolTable);
propertyManager.setProperty("http://apache.org/xml/properties/internal/error-reporter", this.fErrorReporter);
propertyManager.setProperty("http://apache.org/xml/properties/internal/entity-manager", this.fEntityManager);
reset();
}
public boolean canReuse() {
return this.fReuse;
}
public void reset() {
this.fReuse = true;
this.fEventType = 0;
this.fEntityManager.reset(this.fPropertyManager);
this.fScanner.reset(this.fPropertyManager);
this.fDTDDecl = null;
this.fEntityScanner = (XMLEntityReaderImpl)this.fEntityManager.getEntityReader();
this.fReaderInDefinedState = (Boolean)this.fPropertyManager.getProperty("http://java.sun.com/xml/stream/properties/reader-in-defined-state");
this.fBindNamespaces = (Boolean)this.fPropertyManager.getProperty("javax.xml.stream.isNamespaceAware");
}
public void close() throws XMLStreamException {
this.fReuse = true;
}
public String getCharacterEncodingScheme() {
return this.fScanner.getCharacterEncodingScheme();
}
public int getColumnNumber() {
return this.fEntityScanner.getColumnNumber();
}
public String getEncoding() {
return this.fEntityScanner.getEncoding();
}
public int getEventType() {
return this.fEventType;
}
public int getLineNumber() {
return this.fEntityScanner.getLineNumber();
}
public String getLocalName() {
if (this.fEventType == 1 || this.fEventType == 2)
return (this.fScanner.getElementQName()).localpart;
if (this.fEventType == 3)
return this.fScanner.getPITarget();
if (this.fEventType == 9)
return this.fScanner.getEntityName();
return null;
}
public String getNamespaceURI() {
if (this.fEventType == 1 || this.fEventType == 2)
return (this.fScanner.getElementQName()).uri;
return null;
}
public String getPIData() {
if (this.fEventType == 3)
return this.fScanner.getPIData().toString();
throw new IllegalStateException("Current state of the parser is " + getEventTypeString(this.fEventType) + " But expected state is " + getEventTypeString(3));
}
public String getPITarget() {
if (this.fEventType == 3)
return this.fScanner.getPITarget();
throw new IllegalStateException("Current state of the parser is " + getEventTypeString(this.fEventType) + " But expected state is " + getEventTypeString(3));
}
public String getPrefix() {
if (this.fEventType == 1 || this.fEventType == 2)
return (this.fScanner.getElementQName()).prefix;
return null;
}
public char[] getTextCharacters() {
if (this.fEventType == 4 || this.fEventType == 5 || this.fEventType == 12 || this.fEventType == 6)
return (this.fScanner.getCharacterData()).ch;
throw new IllegalStateException("Current state = " + getEventTypeString(this.fEventType) + " is not among the states " + getEventTypeString(4) + " , " + getEventTypeString(5) + " , " + getEventTypeString(12) + " , " + getEventTypeString(6) + " valid for getTextCharacters() ");
}
public int getTextLength() {
if (this.fEventType == 4 || this.fEventType == 5 || this.fEventType == 12 || this.fEventType == 6)
return (this.fScanner.getCharacterData()).length;
throw new IllegalStateException("Current state = " + getEventTypeString(this.fEventType) + " is not among the states " + getEventTypeString(4) + " , " + getEventTypeString(5) + " , " + getEventTypeString(12) + " , " + getEventTypeString(6) + " valid for getTextLength() ");
}
public int getTextStart() {
if (this.fEventType == 4 || this.fEventType == 5 || this.fEventType == 12 || this.fEventType == 6)
return (this.fScanner.getCharacterData()).offset;
throw new IllegalStateException("Current state = " + getEventTypeString(this.fEventType) + " is not among the states " + getEventTypeString(4) + " , " + getEventTypeString(5) + " , " + getEventTypeString(12) + " , " + getEventTypeString(6) + " valid for getTextStart() ");
}
public String getValue() {
if (this.fEventType == 3)
return this.fScanner.getPIData().toString();
if (this.fEventType == 5)
return this.fScanner.getComment();
if (this.fEventType == 1 || this.fEventType == 2)
return (this.fScanner.getElementQName()).localpart;
if (this.fEventType == 4)
return this.fScanner.getCharacterData().toString();
return null;
}
public String getVersion() {
return this.fEntityScanner.getVersion();
}
public boolean hasAttributes() {
return (this.fScanner.getAttributeIterator().getLength() > 0);
}
public boolean hasName() {
if (this.fEventType == 1 || this.fEventType == 2 || this.fEventType == 9 || this.fEventType == 3)
return true;
return false;
}
public boolean hasNext() throws XMLStreamException {
return (this.fEventType != 8);
}
public boolean hasValue() {
if (this.fEventType == 1 || this.fEventType == 2 || this.fEventType == 9 || this.fEventType == 3 || this.fEventType == 5 || this.fEventType == 4)
return true;
return false;
}
public boolean isEndElement() {
return (this.fEventType == 2);
}
public boolean isStandalone() {
return this.fScanner.isStandAlone();
}
public boolean isStartElement() {
return (this.fEventType == 1);
}
public boolean isWhiteSpace() {
if (isCharacters() || this.fEventType == 12) {
char[] ch = getTextCharacters();
int start = getTextStart();
int end = start + getTextLength();
for (int i = start; i < end; i++) {
if (!XMLChar.isSpace(ch[i]))
return false;
}
return true;
}
return false;
}
public int next() throws XMLStreamException {
try {
return this.fEventType = this.fScanner.next();
} catch (IOException ex) {
throw new XMLStreamException(ex.getMessage(), getLocation(), ex);
} catch (XNIException ex) {
throw new XMLStreamException(ex.getMessage(), getLocation(), ex.getException());
}
}
static final String getEventTypeString(int eventType) {
switch (eventType) {
case 1:
return "START_ELEMENT";
case 2:
return "END_ELEMENT";
case 3:
return "PROCESSING_INSTRUCTION";
case 4:
return "CHARACTERS";
case 5:
return "COMMENT";
case 7:
return "START_DOCUMENT";
case 8:
return "END_DOCUMENT";
case 9:
return "ENTITY_REFERENCE";
case 10:
return "ATTRIBUTE";
case 11:
return "DTD";
case 12:
return "CDATA";
case 6:
return "SPACE";
}
return "UNKNOWN_EVENT_TYPE , " + String.valueOf(eventType);
}
public int getAttributeCount() {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getLength();
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeCount()");
}
public QName getAttributeName(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return convertXNIQNametoJavaxQName(this.fScanner.getAttributeIterator().getQualifiedName(index));
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeName()");
}
public String getAttributeLocalName(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getLocalName(index);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeLocalName()");
}
public String getAttributeNamespace(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getURI(index);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeNamespace()");
}
public String getAttributePrefix(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getPrefix(index);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributePrefix()");
}
public QName getAttributeQName(int index) {
if (this.fEventType == 1 || this.fEventType == 10) {
String localName = this.fScanner.getAttributeIterator().getLocalName(index);
String uri = this.fScanner.getAttributeIterator().getURI(index);
return new QName(uri, localName);
}
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeQName()");
}
public String getAttributeType(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getType(index);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeType()");
}
public String getAttributeValue(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getValue(index);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeValue()");
}
public String getAttributeValue(String namespaceURI, String localName) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().getValue(namespaceURI, localName);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for getAttributeValue()");
}
public String getElementText() throws XMLStreamException {
if (getEventType() != 1)
throw new XMLStreamException("parser must be on START_ELEMENT to read next text", getLocation());
int eventType = next();
StringBuffer content = new StringBuffer();
while (eventType != 2) {
if (eventType == 4 || eventType == 12 || eventType == 6 || eventType == 9) {
content.append(getText());
} else if (eventType != 3 && eventType != 5) {
if (eventType == 8)
throw new XMLStreamException("unexpected end of document when reading element text content");
if (eventType == 1)
throw new XMLStreamException("elementGetText() function expects text only elment but START_ELEMENT was encountered.", getLocation());
throw new XMLStreamException("Unexpected event type " + eventType, getLocation());
}
eventType = next();
}
return content.toString();
}
public Location getLocation() {
return new Location() {
public String getLocationURI() {
return XMLReaderImpl.this.fEntityScanner.getExpandedSystemId();
}
public int getCharacterOffset() {
return XMLReaderImpl.this.fEntityScanner.getCharacterOffset();
}
public int getColumnNumber() {
return XMLReaderImpl.this.fEntityScanner.getColumnNumber();
}
public int getLineNumber() {
return XMLReaderImpl.this.fEntityScanner.getLineNumber();
}
public String getPublicId() {
return XMLReaderImpl.this.fEntityScanner.getPublicId();
}
public String getSystemId() {
return XMLReaderImpl.this.fEntityScanner.getExpandedSystemId();
}
public String toString() {
StringBuffer sbuffer = new StringBuffer();
sbuffer.append("Line number = " + getLineNumber());
sbuffer.append("\n");
sbuffer.append("Column number = " + getColumnNumber());
sbuffer.append("\n");
sbuffer.append("System Id = " + getSystemId());
sbuffer.append("\n");
sbuffer.append("Public Id = " + getPublicId());
sbuffer.append("\n");
sbuffer.append("Location Uri= " + getLocationURI());
sbuffer.append("\n");
sbuffer.append("CharacterOffset = " + getCharacterOffset());
sbuffer.append("\n");
return sbuffer.toString();
}
};
}
public QName getName() {
if (this.fEventType == 1 || this.fEventType == 2)
return convertXNIQNametoJavaxQName(this.fScanner.getElementQName());
throw new IllegalArgumentException("Illegal to call getName() when event type is " + getEventTypeString(this.fEventType) + "." + " Valid states are " + getEventTypeString(1) + ", " + getEventTypeString(2));
}
public NamespaceContext getNamespaceContext() {
return this.fNamespaceContextWrapper;
}
public int getNamespaceCount() {
if (this.fEventType == 1 || this.fEventType == 2 || this.fEventType == 13)
return this.fScanner.getNamespaceContext().getDeclaredPrefixCount();
throw new IllegalStateException("Current state " + getEventTypeString(this.fEventType) + " is not among the states " + getEventTypeString(1) + ", " + getEventTypeString(2) + ", " + getEventTypeString(13) + " valid for getNamespaceCount().");
}
public String getNamespacePrefix(int index) {
if (this.fEventType == 1 || this.fEventType == 2 || this.fEventType == 13) {
String prefix = this.fScanner.getNamespaceContext().getDeclaredPrefixAt(index);
return prefix.equals("") ? null : prefix;
}
throw new IllegalStateException("Current state " + getEventTypeString(this.fEventType) + " is not among the states " + getEventTypeString(1) + ", " + getEventTypeString(2) + ", " + getEventTypeString(13) + " valid for getNamespacePrefix().");
}
public String getNamespaceURI(int index) {
if (this.fEventType == 1 || this.fEventType == 2 || this.fEventType == 13)
return this.fScanner.getNamespaceContext().getURI(this.fScanner.getNamespaceContext().getDeclaredPrefixAt(index));
throw new IllegalStateException("Current state " + getEventTypeString(this.fEventType) + " is not among the states " + getEventTypeString(1) + ", " + getEventTypeString(2) + ", " + getEventTypeString(13) + " valid for getNamespaceURI().");
}
public Object getProperty(String name) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException();
if (this.fPropertyManager != null) {
if (name.equals("javax.xml.stream.notations"))
return getNotationDecls();
if (name.equals("javax.xml.stream.entities"))
return getEntityDecls();
return this.fPropertyManager.getProperty(name);
}
return null;
}
public String getText() {
if (this.fEventType == 4 || this.fEventType == 5 || this.fEventType == 12 || this.fEventType == 6)
return this.fScanner.getCharacterData().toString();
if (this.fEventType == 9) {
String name = this.fScanner.getEntityName();
if (name != null) {
if (this.fScanner.foundBuiltInRefs)
return this.fScanner.getCharacterData().toString();
XMLEntityStorage entityStore = this.fEntityManager.getEntityStore();
Hashtable ht = entityStore.getDeclaredEntities();
Entity en = (Entity)ht.get(name);
if (en == null)
return null;
if (en.isExternal())
return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
return ((Entity.InternalEntity)en).text;
}
return null;
}
if (this.fEventType == 11) {
if (this.fDTDDecl != null)
return this.fDTDDecl;
XMLStringBuffer tmpBuffer = this.fScanner.getDTDDecl();
this.fDTDDecl = tmpBuffer.toString();
return this.fDTDDecl;
}
throw new IllegalStateException("Current state " + getEventTypeString(this.fEventType) + " is not among the states" + getEventTypeString(4) + ", " + getEventTypeString(5) + ", " + getEventTypeString(12) + ", " + getEventTypeString(6) + ", " + getEventTypeString(9) + ", " + getEventTypeString(11) + " valid for getText() ");
}
public void require(int type, String namespaceURI, String localName) throws XMLStreamException {
if (type != this.fEventType)
throw new XMLStreamException("Event type " + getEventTypeString(type) + " specified did " + "not match with current parser event " + getEventTypeString(this.fEventType));
if (namespaceURI != null && !namespaceURI.equals(getNamespaceURI()))
throw new XMLStreamException("Namespace URI " + namespaceURI + " specified did not match " + "with current namespace URI");
if (localName != null && !localName.equals(getLocalName()))
throw new XMLStreamException("LocalName " + localName + " specified did not match with " + "current local name");
}
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException {
if (target == null)
throw new NullPointerException("target char array can't be null");
if (targetStart < 0 || length < 0 || sourceStart < 0 || targetStart >= target.length || targetStart + length > target.length)
throw new IndexOutOfBoundsException();
int copiedLength = 0;
int available = getTextLength() - sourceStart;
if (available < 0)
throw new IndexOutOfBoundsException("sourceStart is greater thannumber of characters associated with this event");
if (available < length) {
copiedLength = available;
} else {
copiedLength = length;
}
System.arraycopy(getTextCharacters(), getTextStart() + sourceStart, target, targetStart, copiedLength);
return copiedLength;
}
public boolean hasText() {
if (this.fEventType == 4 || this.fEventType == 5 || this.fEventType == 12)
return ((this.fScanner.getCharacterData()).length > 0);
if (this.fEventType == 9) {
String name = this.fScanner.getEntityName();
if (name != null) {
if (this.fScanner.foundBuiltInRefs)
return true;
XMLEntityStorage entityStore = this.fEntityManager.getEntityStore();
Hashtable ht = entityStore.getDeclaredEntities();
Entity en = (Entity)ht.get(name);
if (en == null)
return false;
if (en.isExternal())
return (((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null);
return (((Entity.InternalEntity)en).text != null);
}
return false;
}
if (this.fEventType == 11)
return this.fScanner.fSeenDoctypeDecl;
return false;
}
public boolean isAttributeSpecified(int index) {
if (this.fEventType == 1 || this.fEventType == 10)
return this.fScanner.getAttributeIterator().isSpecified(index);
throw new IllegalStateException("Current state is not among the states " + getEventTypeString(1) + " , " + getEventTypeString(10) + "valid for isAttributeSpecified()");
}
public boolean isCharacters() {
return (this.fEventType == 4);
}
public int nextTag() throws XMLStreamException {
int eventType = next();
while ((eventType == 4 && isWhiteSpace()) || (eventType == 12 && isWhiteSpace()) || eventType == 6 || eventType == 3 || eventType == 5)
eventType = next();
if (eventType != 1 && eventType != 2)
throw new XMLStreamException("expected start or end tag", getLocation());
return eventType;
}
public boolean standaloneSet() {
return this.fScanner.isStandAlone();
}
public QName convertXNIQNametoJavaxQName(com.sun.xml.stream.xerces.xni.QName qname) {
if (qname.prefix == null)
return new QName(qname.uri, qname.localpart);
return new QName(qname.uri, qname.localpart, qname.prefix);
}
public String getNamespaceURI(String prefix) {
return this.fScanner.getNamespaceContext().getURI(this.fSymbolTable.addSymbol(prefix));
}
protected void setPropertyManager(PropertyManager propertyManager) {
this.fPropertyManager = propertyManager;
this.fScanner.setProperty("stax-properties", propertyManager);
this.fScanner.setPropertyManager(propertyManager);
}
protected PropertyManager getPropertyManager() {
return this.fPropertyManager;
}
static void pr(String str) {
System.out.println(str);
}
protected List getEntityDecls() {
if (this.fEventType == 11) {
XMLEntityStorage entityStore = this.fEntityManager.getEntityStore();
Hashtable ht = entityStore.getDeclaredEntities();
ArrayList<EntityDeclarationImpl> list = null;
if (ht != null) {
EntityDeclarationImpl decl = null;
list = new ArrayList(ht.size());
Enumeration<String> enu = ht.keys();
while (enu.hasMoreElements()) {
String key = enu.nextElement();
Entity en = (Entity)ht.get(key);
decl = new EntityDeclarationImpl();
decl.setEntityName(key);
if (en.isExternal()) {
decl.setXMLResourceIdentifier(((Entity.ExternalEntity)en).entityLocation);
decl.setNotationName(((Entity.ExternalEntity)en).notation);
} else {
decl.setEntityReplacementText(((Entity.InternalEntity)en).text);
}
list.add(decl);
}
}
return list;
}
return null;
}
protected List getNotationDecls() {
if (this.fEventType == 11) {
if (this.fScanner.fDTDScanner == null)
return null;
DTDGrammar grammar = ((XMLDTDScannerImpl)this.fScanner.fDTDScanner).getGrammar();
if (grammar == null)
return null;
List notations = grammar.getNotationDecls();
Iterator<XMLNotationDecl> it = notations.iterator();
ArrayList<NotationDeclarationImpl> list = new ArrayList();
while (it.hasNext()) {
XMLNotationDecl ni = it.next();
if (ni != null)
list.add(new NotationDeclarationImpl(ni));
}
return list;
}
return null;
}
}

View file

@ -0,0 +1,717 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.XMLChar;
import com.sun.xml.stream.xerces.util.XMLResourceIdentifierImpl;
import com.sun.xml.stream.xerces.util.XMLStringBuffer;
import com.sun.xml.stream.xerces.xni.XMLAttributes;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponent;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.stream.events.XMLEvent;
public abstract class XMLScanner implements XMLComponent {
protected static final String VALIDATION = "http://xml.org/sax/features/validation";
protected static final String NOTIFY_CHAR_REFS = "http://apache.org/xml/features/scanner/notify-char-refs";
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String ERROR_REPORTER = "http://apache.org/xml/properties/internal/error-reporter";
protected static final String ENTITY_MANAGER = "http://apache.org/xml/properties/internal/entity-manager";
protected static final boolean DEBUG_ATTR_NORMALIZATION = false;
private boolean fNeedNonNormalizedValue = false;
protected ArrayList attributeValueCache = new ArrayList();
protected ArrayList stringBufferCache = new ArrayList();
protected int fStringBufferIndex = 0;
protected boolean fAttributeCacheInitDone = false;
protected int fAttributeCacheUsedCount = 0;
protected boolean fValidation = false;
protected boolean fNotifyCharRefs = false;
protected PropertyManager fPropertyManager = null;
protected SymbolTable fSymbolTable;
protected XMLErrorReporter fErrorReporter;
protected XMLEntityManager fEntityManager = null;
protected XMLEntityStorage fEntityStore = null;
protected XMLEvent fEvent;
protected XMLEntityReaderImpl fEntityScanner = null;
protected int fEntityDepth;
protected String fCharRefLiteral = null;
protected boolean fScanningAttribute;
protected boolean fReportEntity;
protected static final String fVersionSymbol = "version".intern();
protected static final String fEncodingSymbol = "encoding".intern();
protected static final String fStandaloneSymbol = "standalone".intern();
protected static final String fAmpSymbol = "amp".intern();
protected static final String fLtSymbol = "lt".intern();
protected static final String fGtSymbol = "gt".intern();
protected static final String fQuotSymbol = "quot".intern();
protected static final String fAposSymbol = "apos".intern();
private XMLString fString = new XMLString();
private XMLStringBuffer fStringBuffer = new XMLStringBuffer();
private XMLStringBuffer fStringBuffer2 = new XMLStringBuffer();
private XMLStringBuffer fStringBuffer3 = new XMLStringBuffer();
protected XMLResourceIdentifierImpl fResourceIdentifier = new XMLResourceIdentifierImpl();
int initialCacheCount = 6;
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
this.fSymbolTable = (SymbolTable)componentManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)componentManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
this.fEntityManager = (XMLEntityManager)componentManager.getProperty("http://apache.org/xml/properties/internal/entity-manager");
init();
try {
this.fValidation = componentManager.getFeature("http://xml.org/sax/features/validation");
} catch (XMLConfigurationException e) {
this.fValidation = false;
}
try {
this.fNotifyCharRefs = componentManager.getFeature("http://apache.org/xml/features/scanner/notify-char-refs");
} catch (XMLConfigurationException e) {
this.fNotifyCharRefs = false;
}
}
protected void setPropertyManager(PropertyManager propertyManager) {
this.fPropertyManager = propertyManager;
}
public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
if (propertyId.startsWith("http://apache.org/xml/properties/")) {
String property = propertyId.substring("http://apache.org/xml/properties/".length());
if (property.equals("internal/symbol-table")) {
this.fSymbolTable = (SymbolTable)value;
} else if (property.equals("internal/error-reporter")) {
this.fErrorReporter = (XMLErrorReporter)value;
} else if (property.equals("internal/entity-manager")) {
this.fEntityManager = (XMLEntityManager)value;
}
}
}
public void setFeature(String featureId, boolean value) throws XMLConfigurationException {
if ("http://xml.org/sax/features/validation".equals(featureId)) {
this.fValidation = value;
} else if ("http://apache.org/xml/features/scanner/notify-char-refs".equals(featureId)) {
this.fNotifyCharRefs = value;
}
}
public boolean getFeature(String featureId) throws XMLConfigurationException {
if ("http://xml.org/sax/features/validation".equals(featureId))
return this.fValidation;
if ("http://apache.org/xml/features/scanner/notify-char-refs".equals(featureId))
return this.fNotifyCharRefs;
throw new XMLConfigurationException((short)0, featureId);
}
public void reset(PropertyManager propertyManager) {
init();
this.fSymbolTable = (SymbolTable)propertyManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fErrorReporter = (XMLErrorReporter)propertyManager.getProperty("http://apache.org/xml/properties/internal/error-reporter");
this.fEntityManager = (XMLEntityManager)propertyManager.getProperty("http://apache.org/xml/properties/internal/entity-manager");
this.fEntityStore = this.fEntityManager.getEntityStore();
this.fEntityScanner = (XMLEntityReaderImpl)this.fEntityManager.getEntityReader();
this.fValidation = false;
this.fNotifyCharRefs = false;
}
protected void scanXMLDeclOrTextDecl(boolean scanningTextDecl, String[] pseudoAttributeValues) throws IOException, XNIException {
String version = null;
String encoding = null;
String standalone = null;
int STATE_VERSION = 0;
int STATE_ENCODING = 1;
int STATE_STANDALONE = 2;
int STATE_DONE = 3;
int state = 0;
boolean dataFoundForTarget = false;
boolean sawSpace = this.fEntityScanner.skipSpaces();
while (this.fEntityScanner.peekChar() != 63) {
dataFoundForTarget = true;
String name = scanPseudoAttribute(scanningTextDecl, this.fString);
switch (state) {
case 0:
if (name.equals(fVersionSymbol)) {
if (!sawSpace)
reportFatalError(scanningTextDecl ? "SpaceRequiredBeforeVersionInTextDecl" : "SpaceRequiredBeforeVersionInXMLDecl", null);
version = this.fString.toString();
state = 1;
if (!versionSupported(version))
reportFatalError("VersionNotSupported", new Object[] { version });
break;
}
if (name.equals(fEncodingSymbol)) {
if (!scanningTextDecl)
reportFatalError("VersionInfoRequired", null);
if (!sawSpace)
reportFatalError(scanningTextDecl ? "SpaceRequiredBeforeEncodingInTextDecl" : "SpaceRequiredBeforeEncodingInXMLDecl", null);
encoding = this.fString.toString();
state = scanningTextDecl ? 3 : 2;
break;
}
if (scanningTextDecl) {
reportFatalError("EncodingDeclRequired", null);
} else {
reportFatalError("VersionInfoRequired", null);
}
break;
case 1:
if (name.equals(fEncodingSymbol)) {
if (!sawSpace)
reportFatalError(scanningTextDecl ? "SpaceRequiredBeforeEncodingInTextDecl" : "SpaceRequiredBeforeEncodingInXMLDecl", null);
encoding = this.fString.toString();
state = scanningTextDecl ? 3 : 2;
break;
}
if (!scanningTextDecl && name.equals(fStandaloneSymbol)) {
if (!sawSpace)
reportFatalError("SpaceRequiredBeforeStandalone", null);
standalone = this.fString.toString();
state = 3;
if (!standalone.equals("yes") && !standalone.equals("no"))
reportFatalError("SDDeclInvalid", null);
break;
}
reportFatalError("EncodingDeclRequired", null);
break;
case 2:
if (name.equals(fStandaloneSymbol)) {
if (!sawSpace)
reportFatalError("SpaceRequiredBeforeStandalone", null);
standalone = this.fString.toString();
state = 3;
if (!standalone.equals("yes") && !standalone.equals("no"))
reportFatalError("SDDeclInvalid", null);
break;
}
reportFatalError("EncodingDeclRequired", null);
break;
default:
reportFatalError("NoMorePseudoAttributes", null);
break;
}
sawSpace = this.fEntityScanner.skipSpaces();
}
if (scanningTextDecl && state != 3)
reportFatalError("MorePseudoAttributes", null);
if (scanningTextDecl) {
if (!dataFoundForTarget && encoding == null)
reportFatalError("EncodingDeclRequired", null);
} else if (!dataFoundForTarget && version == null) {
reportFatalError("VersionInfoRequired", null);
}
if (!this.fEntityScanner.skipChar(63))
reportFatalError("XMLDeclUnterminated", null);
if (!this.fEntityScanner.skipChar(62))
reportFatalError("XMLDeclUnterminated", null);
pseudoAttributeValues[0] = version;
pseudoAttributeValues[1] = encoding;
pseudoAttributeValues[2] = standalone;
}
public String scanPseudoAttribute(boolean scanningTextDecl, XMLString value) throws IOException, XNIException {
String name = this.fEntityScanner.scanName();
if (name == null)
reportFatalError("PseudoAttrNameExpected", null);
this.fEntityScanner.skipSpaces();
if (!this.fEntityScanner.skipChar(61))
reportFatalError(scanningTextDecl ? "EqRequiredInTextDecl" : "EqRequiredInXMLDecl", new Object[] { name });
this.fEntityScanner.skipSpaces();
int quote = this.fEntityScanner.peekChar();
if (quote != 39 && quote != 34)
reportFatalError(scanningTextDecl ? "QuoteRequiredInTextDecl" : "QuoteRequiredInXMLDecl", new Object[] { name });
this.fEntityScanner.scanChar();
int c = this.fEntityScanner.scanLiteral(quote, value);
if (c != quote) {
this.fStringBuffer2.clear();
while (true) {
this.fStringBuffer2.append(value);
if (c != -1)
if (c == 38 || c == 37 || c == 60 || c == 93) {
this.fStringBuffer2.append((char)this.fEntityScanner.scanChar());
} else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(this.fStringBuffer2);
} else if (isInvalidLiteral(c)) {
String key = scanningTextDecl ? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
reportFatalError(key, new Object[] { Integer.toString(c, 16) });
this.fEntityScanner.scanChar();
}
c = this.fEntityScanner.scanLiteral(quote, value);
if (c == quote) {
this.fStringBuffer2.append(value);
value.setValues(this.fStringBuffer2);
break;
}
}
}
if (!this.fEntityScanner.skipChar(quote))
reportFatalError(scanningTextDecl ? "CloseQuoteMissingInTextDecl" : "CloseQuoteMissingInXMLDecl", new Object[] { name });
return name;
}
protected void scanPI(XMLStringBuffer data) throws IOException, XNIException {
this.fReportEntity = false;
String target = this.fEntityScanner.scanName();
if (target == null)
reportFatalError("PITargetRequired", null);
scanPIData(target, data);
this.fReportEntity = true;
}
protected void scanPIData(String target, XMLStringBuffer data) throws IOException, XNIException {
if (target.length() == 3) {
char c0 = Character.toLowerCase(target.charAt(0));
char c1 = Character.toLowerCase(target.charAt(1));
char c2 = Character.toLowerCase(target.charAt(2));
if (c0 == 'x' && c1 == 'm' && c2 == 'l')
reportFatalError("ReservedPITarget", null);
}
if (!this.fEntityScanner.skipSpaces()) {
if (this.fEntityScanner.skipString("?>"))
return;
reportFatalError("SpaceRequiredInPI", null);
}
if (this.fEntityScanner.scanData("?>", data))
do {
int c = this.fEntityScanner.peekChar();
if (c == -1)
continue;
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(data);
} else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInPI", new Object[] { Integer.toHexString(c) });
this.fEntityScanner.scanChar();
}
} while (this.fEntityScanner.scanData("?>", data));
}
protected void scanComment(XMLStringBuffer text) throws IOException, XNIException {
text.clear();
while (this.fEntityScanner.scanData("--", text)) {
int c = this.fEntityScanner.peekChar();
System.out.println("XMLScanner#scanComment#text.toString() == " + text.toString());
System.out.println("XMLScanner#scanComment#c == " + c);
if (c != -1) {
if (XMLChar.isHighSurrogate(c))
scanSurrogates(text);
if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInComment", new Object[] { Integer.toHexString(c) });
this.fEntityScanner.scanChar();
}
}
}
if (!this.fEntityScanner.skipChar(62))
reportFatalError("DashDashInComment", null);
}
protected void scanAttributeValue(XMLString value, XMLString nonNormalizedValue, String atName, XMLAttributes attributes, int attrIndex, boolean checkEntities) throws IOException, XNIException {
XMLStringBuffer stringBuffer = null;
int quote = this.fEntityScanner.peekChar();
if (quote != 39 && quote != 34)
reportFatalError("OpenQuoteExpected", new Object[] { atName });
this.fEntityScanner.scanChar();
int entityDepth = this.fEntityDepth;
int c = this.fEntityScanner.scanLiteral(quote, value);
if (this.fNeedNonNormalizedValue) {
this.fStringBuffer2.clear();
this.fStringBuffer2.append(value);
}
if (this.fEntityScanner.whiteSpaceLen > 0)
normalizeWhitespace(value);
if (c != quote) {
this.fScanningAttribute = true;
stringBuffer = getStringBuffer();
stringBuffer.clear();
while (true) {
stringBuffer.append(value);
if (c == 38) {
this.fEntityScanner.skipChar(38);
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append('&');
if (this.fEntityScanner.skipChar(35)) {
int ch;
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append('#');
if (this.fNeedNonNormalizedValue) {
ch = scanCharReferenceValue(stringBuffer, this.fStringBuffer2);
} else {
ch = scanCharReferenceValue(stringBuffer, null);
}
if (ch != -1);
} else {
String entityName = this.fEntityScanner.scanName();
if (entityName == null) {
reportFatalError("NameRequiredInReference", null);
} else if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue) {
this.fStringBuffer2.append(entityName);
}
if (!this.fEntityScanner.skipChar(59)) {
reportFatalError("SemicolonRequiredInReference", new Object[] { entityName });
} else if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue) {
this.fStringBuffer2.append(';');
}
if (entityName == fAmpSymbol) {
stringBuffer.append('&');
} else if (entityName == fAposSymbol) {
stringBuffer.append('\'');
} else if (entityName == fLtSymbol) {
stringBuffer.append('<');
} else if (entityName == fGtSymbol) {
stringBuffer.append('>');
} else if (entityName == fQuotSymbol) {
stringBuffer.append('"');
} else if (this.fEntityStore.isExternalEntity(entityName)) {
reportFatalError("ReferenceToExternalEntity", new Object[] { entityName });
} else {
if (!this.fEntityStore.isDeclaredEntity(entityName))
if (checkEntities) {
if (this.fValidation)
this.fErrorReporter.reportError(this.fEntityScanner, "http://www.w3.org/TR/1998/REC-xml-19980210", "EntityNotDeclared", new Object[] { entityName }, (short)1);
} else {
reportFatalError("EntityNotDeclared", new Object[] { entityName });
}
this.fEntityManager.startEntity(entityName, true);
}
}
} else if (c == 60) {
reportFatalError("LessthanInAttValue", new Object[] { null, atName });
this.fEntityScanner.scanChar();
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append((char)c);
} else if (c == 37 || c == 93) {
this.fEntityScanner.scanChar();
stringBuffer.append((char)c);
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append((char)c);
} else if (c == 10 || c == 13) {
this.fEntityScanner.scanChar();
stringBuffer.append(' ');
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append('\n');
} else if (c != -1 && XMLChar.isHighSurrogate(c)) {
if (scanSurrogates(this.fStringBuffer3)) {
stringBuffer.append(this.fStringBuffer3);
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append(this.fStringBuffer3);
}
} else if (c != -1 && isInvalidLiteral(c)) {
reportFatalError("InvalidCharInAttValue", new Object[] { Integer.toString(c, 16) });
this.fEntityScanner.scanChar();
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append((char)c);
}
c = this.fEntityScanner.scanLiteral(quote, value);
if (entityDepth == this.fEntityDepth && this.fNeedNonNormalizedValue)
this.fStringBuffer2.append(value);
if (this.fEntityScanner.whiteSpaceLen > 0)
normalizeWhitespace(value);
if (c == quote && entityDepth == this.fEntityDepth) {
stringBuffer.append(value);
value.setValues(stringBuffer);
this.fScanningAttribute = false;
break;
}
}
}
if (this.fNeedNonNormalizedValue)
nonNormalizedValue.setValues(this.fStringBuffer2);
int cquote = this.fEntityScanner.scanChar();
if (cquote != quote)
reportFatalError("CloseQuoteExpected", new Object[] { atName });
}
protected void scanExternalID(String[] identifiers, boolean optionalSystemId) throws IOException, XNIException {
String systemId = null;
String publicId = null;
if (this.fEntityScanner.skipString("PUBLIC")) {
if (!this.fEntityScanner.skipSpaces())
reportFatalError("SpaceRequiredAfterPUBLIC", null);
scanPubidLiteral(this.fString);
publicId = this.fString.toString();
if (!this.fEntityScanner.skipSpaces() && !optionalSystemId)
reportFatalError("SpaceRequiredBetweenPublicAndSystem", null);
}
if (publicId != null || this.fEntityScanner.skipString("SYSTEM")) {
if (publicId == null && !this.fEntityScanner.skipSpaces())
reportFatalError("SpaceRequiredAfterSYSTEM", null);
int quote = this.fEntityScanner.peekChar();
if (quote != 39 && quote != 34) {
if (publicId != null && optionalSystemId) {
identifiers[0] = null;
identifiers[1] = publicId;
return;
}
reportFatalError("QuoteRequiredInSystemID", null);
}
this.fEntityScanner.scanChar();
XMLString ident = this.fString;
if (this.fEntityScanner.scanLiteral(quote, ident) != quote) {
this.fStringBuffer.clear();
while (true) {
this.fStringBuffer.append(ident);
int c = this.fEntityScanner.peekChar();
if (XMLChar.isMarkup(c) || c == 93)
this.fStringBuffer.append((char)this.fEntityScanner.scanChar());
if (this.fEntityScanner.scanLiteral(quote, ident) == quote) {
this.fStringBuffer.append(ident);
ident = this.fStringBuffer;
break;
}
}
}
systemId = ident.toString();
if (!this.fEntityScanner.skipChar(quote))
reportFatalError("SystemIDUnterminated", null);
}
identifiers[0] = systemId;
identifiers[1] = publicId;
}
protected boolean scanPubidLiteral(XMLString literal) throws IOException, XNIException {
int quote = this.fEntityScanner.scanChar();
if (quote != 39 && quote != 34) {
reportFatalError("QuoteRequiredInPublicID", null);
return false;
}
this.fStringBuffer.clear();
boolean skipSpace = true;
boolean dataok = true;
while (true) {
int c = this.fEntityScanner.scanChar();
if (c == 32 || c == 10 || c == 13) {
if (!skipSpace) {
this.fStringBuffer.append(' ');
skipSpace = true;
}
continue;
}
if (c == quote) {
if (skipSpace)
this.fStringBuffer.length--;
literal.setValues(this.fStringBuffer);
break;
}
if (XMLChar.isPubid(c)) {
this.fStringBuffer.append((char)c);
skipSpace = false;
continue;
}
if (c == -1) {
reportFatalError("PublicIDUnterminated", null);
return false;
}
dataok = false;
reportFatalError("InvalidCharInPublicID", new Object[] { Integer.toHexString(c) });
}
return dataok;
}
protected void normalizeWhitespace(XMLString value) {
int i = 0;
int j = 0;
int[] buff = this.fEntityScanner.whiteSpaceLookup;
int buffLen = this.fEntityScanner.whiteSpaceLen;
int end = value.offset + value.length;
while (i < buffLen) {
j = buff[i];
if (j < end)
value.ch[j] = ' ';
i++;
}
}
public void startEntity(String name, XMLResourceIdentifier identifier, String encoding) throws XNIException {
this.fEntityDepth++;
}
public void endEntity(String name) throws IOException, XNIException {
this.fEntityDepth--;
}
protected int scanCharReferenceValue(XMLStringBuffer buf, XMLStringBuffer buf2) throws IOException, XNIException {
boolean hex = false;
if (this.fEntityScanner.skipChar(120)) {
if (buf2 != null)
buf2.append('x');
hex = true;
this.fStringBuffer3.clear();
boolean digit = true;
int c = this.fEntityScanner.peekChar();
digit = ((c >= 48 && c <= 57) || (c >= 97 && c <= 102) || (c >= 65 && c <= 70));
if (digit) {
if (buf2 != null)
buf2.append((char)c);
this.fEntityScanner.scanChar();
this.fStringBuffer3.append((char)c);
do {
c = this.fEntityScanner.peekChar();
digit = ((c >= 48 && c <= 57) || (c >= 97 && c <= 102) || (c >= 65 && c <= 70));
if (!digit)
continue;
if (buf2 != null)
buf2.append((char)c);
this.fEntityScanner.scanChar();
this.fStringBuffer3.append((char)c);
} while (digit);
} else {
reportFatalError("HexdigitRequiredInCharRef", null);
}
} else {
this.fStringBuffer3.clear();
boolean digit = true;
int c = this.fEntityScanner.peekChar();
digit = (c >= 48 && c <= 57);
if (digit) {
if (buf2 != null)
buf2.append((char)c);
this.fEntityScanner.scanChar();
this.fStringBuffer3.append((char)c);
do {
c = this.fEntityScanner.peekChar();
digit = (c >= 48 && c <= 57);
if (!digit)
continue;
if (buf2 != null)
buf2.append((char)c);
this.fEntityScanner.scanChar();
this.fStringBuffer3.append((char)c);
} while (digit);
} else {
reportFatalError("DigitRequiredInCharRef", null);
}
}
if (!this.fEntityScanner.skipChar(59))
reportFatalError("SemicolonRequiredInCharRef", null);
if (buf2 != null)
buf2.append(';');
int value = -1;
try {
value = Integer.parseInt(this.fStringBuffer3.toString(), hex ? 16 : 10);
if (isInvalid(value)) {
StringBuffer errorBuf = new StringBuffer(this.fStringBuffer3.length + 1);
if (hex)
errorBuf.append('x');
errorBuf.append(this.fStringBuffer3.ch, this.fStringBuffer3.offset, this.fStringBuffer3.length);
reportFatalError("InvalidCharRef", new Object[] { errorBuf.toString() });
}
} catch (NumberFormatException e) {
StringBuffer errorBuf = new StringBuffer(this.fStringBuffer3.length + 1);
if (hex)
errorBuf.append('x');
errorBuf.append(this.fStringBuffer3.ch, this.fStringBuffer3.offset, this.fStringBuffer3.length);
reportFatalError("InvalidCharRef", new Object[] { errorBuf.toString() });
}
if (!XMLChar.isSupplemental(value)) {
buf.append((char)value);
} else {
buf.append(XMLChar.highSurrogate(value));
buf.append(XMLChar.lowSurrogate(value));
}
if (this.fNotifyCharRefs && value != -1) {
String literal = "#" + (hex ? "x" : "") + this.fStringBuffer3.toString();
if (!this.fScanningAttribute)
this.fCharRefLiteral = literal;
}
return value;
}
protected static boolean isInvalid(int value) {
return XMLChar.isInvalid(value);
}
protected static boolean isInvalidLiteral(int value) {
return XMLChar.isInvalid(value);
}
protected static boolean isValidNameChar(int value) {
return XMLChar.isName(value);
}
protected static boolean isValidNCName(int value) {
return XMLChar.isNCName(value);
}
protected static boolean isValidNameStartChar(int value) {
return XMLChar.isNameStart(value);
}
protected boolean versionSupported(String version) {
return version.equals("1.0");
}
protected boolean scanSurrogates(XMLStringBuffer buf) throws IOException, XNIException {
int high = this.fEntityScanner.scanChar();
int low = this.fEntityScanner.peekChar();
if (!XMLChar.isLowSurrogate(low)) {
reportFatalError("InvalidCharInContent", new Object[] { Integer.toString(high, 16) });
return false;
}
this.fEntityScanner.scanChar();
int c = XMLChar.supplemental((char)high, (char)low);
if (!isInvalid(c)) {
reportFatalError("InvalidCharInContent", new Object[] { Integer.toString(c, 16) });
return false;
}
buf.append((char)high);
buf.append((char)low);
return true;
}
protected void reportFatalError(String msgId, Object[] args) throws XNIException {
this.fErrorReporter.reportError(this.fEntityScanner, "http://www.w3.org/TR/1998/REC-xml-19980210", msgId, args, (short)2);
}
private void init() {
this.fEntityDepth = 0;
this.fReportEntity = true;
this.fResourceIdentifier.clear();
}
XMLStringBuffer getStringBuffer() {
if (this.fStringBufferIndex < this.initialCacheCount || this.fStringBufferIndex < this.stringBufferCache.size())
return this.stringBufferCache.get(this.fStringBufferIndex++);
XMLStringBuffer tmpObj = new XMLStringBuffer();
this.stringBufferCache.add(this.fStringBufferIndex, tmpObj);
return tmpObj;
}
}

View file

@ -0,0 +1,604 @@
package com.sun.xml.stream;
import com.sun.xml.stream.events.AttributeImpl;
import com.sun.xml.stream.events.NamespaceImpl;
import com.sun.xml.stream.xerces.util.NamespaceContextWrapper;
import com.sun.xml.stream.xerces.util.NamespaceSupport;
import com.sun.xml.stream.xerces.util.XMLChar;
import java.util.ArrayList;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import javax.xml.stream.StreamFilter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
public class XMLStreamFilterImpl implements XMLStreamReader {
private StreamFilter fStreamFilter = null;
private XMLStreamReader fStreamReader = null;
private int fCurrentEventType = -1;
private QName fElementName = null;
private String fLocalName = null;
private boolean fHasName = false;
private boolean fReadNext = true;
private boolean fHasMoreEvents = true;
private boolean fReadFromCache = true;
private ArrayList fCachedAttributes = null;
private ArrayList fCachedNamespaceAttr = null;
private NamespaceContextWrapper fCachedNamespaceContext = null;
private String fCachedElementText = null;
private int fCachedEventType = -1;
private String fCachedVersion = null;
private String fCachedEncoding = null;
private boolean fCachedStandalone = false;
private Location fCachedLocation = null;
private String fCachedTextValue = null;
private String fCachedPITarget = null;
private String fCachedPIData = null;
private String fCachedCharEncoding = null;
private static boolean DEBUG = false;
public XMLStreamFilterImpl(XMLStreamReader reader, StreamFilter filter) {
this.fStreamReader = reader;
this.fStreamFilter = filter;
this.fCachedAttributes = new ArrayList();
this.fCachedNamespaceAttr = new ArrayList();
try {
if (!this.fStreamFilter.accept(this.fStreamReader)) {
next();
cache();
}
} catch (XMLStreamException xs) {
System.err.println("Error while creating a stream Filter" + xs);
}
this.fCurrentEventType = this.fStreamReader.getEventType();
if (DEBUG)
System.out.println("Cached Event" + this.fCachedEventType);
}
protected void setStreamFilter(StreamFilter sf) {
this.fStreamFilter = sf;
}
public boolean hasNext() throws XMLStreamException {
if (this.fReadNext) {
this.fReadNext = false;
cache();
if (DEBUG)
System.out.println("Cached Event in hasNext" + this.fCachedEventType);
return readNext();
}
return this.fHasMoreEvents;
}
public void close() throws XMLStreamException {
this.fStreamReader.close();
}
public int getAttributeCount() {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeCount();
return this.fCachedAttributes.size();
}
public QName getAttributeName(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeName(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getName();
return null;
}
public String getAttributeNamespace(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeNamespace(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getName().getNamespaceURI();
return null;
}
public String getAttributePrefix(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributePrefix(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getName().getPrefix();
return null;
}
public String getAttributeType(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeType(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getDTDType();
return null;
}
public String getAttributeValue(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeValue(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getValue();
return null;
}
public String getAttributeValue(String namespaceURI, String localName) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeValue(namespaceURI, localName);
if (this.fCachedEventType != 1 || this.fCachedEventType != 10)
throw new IllegalStateException("Current event state is " + this.fCachedEventType);
for (int i = 0; i < this.fCachedAttributes.size(); i++) {
AttributeImpl attr = this.fCachedAttributes.get(i);
if (attr != null && attr.getName().getLocalPart().equals(localName) && namespaceURI.equals(attr.getName().getNamespaceURI()))
return attr.getValue();
}
return null;
}
public String getCharacterEncodingScheme() {
if (!this.fReadFromCache)
return this.fStreamReader.getCharacterEncodingScheme();
return this.fCachedCharEncoding;
}
public String getElementText() throws XMLStreamException {
if (!this.fReadFromCache)
return this.fStreamReader.getElementText();
if (this.fCachedEventType != 1)
throw new XMLStreamException("parser must be on START_ELEMENT to read next text", getLocation());
return this.fCachedElementText;
}
public String getEncoding() {
if (!this.fReadFromCache)
return this.fStreamReader.getEncoding();
return this.fCachedEncoding;
}
public int getEventType() {
if (!this.fReadFromCache)
return this.fStreamReader.getEventType();
return this.fCachedEventType;
}
public String getLocalName() {
if (!this.fReadFromCache)
return this.fStreamReader.getLocalName();
return this.fLocalName;
}
public Location getLocation() {
if (!this.fReadFromCache)
return this.fStreamReader.getLocation();
return this.fCachedLocation;
}
public QName getName() {
if (!this.fReadFromCache)
return this.fStreamReader.getName();
if (this.fCachedEventType == 1 || this.fCachedEventType == 2)
return this.fElementName;
throw new IllegalArgumentException("Illegal to call getName() when event type is " + this.fCachedEventType);
}
public NamespaceContext getNamespaceContext() {
if (!this.fReadFromCache)
return this.fStreamReader.getNamespaceContext();
return this.fCachedNamespaceContext;
}
public int getNamespaceCount() {
if (!this.fReadFromCache)
return this.fStreamReader.getNamespaceCount();
if (this.fCachedEventType == 1 || this.fCachedEventType == 2 || this.fCachedEventType == 13)
return this.fCachedNamespaceAttr.size();
throw new IllegalStateException("Current event state is " + this.fCachedEventType);
}
public String getNamespacePrefix(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getNamespacePrefix(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getName().getPrefix();
return null;
}
public String getNamespaceURI() {
if (!this.fReadFromCache)
return this.fStreamReader.getNamespaceURI();
if ((this.fCachedEventType == 1 || this.fCachedEventType == 2) && this.fElementName != null)
return this.fElementName.getNamespaceURI();
return null;
}
public String getNamespaceURI(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getNamespaceURI(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.getName().getNamespaceURI();
return null;
}
public String getNamespaceURI(String prefix) {
if (!this.fReadFromCache)
return this.fStreamReader.getNamespaceURI();
return this.fCachedNamespaceContext.getNamespaceURI(prefix);
}
public String getPIData() {
if (!this.fReadFromCache)
return this.fStreamReader.getPIData();
return this.fCachedPIData;
}
public String getPITarget() {
if (!this.fReadFromCache)
return this.fStreamReader.getPITarget();
return this.fCachedPITarget;
}
public String getPrefix() {
if (!this.fReadFromCache)
return this.fStreamReader.getPrefix();
if (this.fCachedEventType == 1 || this.fCachedEventType == 2)
return this.fElementName.getPrefix();
return null;
}
public Object getProperty(String name) throws IllegalArgumentException {
return this.fStreamReader.getProperty(name);
}
public String getText() {
if (!this.fReadFromCache)
return this.fStreamReader.getText();
return this.fCachedTextValue;
}
public char[] getTextCharacters() {
if (!this.fReadFromCache)
return this.fStreamReader.getTextCharacters();
if (this.fCachedTextValue != null)
return this.fCachedTextValue.toCharArray();
return null;
}
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException {
if (!this.fReadFromCache)
return this.fStreamReader.getTextCharacters(sourceStart, target, targetStart, length);
if (target == null)
throw new NullPointerException("target char array can't be null");
if (targetStart < 0 || length < 0 || sourceStart < 0 || targetStart >= target.length || targetStart + length > target.length)
throw new IndexOutOfBoundsException();
if (this.fCachedTextValue == null)
return 0;
int copiedLength = 0;
int available = this.fCachedTextValue.length() - sourceStart;
if (available < 0)
throw new IndexOutOfBoundsException("sourceStart is greater thannumber of characters associated with this event");
if (available < length) {
copiedLength = available;
} else {
copiedLength = length;
}
System.arraycopy(this.fCachedTextValue, sourceStart, target, targetStart, copiedLength);
return copiedLength;
}
public int getTextLength() {
if (!this.fReadFromCache)
return this.fStreamReader.getTextLength();
if (this.fCachedTextValue != null)
return this.fCachedTextValue.length();
return 0;
}
public int getTextStart() {
if (!this.fReadFromCache)
return this.fStreamReader.getTextStart();
return 0;
}
public String getVersion() {
if (!this.fReadFromCache)
return this.fStreamReader.getVersion();
return this.fCachedVersion;
}
public boolean hasName() {
if (!this.fReadFromCache)
return this.fStreamReader.hasName();
if (this.fCachedEventType == 1 || this.fCachedEventType == 2 || this.fCachedEventType == 9 || this.fCachedEventType == 3)
return true;
return false;
}
public boolean hasText() {
if (!this.fReadFromCache)
return this.fStreamReader.hasText();
if (this.fCachedTextValue != null)
return true;
return false;
}
public boolean isAttributeSpecified(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.isAttributeSpecified(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
return attr.isSpecified();
return false;
}
public boolean isCharacters() {
if (!this.fReadFromCache)
return this.fStreamReader.isCharacters();
return (this.fCachedEventType == 4);
}
public boolean isEndElement() {
if (!this.fReadFromCache)
return this.fStreamReader.isEndElement();
return (this.fCachedEventType == 2);
}
public boolean isStandalone() {
if (!this.fReadFromCache)
return this.fStreamReader.isStandalone();
return this.fCachedStandalone;
}
public boolean isStartElement() {
if (!this.fReadFromCache)
return this.fStreamReader.isStartElement();
return (this.fCachedEventType == 1);
}
public boolean isWhiteSpace() {
if (!this.fReadFromCache)
return this.fStreamReader.isWhiteSpace();
if (isCharacters() || this.fCachedEventType == 12) {
if (this.fCachedTextValue == null)
return false;
char[] ch = this.fCachedTextValue.toCharArray();
int start = 0;
int length = this.fCachedTextValue.length();
for (int i = start; i < length; i++) {
if (!XMLChar.isSpace(ch[i]))
return false;
}
return true;
}
return false;
}
public int next() throws XMLStreamException {
if (this.fReadNext) {
if (readNext())
this.fReadFromCache = false;
} else {
this.fReadNext = true;
this.fReadFromCache = false;
}
return this.fCurrentEventType;
}
public int nextTag() throws XMLStreamException {
if (this.fReadNext) {
if (readNextTag())
this.fReadFromCache = false;
} else {
this.fReadNext = true;
if (this.fCurrentEventType != 1 || this.fCurrentEventType != 2) {
this.fCurrentEventType = this.fStreamReader.nextTag();
this.fReadFromCache = false;
}
}
return this.fCurrentEventType;
}
public void require(int type, String namespaceURI, String localName) throws XMLStreamException {
if (!this.fReadFromCache) {
this.fStreamReader.require(type, namespaceURI, localName);
} else {
if (type != this.fCachedEventType)
throw new XMLStreamException("Event type " + XMLReaderImpl.getEventTypeString(type) + " specified did not match with current parser event");
if (namespaceURI != null && !namespaceURI.equals(getNamespaceURI()))
throw new XMLStreamException("Namespace URI " + namespaceURI + " specified did not match with current namespace URI");
if (localName != null && !localName.equals(getLocalName()))
throw new XMLStreamException("LocalName " + localName + " specified did not match with current local name");
}
}
public boolean standaloneSet() {
if (!this.fReadFromCache)
return this.fStreamReader.standaloneSet();
return this.fCachedStandalone;
}
public String getAttributeLocalName(int index) {
if (!this.fReadFromCache)
return this.fStreamReader.getAttributeLocalName(index);
AttributeImpl attr = getCachedAttribute(index);
if (attr != null)
attr.getName().getLocalPart();
return null;
}
private void cache() {
this.fReadFromCache = true;
this.fCachedEventType = this.fCurrentEventType;
clearCache();
this.fCachedLocation = this.fStreamReader.getLocation();
switch (this.fCurrentEventType) {
case 4:
case 5:
case 6:
case 12:
this.fCachedTextValue = this.fStreamReader.getText();
break;
case 11:
this.fCachedTextValue = this.fStreamReader.getText();
break;
case 2:
this.fElementName = this.fStreamReader.getName();
this.fHasName = this.fStreamReader.hasName();
this.fLocalName = this.fElementName.getLocalPart();
cacheNamespaceContext();
break;
case 9:
this.fLocalName = this.fStreamReader.getLocalName();
this.fCachedTextValue = this.fStreamReader.getText();
break;
case 3:
this.fCachedPIData = this.fStreamReader.getPIData();
this.fCachedPITarget = this.fStreamReader.getPITarget();
break;
case 7:
this.fCachedVersion = this.fStreamReader.getVersion();
this.fCachedEncoding = this.fStreamReader.getEncoding();
this.fCachedStandalone = this.fStreamReader.isStandalone();
this.fCachedCharEncoding = this.fStreamReader.getCharacterEncodingScheme();
break;
case 1:
try {
this.fElementName = this.fStreamReader.getName();
this.fHasName = this.fStreamReader.hasName();
this.fLocalName = this.fElementName.getLocalPart();
if (DEBUG) {
System.out.println("Name is " + this.fLocalName);
System.out.println("Name is " + this.fElementName);
}
cacheAttributes();
cacheNamespaceAttributes();
cacheNamespaceContext();
if (this.fStreamReader.hasText())
this.fCachedElementText = this.fStreamReader.getElementText();
} catch (Exception ex) {
System.err.println("Error occurred while trying to cache START_ELEMENT" + ex.getMessage());
}
break;
}
}
private boolean readNext() throws XMLStreamException {
while (this.fStreamReader.hasNext()) {
this.fStreamReader.next();
this.fHasMoreEvents = this.fStreamFilter.accept(this.fStreamReader);
if (this.fHasMoreEvents) {
this.fCurrentEventType = this.fStreamReader.getEventType();
return true;
}
}
return false;
}
private boolean readNextTag() throws XMLStreamException {
while (this.fStreamReader.hasNext()) {
this.fStreamReader.nextTag();
this.fHasMoreEvents = this.fStreamFilter.accept(this.fStreamReader);
if (this.fHasMoreEvents) {
this.fCurrentEventType = this.fStreamReader.getEventType();
return true;
}
}
return false;
}
private void cacheAttributes() {
int len = this.fStreamReader.getAttributeCount();
QName qname = null;
String prefix = null;
String localpart = null;
AttributeImpl attr = null;
this.fCachedAttributes.clear();
for (int i = 0; i < len; i++) {
qname = this.fStreamReader.getAttributeName(i);
prefix = qname.getPrefix();
localpart = qname.getLocalPart();
attr = new AttributeImpl();
attr.setName(qname);
attr.setAttributeType(this.fStreamReader.getAttributeType(i));
attr.setSpecified(this.fStreamReader.isAttributeSpecified(i));
attr.setValue(this.fStreamReader.getAttributeValue(i));
this.fCachedAttributes.add(attr);
}
}
protected void cacheNamespaceAttributes() {
int count = this.fStreamReader.getNamespaceCount();
String uri = null;
String prefix = null;
NamespaceImpl attr = null;
this.fCachedNamespaceAttr.clear();
for (int i = 0; i < count; i++) {
uri = this.fStreamReader.getNamespaceURI(i);
prefix = this.fStreamReader.getNamespacePrefix(i);
if (prefix == null)
prefix = "";
attr = new NamespaceImpl(prefix, uri);
this.fCachedNamespaceAttr.add(attr);
}
}
private void cacheNamespaceContext() {
NamespaceContextWrapper nc = (NamespaceContextWrapper)this.fStreamReader.getNamespaceContext();
NamespaceSupport ns = new NamespaceSupport(nc.getNamespaceContext());
this.fCachedNamespaceContext = new NamespaceContextWrapper(ns);
}
private AttributeImpl getCachedAttribute(int index) {
if (this.fCachedEventType == 1 || this.fCachedEventType == 10) {
if (index < this.fCachedAttributes.size())
return this.fCachedAttributes.get(index);
} else {
throw new IllegalStateException("Current event state is " + this.fCachedEventType);
}
return null;
}
private void clearCache() {
this.fCachedAttributes.clear();
this.fCachedNamespaceAttr.clear();
this.fCachedNamespaceContext = null;
this.fCachedElementText = null;
this.fCachedVersion = null;
this.fCachedEncoding = null;
this.fCachedLocation = null;
this.fCachedTextValue = null;
this.fCachedPITarget = null;
this.fCachedPIData = null;
this.fCachedCharEncoding = null;
this.fElementName = null;
this.fHasName = false;
this.fLocalName = null;
}
}

View file

@ -0,0 +1,205 @@
package com.sun.xml.stream;
import com.sun.xml.stream.xerces.xni.parser.XMLInputSource;
import java.io.InputStream;
import java.io.Reader;
import javax.xml.stream.EventFilter;
import javax.xml.stream.StreamFilter;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLReporter;
import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.util.XMLEventAllocator;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
public class ZephyrParserFactory extends XMLInputFactory {
protected static final String READER_IN_DEFINED_STATE = "http://java.sun.com/xml/stream/properties/reader-in-defined-state";
private PropertyManager fPropertyManager = new PropertyManager(1);
private static final boolean DEBUG = false;
private XMLReaderImpl fTempReader = null;
boolean fPropertyChanged = false;
boolean fReuseInstance = true;
boolean fEventReaderInstance = false;
void initEventReader() {
this.fEventReaderInstance = true;
this.fPropertyChanged = true;
}
public XMLEventReader createXMLEventReader(InputStream inputstream) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(createXMLStreamReader(inputstream));
}
public XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(createXMLStreamReader(reader));
}
public XMLEventReader createXMLEventReader(Source source) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(createXMLStreamReader(source));
}
public XMLEventReader createXMLEventReader(String systemId, InputStream inputstream) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(createXMLStreamReader(systemId, inputstream));
}
public XMLEventReader createXMLEventReader(InputStream stream, String encoding) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(createXMLStreamReader(stream, encoding));
}
public XMLEventReader createXMLEventReader(String systemId, Reader reader) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(createXMLStreamReader(systemId, reader));
}
public XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException {
initEventReader();
return new XMLEventReaderImpl(reader);
}
public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException {
return createXMLStreamReader(null, reader);
}
public XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException {
XMLInputSource inputSource = new XMLInputSource(null, systemId, null, reader, null);
return getXMLStreamReaderImpl(inputSource);
}
public XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException {
return new XMLReaderImpl(jaxpSourcetoXMLInputSource(source), getNewPropertyManager());
}
public XMLStreamReader createXMLStreamReader(InputStream inputStream) throws XMLStreamException {
return createXMLStreamReader(null, inputStream, null);
}
public XMLStreamReader createXMLStreamReader(String systemId, InputStream inputStream) throws XMLStreamException {
return createXMLStreamReader(systemId, inputStream, null);
}
public XMLStreamReader createXMLStreamReader(InputStream inputStream, String encoding) throws XMLStreamException {
return createXMLStreamReader(null, inputStream, encoding);
}
public XMLStreamReader createXMLStreamReader(String systemId, InputStream inputStream, String encoding) throws XMLStreamException {
XMLInputSource inputSource = new XMLInputSource(null, systemId, null, inputStream, encoding);
return getXMLStreamReaderImpl(inputSource);
}
public XMLEventAllocator getEventAllocator() {
return (XMLEventAllocator)getProperty("javax.xml.stream.allocator");
}
public XMLReporter getXMLReporter() {
return (XMLReporter)this.fPropertyManager.getProperty("javax.xml.stream.reporter");
}
public XMLResolver getXMLResolver() {
Object object = this.fPropertyManager.getProperty("javax.xml.stream.resolver");
return (XMLResolver)object;
}
public void setXMLReporter(XMLReporter xmlreporter) {
this.fPropertyManager.setProperty("javax.xml.stream.reporter", xmlreporter);
}
public void setXMLResolver(XMLResolver xmlresolver) {
this.fPropertyManager.setProperty("javax.xml.stream.resolver", xmlresolver);
}
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
return new EventFilterSupport(reader, filter);
}
public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException {
if (reader != null && filter != null)
return new XMLStreamFilterImpl(reader, filter);
return null;
}
public Object getProperty(String name) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Property not supported");
if (this.fPropertyManager.containsProperty(name))
return this.fPropertyManager.getProperty(name);
throw new IllegalArgumentException("Property not supported");
}
public boolean isPropertySupported(String name) {
if (name == null)
return false;
return this.fPropertyManager.containsProperty(name);
}
public void setEventAllocator(XMLEventAllocator allocator) {
this.fPropertyManager.setProperty("javax.xml.stream.allocator", allocator);
}
public void setProperty(String name, Object value) throws IllegalArgumentException {
if (name == null || value == null || !this.fPropertyManager.containsProperty(name))
throw new IllegalArgumentException("Property " + name + " is not supported");
if (name == "reuse-instance" || name.equals("reuse-instance")) {
this.fReuseInstance = (Boolean)value;
} else {
this.fPropertyChanged = true;
}
this.fPropertyManager.setProperty(name, value);
}
XMLStreamReader getXMLStreamReaderImpl(XMLInputSource inputSource) throws XMLStreamException {
if (this.fTempReader == null) {
this.fPropertyChanged = false;
return this.fTempReader = new XMLReaderImpl(inputSource, getNewPropertyManager());
}
if (this.fReuseInstance && this.fTempReader.canReuse() && !this.fPropertyChanged) {
this.fTempReader.reset();
this.fTempReader.setInputSource(inputSource);
this.fPropertyChanged = false;
return this.fTempReader;
}
this.fPropertyChanged = false;
return this.fTempReader = new XMLReaderImpl(inputSource, getNewPropertyManager());
}
PropertyManager getNewPropertyManager() {
PropertyManager pm = new PropertyManager(this.fPropertyManager);
if (this.fEventReaderInstance) {
pm.setProperty("http://java.sun.com/xml/stream/properties/reader-in-defined-state", new Boolean(false));
this.fEventReaderInstance = false;
this.fPropertyChanged = true;
}
return pm;
}
XMLInputSource jaxpSourcetoXMLInputSource(Source source) {
if (source instanceof StreamSource) {
StreamSource stSource = (StreamSource)source;
String systemId = stSource.getSystemId();
String publicId = stSource.getPublicId();
InputStream istream = stSource.getInputStream();
Reader reader = stSource.getReader();
if (istream != null)
return new XMLInputSource(publicId, systemId, null, istream, null);
if (reader != null)
return new XMLInputSource(publicId, systemId, null, reader, null);
return new XMLInputSource(publicId, systemId, null);
}
if (source instanceof Source)
return new XMLInputSource(null, source.getSystemId(), null);
throw new UnsupportedOperationException(source.getClass().getName() + " type is not supported");
}
}

View file

@ -0,0 +1,105 @@
package com.sun.xml.stream;
import com.sun.xml.stream.writers.XMLDOMWriterImpl;
import com.sun.xml.stream.writers.XMLEventWriterImpl;
import com.sun.xml.stream.writers.XMLStreamWriterImpl;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamResult;
public class ZephyrWriterFactory extends XMLOutputFactory {
private PropertyManager fPropertyManager = null;
public ZephyrWriterFactory() {
this.fPropertyManager = new PropertyManager(2);
}
public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
return new XMLEventWriterImpl(createXMLStreamWriter(result));
}
public XMLEventWriter createXMLEventWriter(Writer writer) throws XMLStreamException {
return new XMLEventWriterImpl(createXMLStreamWriter(writer));
}
public XMLEventWriter createXMLEventWriter(OutputStream outputStream) throws XMLStreamException {
return new XMLEventWriterImpl(createXMLStreamWriter(outputStream));
}
public XMLEventWriter createXMLEventWriter(OutputStream outputStream, String encoding) throws XMLStreamException {
return new XMLEventWriterImpl(createXMLStreamWriter(outputStream, encoding));
}
public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
if (result instanceof StreamResult) {
StreamResult streamResult = (StreamResult)result;
if (streamResult.getWriter() != null)
return new XMLStreamWriterImpl(streamResult.getWriter(), new PropertyManager(this.fPropertyManager));
if (streamResult.getOutputStream() != null)
return new XMLStreamWriterImpl(streamResult.getOutputStream(), new PropertyManager(this.fPropertyManager));
if (streamResult.getSystemId() != null)
try {
FileWriter writer = new FileWriter(new File(streamResult.getSystemId()));
return new XMLStreamWriterImpl(writer, new PropertyManager(this.fPropertyManager));
} catch (IOException ie) {
throw new XMLStreamException(ie);
}
} else {
if (result instanceof DOMResult)
return new XMLDOMWriterImpl((DOMResult)result);
if (result instanceof Result)
try {
FileWriter writer = new FileWriter(new File(result.getSystemId()));
return new XMLStreamWriterImpl(writer, new PropertyManager(this.fPropertyManager));
} catch (IOException ie) {
throw new XMLStreamException(ie);
}
}
throw new UnsupportedOperationException();
}
public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
return new XMLStreamWriterImpl(writer, new PropertyManager(this.fPropertyManager));
}
public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream) throws XMLStreamException {
return new XMLStreamWriterImpl(outputStream, new PropertyManager(this.fPropertyManager));
}
public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, String encoding) throws XMLStreamException {
try {
return new XMLStreamWriterImpl(outputStream, encoding, new PropertyManager(this.fPropertyManager));
} catch (Exception ex) {
throw new XMLStreamException(ex);
}
}
public Object getProperty(String name) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Property not supported");
if (this.fPropertyManager.containsProperty(name))
return this.fPropertyManager.getProperty(name);
throw new IllegalArgumentException("Property not supported");
}
public boolean isPropertySupported(String name) {
if (name == null)
return false;
return this.fPropertyManager.containsProperty(name);
}
public void setProperty(String name, Object value) throws IllegalArgumentException {
if (name == null || value == null || !this.fPropertyManager.containsProperty(name))
throw new IllegalArgumentException("Property " + name + "is not supported");
this.fPropertyManager.setProperty(name, value);
}
}

View file

@ -0,0 +1,277 @@
package com.sun.xml.stream.dtd;
import com.sun.xml.stream.dtd.nonvalidating.DTDGrammar;
import com.sun.xml.stream.dtd.nonvalidating.XMLAttributeDecl;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.XMLChar;
import com.sun.xml.stream.xerces.util.XMLSymbols;
import com.sun.xml.stream.xerces.xni.Augmentations;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLAttributes;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
public class DTDGrammarUtil {
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
private static final boolean DEBUG_ATTRIBUTES = false;
private static final boolean DEBUG_ELEMENT_CHILDREN = false;
protected DTDGrammar fDTDGrammar = null;
protected boolean fNamespaces;
protected SymbolTable fSymbolTable = null;
private int fCurrentElementIndex = -1;
private int fCurrentContentSpecType = -1;
private boolean fInCDATASection = false;
private boolean[] fElementContentState = new boolean[8];
private int fElementDepth = -1;
private boolean fInElementContent = false;
private XMLAttributeDecl fTempAttDecl = new XMLAttributeDecl();
private QName fTempQName = new QName();
private StringBuffer fBuffer = new StringBuffer();
public DTDGrammarUtil(SymbolTable symbolTable) {
this.fSymbolTable = symbolTable;
}
public DTDGrammarUtil(DTDGrammar grammar, SymbolTable symbolTable) {
this.fDTDGrammar = grammar;
this.fSymbolTable = symbolTable;
}
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
this.fDTDGrammar = null;
this.fInCDATASection = false;
this.fInElementContent = false;
this.fCurrentElementIndex = -1;
this.fCurrentContentSpecType = -1;
try {
this.fNamespaces = componentManager.getFeature("http://xml.org/sax/features/namespaces");
} catch (XMLConfigurationException e) {
this.fNamespaces = true;
}
this.fSymbolTable = (SymbolTable)componentManager.getProperty("http://apache.org/xml/properties/internal/symbol-table");
this.fElementDepth = -1;
}
public void startElement(QName element) throws XNIException {
handleStartElement(element);
}
public void endElement(QName element) throws XNIException {
handleEndElement(element);
}
public void startCDATA(Augmentations augs) throws XNIException {
this.fInCDATASection = true;
}
public void endCDATA(Augmentations augs) throws XNIException {
this.fInCDATASection = false;
}
public void addDTDDefaultAttrs(QName elementName, XMLAttributes attributes) throws XNIException {
int elementIndex = this.fDTDGrammar.getElementDeclIndex(elementName);
if (elementIndex == -1 || this.fDTDGrammar == null)
return;
int attlistIndex = this.fDTDGrammar.getFirstAttributeDeclIndex(elementIndex);
while (attlistIndex != -1) {
this.fDTDGrammar.getAttributeDecl(attlistIndex, this.fTempAttDecl);
String attPrefix = this.fTempAttDecl.name.prefix;
String attLocalpart = this.fTempAttDecl.name.localpart;
String attRawName = this.fTempAttDecl.name.rawname;
String attType = getAttributeTypeName(this.fTempAttDecl);
int attDefaultType = this.fTempAttDecl.simpleType.defaultType;
String attValue = null;
if (this.fTempAttDecl.simpleType.defaultValue != null)
attValue = this.fTempAttDecl.simpleType.defaultValue;
boolean specified = false;
boolean required = (attDefaultType == 2);
boolean cdata = (attType == XMLSymbols.fCDATASymbol);
if (!cdata || required || attValue != null) {
int j = attributes.getLength();
for (int k = 0; k < j; k++) {
if (attributes.getQName(k) == attRawName) {
specified = true;
break;
}
}
}
if (!specified &&
attValue != null) {
if (this.fNamespaces) {
int index = attRawName.indexOf(':');
if (index != -1) {
attPrefix = attRawName.substring(0, index);
attPrefix = this.fSymbolTable.addSymbol(attPrefix);
attLocalpart = attRawName.substring(index + 1);
attLocalpart = this.fSymbolTable.addSymbol(attLocalpart);
}
}
this.fTempQName.setValues(attPrefix, attLocalpart, attRawName, this.fTempAttDecl.name.uri);
int newAttr = attributes.addAttribute(this.fTempQName, attType, attValue);
}
attlistIndex = this.fDTDGrammar.getNextAttributeDeclIndex(attlistIndex);
}
int attrCount = attributes.getLength();
for (int i = 0; i < attrCount; i++) {
String attrRawName = attributes.getQName(i);
boolean declared = false;
int attDefIndex = -1;
int position = this.fDTDGrammar.getFirstAttributeDeclIndex(elementIndex);
while (position != -1) {
this.fDTDGrammar.getAttributeDecl(position, this.fTempAttDecl);
if (this.fTempAttDecl.name.rawname == attrRawName) {
attDefIndex = position;
declared = true;
break;
}
position = this.fDTDGrammar.getNextAttributeDeclIndex(position);
}
if (declared) {
String type = getAttributeTypeName(this.fTempAttDecl);
attributes.setType(i, type);
boolean changedByNormalization = false;
String oldValue = attributes.getValue(i);
String attrValue = oldValue;
if (attributes.isSpecified(i) && type != XMLSymbols.fCDATASymbol) {
changedByNormalization = normalizeAttrValue(attributes, i);
attrValue = attributes.getValue(i);
}
}
}
}
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
boolean leadingSpace = true;
boolean spaceStart = false;
boolean readingNonSpace = false;
int count = 0;
int eaten = 0;
String attrValue = attributes.getValue(index);
char[] attValue = new char[attrValue.length()];
this.fBuffer.setLength(0);
attrValue.getChars(0, attrValue.length(), attValue, 0);
for (int i = 0; i < attValue.length; i++) {
if (attValue[i] == ' ') {
if (readingNonSpace) {
spaceStart = true;
readingNonSpace = false;
}
if (spaceStart && !leadingSpace) {
spaceStart = false;
this.fBuffer.append(attValue[i]);
count++;
} else if (leadingSpace || !spaceStart) {
eaten++;
}
} else {
readingNonSpace = true;
spaceStart = false;
leadingSpace = false;
this.fBuffer.append(attValue[i]);
count++;
}
}
if (count > 0 && this.fBuffer.charAt(count - 1) == ' ')
this.fBuffer.setLength(count - 1);
String newValue = this.fBuffer.toString();
attributes.setValue(index, newValue);
return !attrValue.equals(newValue);
}
private String getAttributeTypeName(XMLAttributeDecl attrDecl) {
StringBuffer buffer;
int i;
switch (attrDecl.simpleType.type) {
case 1:
return attrDecl.simpleType.list ? XMLSymbols.fENTITIESSymbol : XMLSymbols.fENTITYSymbol;
case 2:
buffer = new StringBuffer();
buffer.append('(');
for (i = 0; i < attrDecl.simpleType.enumeration.length; i++) {
if (i > 0)
buffer.append("|");
buffer.append(attrDecl.simpleType.enumeration[i]);
}
buffer.append(')');
return this.fSymbolTable.addSymbol(buffer.toString());
case 3:
return XMLSymbols.fIDSymbol;
case 4:
return attrDecl.simpleType.list ? XMLSymbols.fIDREFSSymbol : XMLSymbols.fIDREFSymbol;
case 5:
return attrDecl.simpleType.list ? XMLSymbols.fNMTOKENSSymbol : XMLSymbols.fNMTOKENSymbol;
case 6:
return XMLSymbols.fNOTATIONSymbol;
}
return XMLSymbols.fCDATASymbol;
}
private void ensureStackCapacity(int newElementDepth) {
if (newElementDepth == this.fElementContentState.length) {
boolean[] newStack = new boolean[newElementDepth * 2];
System.arraycopy(this.fElementContentState, 0, newStack, 0, newElementDepth);
this.fElementContentState = newStack;
}
}
protected void handleStartElement(QName element) throws XNIException {
if (this.fDTDGrammar == null) {
this.fCurrentElementIndex = -1;
this.fCurrentContentSpecType = -1;
this.fInElementContent = false;
return;
}
this.fCurrentElementIndex = this.fDTDGrammar.getElementDeclIndex(element);
this.fCurrentContentSpecType = this.fDTDGrammar.getContentSpecType(this.fCurrentElementIndex);
this.fInElementContent = (this.fCurrentContentSpecType == 3);
this.fElementDepth++;
ensureStackCapacity(this.fElementDepth);
this.fElementContentState[this.fElementDepth] = this.fInElementContent;
}
protected void handleEndElement(QName element) throws XNIException {
this.fElementDepth--;
if (this.fElementDepth < -1)
throw new RuntimeException("FWK008 Element stack underflow");
if (this.fElementDepth < 0) {
this.fCurrentElementIndex = -1;
this.fCurrentContentSpecType = -1;
this.fInElementContent = false;
return;
}
this.fInElementContent = this.fElementContentState[this.fElementDepth];
}
public boolean isInElementContent() {
return this.fInElementContent;
}
public boolean isIgnorableWhiteSpace(XMLString text) {
if (isInElementContent()) {
for (int i = text.offset; i < text.offset + text.length; i++) {
if (!XMLChar.isSpace(text.ch[i]))
return false;
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,611 @@
package com.sun.xml.stream.dtd.nonvalidating;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.util.XMLSymbols;
import com.sun.xml.stream.xerces.xni.Augmentations;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLLocator;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import com.sun.xml.stream.xerces.xni.XMLString;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLDTDContentModelSource;
import com.sun.xml.stream.xerces.xni.parser.XMLDTDSource;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
public class DTDGrammar {
public static final int TOP_LEVEL_SCOPE = -1;
private static final int CHUNK_SHIFT = 8;
private static final int CHUNK_SIZE = 256;
private static final int CHUNK_MASK = 255;
private static final int INITIAL_CHUNK_COUNT = 4;
private static final short LIST_FLAG = 128;
private static final short LIST_MASK = -129;
private static final boolean DEBUG = false;
protected XMLDTDSource fDTDSource = null;
protected XMLDTDContentModelSource fDTDContentModelSource = null;
protected int fCurrentElementIndex;
protected int fCurrentAttributeIndex;
protected boolean fReadingExternalDTD = false;
private SymbolTable fSymbolTable;
private ArrayList notationDecls = new ArrayList();
private int fElementDeclCount = 0;
private QName[][] fElementDeclName = new QName[4][];
private short[][] fElementDeclType = new short[4][];
private int[][] fElementDeclFirstAttributeDeclIndex = new int[4][];
private int[][] fElementDeclLastAttributeDeclIndex = new int[4][];
private int fAttributeDeclCount = 0;
private QName[][] fAttributeDeclName = new QName[4][];
private boolean fIsImmutable = false;
private short[][] fAttributeDeclType = new short[4][];
private String[][][] fAttributeDeclEnumeration = new String[4][][];
private short[][] fAttributeDeclDefaultType = new short[4][];
private String[][] fAttributeDeclDefaultValue = new String[4][];
private String[][] fAttributeDeclNonNormalizedDefaultValue = new String[4][];
private int[][] fAttributeDeclNextAttributeDeclIndex = new int[4][];
private QNameHashtable fElementIndexMap = new QNameHashtable();
private QName fQName = new QName();
private QName fQName2 = new QName();
protected XMLAttributeDecl fAttributeDecl = new XMLAttributeDecl();
private int fLeafCount = 0;
private int fEpsilonIndex = -1;
private XMLElementDecl fElementDecl = new XMLElementDecl();
private XMLSimpleType fSimpleType = new XMLSimpleType();
Hashtable fElementDeclTab = new Hashtable();
private short[] fOpStack = null;
private int[] fNodeIndexStack = null;
private int[] fPrevNodeIndexStack = null;
private int fDepth = 0;
int valueIndex = -1;
int prevNodeIndex = -1;
int nodeIndex = -1;
public DTDGrammar(SymbolTable symbolTable) {
this.fSymbolTable = symbolTable;
}
public int getAttributeDeclIndex(int elementDeclIndex, String attributeDeclName) {
if (elementDeclIndex == -1)
return -1;
int attDefIndex = getFirstAttributeDeclIndex(elementDeclIndex);
while (attDefIndex != -1) {
getAttributeDecl(attDefIndex, this.fAttributeDecl);
if (this.fAttributeDecl.name.rawname == attributeDeclName || attributeDeclName.equals(this.fAttributeDecl.name.rawname))
return attDefIndex;
attDefIndex = getNextAttributeDeclIndex(attDefIndex);
}
return -1;
}
public void startDTD(XMLLocator locator, Augmentations augs) throws XNIException {
this.fOpStack = null;
this.fNodeIndexStack = null;
this.fPrevNodeIndexStack = null;
}
public void elementDecl(String name, String contentModel, Augmentations augs) throws XNIException {
XMLElementDecl tmpElementDecl = (XMLElementDecl)this.fElementDeclTab.get(name);
if (tmpElementDecl != null) {
if (tmpElementDecl.type == -1) {
this.fCurrentElementIndex = getElementDeclIndex(name);
} else {
return;
}
} else {
this.fCurrentElementIndex = createElementDecl();
}
XMLElementDecl elementDecl = new XMLElementDecl();
QName elementName = new QName(null, name, name, null);
elementDecl.name.setValues(elementName);
elementDecl.scope = -1;
if (contentModel.equals("EMPTY")) {
elementDecl.type = 1;
} else if (contentModel.equals("ANY")) {
elementDecl.type = 0;
} else if (contentModel.startsWith("(")) {
if (contentModel.indexOf("#PCDATA") > 0) {
elementDecl.type = 2;
} else {
elementDecl.type = 3;
}
}
this.fElementDeclTab.put(name, elementDecl);
this.fElementDecl = elementDecl;
setElementDecl(this.fCurrentElementIndex, this.fElementDecl);
int chunk = this.fCurrentElementIndex >> 8;
int index = this.fCurrentElementIndex & 0xFF;
ensureElementDeclCapacity(chunk);
}
public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {
if (type != XMLSymbols.fCDATASymbol && defaultValue != null)
normalizeDefaultAttrValue(defaultValue);
if (!this.fElementDeclTab.containsKey(elementName)) {
this.fCurrentElementIndex = createElementDecl();
XMLElementDecl elementDecl = new XMLElementDecl();
elementDecl.name.setValues(null, elementName, elementName, null);
elementDecl.scope = -1;
this.fElementDeclTab.put(elementName, elementDecl);
setElementDecl(this.fCurrentElementIndex, elementDecl);
}
int elementIndex = getElementDeclIndex(elementName);
if (getAttributeDeclIndex(elementIndex, attributeName) != -1)
return;
this.fCurrentAttributeIndex = createAttributeDecl();
this.fSimpleType.clear();
if (defaultType != null)
if (defaultType.equals("#FIXED")) {
this.fSimpleType.defaultType = 1;
} else if (defaultType.equals("#IMPLIED")) {
this.fSimpleType.defaultType = 0;
} else if (defaultType.equals("#REQUIRED")) {
this.fSimpleType.defaultType = 2;
}
this.fSimpleType.defaultValue = (defaultValue != null) ? defaultValue.toString() : null;
this.fSimpleType.nonNormalizedDefaultValue = (nonNormalizedDefaultValue != null) ? nonNormalizedDefaultValue.toString() : null;
this.fSimpleType.enumeration = enumeration;
if (type.equals("CDATA")) {
this.fSimpleType.type = 0;
} else if (type.equals("ID")) {
this.fSimpleType.type = 3;
} else if (type.startsWith("IDREF")) {
this.fSimpleType.type = 4;
if (type.indexOf("S") > 0)
this.fSimpleType.list = true;
} else if (type.equals("ENTITIES")) {
this.fSimpleType.type = 1;
this.fSimpleType.list = true;
} else if (type.equals("ENTITY")) {
this.fSimpleType.type = 1;
} else if (type.equals("NMTOKENS")) {
this.fSimpleType.type = 5;
this.fSimpleType.list = true;
} else if (type.equals("NMTOKEN")) {
this.fSimpleType.type = 5;
} else if (type.startsWith("NOTATION")) {
this.fSimpleType.type = 6;
} else if (type.startsWith("ENUMERATION")) {
this.fSimpleType.type = 2;
} else {
System.err.println("!!! unknown attribute type " + type);
}
this.fQName.setValues(null, attributeName, attributeName, null);
this.fAttributeDecl.setValues(this.fQName, this.fSimpleType, false);
setAttributeDecl(elementIndex, this.fCurrentAttributeIndex, this.fAttributeDecl);
int chunk = this.fCurrentAttributeIndex >> 8;
int index = this.fCurrentAttributeIndex & 0xFF;
ensureAttributeDeclCapacity(chunk);
}
public SymbolTable getSymbolTable() {
return this.fSymbolTable;
}
public int getFirstElementDeclIndex() {
return (this.fElementDeclCount >= 0) ? 0 : -1;
}
public int getNextElementDeclIndex(int elementDeclIndex) {
return (elementDeclIndex < this.fElementDeclCount - 1) ? (elementDeclIndex + 1) : -1;
}
public int getElementDeclIndex(String elementDeclName) {
int mapping = this.fElementIndexMap.get(elementDeclName);
return mapping;
}
public int getElementDeclIndex(QName elementDeclQName) {
return getElementDeclIndex(elementDeclQName.rawname);
}
public short getContentSpecType(int elementIndex) {
if (elementIndex < 0 || elementIndex >= this.fElementDeclCount)
return -1;
int chunk = elementIndex >> 8;
int index = elementIndex & 0xFF;
if (this.fElementDeclType[chunk][index] == -1)
return -1;
return (short)(this.fElementDeclType[chunk][index] & 0xFFFFFF7F);
}
public boolean getElementDecl(int elementDeclIndex, XMLElementDecl elementDecl) {
if (elementDeclIndex < 0 || elementDeclIndex >= this.fElementDeclCount)
return false;
int chunk = elementDeclIndex >> 8;
int index = elementDeclIndex & 0xFF;
elementDecl.name.setValues(this.fElementDeclName[chunk][index]);
if (this.fElementDeclType[chunk][index] == -1) {
elementDecl.type = -1;
elementDecl.simpleType.list = false;
} else {
elementDecl.type = (short)(this.fElementDeclType[chunk][index] & 0xFFFFFF7F);
elementDecl.simpleType.list = ((this.fElementDeclType[chunk][index] & 0x80) != 0);
}
elementDecl.simpleType.defaultType = -1;
elementDecl.simpleType.defaultValue = null;
return true;
}
public int getFirstAttributeDeclIndex(int elementDeclIndex) {
int chunk = elementDeclIndex >> 8;
int index = elementDeclIndex & 0xFF;
return this.fElementDeclFirstAttributeDeclIndex[chunk][index];
}
public int getNextAttributeDeclIndex(int attributeDeclIndex) {
int chunk = attributeDeclIndex >> 8;
int index = attributeDeclIndex & 0xFF;
return this.fAttributeDeclNextAttributeDeclIndex[chunk][index];
}
public boolean getAttributeDecl(int attributeDeclIndex, XMLAttributeDecl attributeDecl) {
short attributeType;
boolean isList;
if (attributeDeclIndex < 0 || attributeDeclIndex >= this.fAttributeDeclCount)
return false;
int chunk = attributeDeclIndex >> 8;
int index = attributeDeclIndex & 0xFF;
attributeDecl.name.setValues(this.fAttributeDeclName[chunk][index]);
if (this.fAttributeDeclType[chunk][index] == -1) {
attributeType = -1;
isList = false;
} else {
attributeType = (short)(this.fAttributeDeclType[chunk][index] & 0xFFFFFF7F);
isList = ((this.fAttributeDeclType[chunk][index] & 0x80) != 0);
}
attributeDecl.simpleType.setValues(attributeType, (this.fAttributeDeclName[chunk][index]).localpart, this.fAttributeDeclEnumeration[chunk][index], isList, this.fAttributeDeclDefaultType[chunk][index], this.fAttributeDeclDefaultValue[chunk][index], this.fAttributeDeclNonNormalizedDefaultValue[chunk][index]);
return true;
}
public boolean isCDATAAttribute(QName elName, QName atName) {
int elDeclIdx = getElementDeclIndex(elName);
int atDeclIdx = getAttributeDeclIndex(elDeclIdx, atName.rawname);
if (getAttributeDecl(elDeclIdx, this.fAttributeDecl) && this.fAttributeDecl.simpleType.type != 0)
return false;
return true;
}
public void printElements() {
int elementDeclIndex = 0;
XMLElementDecl elementDecl = new XMLElementDecl();
while (getElementDecl(elementDeclIndex++, elementDecl))
System.out.println("element decl: " + elementDecl.name + ", " + elementDecl.name.rawname);
}
public void printAttributes(int elementDeclIndex) {
int attributeDeclIndex = getFirstAttributeDeclIndex(elementDeclIndex);
System.out.print(elementDeclIndex);
System.out.print(" [");
while (attributeDeclIndex != -1) {
System.out.print(' ');
System.out.print(attributeDeclIndex);
printAttribute(attributeDeclIndex);
attributeDeclIndex = getNextAttributeDeclIndex(attributeDeclIndex);
if (attributeDeclIndex != -1)
System.out.print(",");
}
System.out.println(" ]");
}
protected int createElementDecl() {
int chunk = this.fElementDeclCount >> 8;
int index = this.fElementDeclCount & 0xFF;
ensureElementDeclCapacity(chunk);
this.fElementDeclName[chunk][index] = new QName();
this.fElementDeclType[chunk][index] = -1;
this.fElementDeclFirstAttributeDeclIndex[chunk][index] = -1;
this.fElementDeclLastAttributeDeclIndex[chunk][index] = -1;
return this.fElementDeclCount++;
}
protected void setElementDecl(int elementDeclIndex, XMLElementDecl elementDecl) {
if (elementDeclIndex < 0 || elementDeclIndex >= this.fElementDeclCount)
return;
int chunk = elementDeclIndex >> 8;
int index = elementDeclIndex & 0xFF;
int scope = elementDecl.scope;
this.fElementDeclName[chunk][index].setValues(elementDecl.name);
this.fElementDeclType[chunk][index] = elementDecl.type;
if (elementDecl.simpleType.list == true)
this.fElementDeclType[chunk][index] = (short)(this.fElementDeclType[chunk][index] | 0x80);
this.fElementIndexMap.put(elementDecl.name.rawname, elementDeclIndex);
}
protected void setFirstAttributeDeclIndex(int elementDeclIndex, int newFirstAttrIndex) {
if (elementDeclIndex < 0 || elementDeclIndex >= this.fElementDeclCount)
return;
int chunk = elementDeclIndex >> 8;
int index = elementDeclIndex & 0xFF;
this.fElementDeclFirstAttributeDeclIndex[chunk][index] = newFirstAttrIndex;
}
protected int createAttributeDecl() {
int chunk = this.fAttributeDeclCount >> 8;
int index = this.fAttributeDeclCount & 0xFF;
ensureAttributeDeclCapacity(chunk);
this.fAttributeDeclName[chunk][index] = new QName();
this.fAttributeDeclType[chunk][index] = -1;
this.fAttributeDeclEnumeration[chunk][index] = null;
this.fAttributeDeclDefaultType[chunk][index] = 0;
this.fAttributeDeclDefaultValue[chunk][index] = null;
this.fAttributeDeclNonNormalizedDefaultValue[chunk][index] = null;
this.fAttributeDeclNextAttributeDeclIndex[chunk][index] = -1;
return this.fAttributeDeclCount++;
}
protected void setAttributeDecl(int elementDeclIndex, int attributeDeclIndex, XMLAttributeDecl attributeDecl) {
int attrChunk = attributeDeclIndex >> 8;
int attrIndex = attributeDeclIndex & 0xFF;
this.fAttributeDeclName[attrChunk][attrIndex].setValues(attributeDecl.name);
this.fAttributeDeclType[attrChunk][attrIndex] = attributeDecl.simpleType.type;
if (attributeDecl.simpleType.list)
this.fAttributeDeclType[attrChunk][attrIndex] = (short)(this.fAttributeDeclType[attrChunk][attrIndex] | 0x80);
this.fAttributeDeclEnumeration[attrChunk][attrIndex] = attributeDecl.simpleType.enumeration;
this.fAttributeDeclDefaultType[attrChunk][attrIndex] = attributeDecl.simpleType.defaultType;
this.fAttributeDeclDefaultValue[attrChunk][attrIndex] = attributeDecl.simpleType.defaultValue;
this.fAttributeDeclNonNormalizedDefaultValue[attrChunk][attrIndex] = attributeDecl.simpleType.nonNormalizedDefaultValue;
int elemChunk = elementDeclIndex >> 8;
int elemIndex = elementDeclIndex & 0xFF;
int index = this.fElementDeclFirstAttributeDeclIndex[elemChunk][elemIndex];
while (index != -1 &&
index != attributeDeclIndex) {
attrChunk = index >> 8;
attrIndex = index & 0xFF;
index = this.fAttributeDeclNextAttributeDeclIndex[attrChunk][attrIndex];
}
if (index == -1) {
if (this.fElementDeclFirstAttributeDeclIndex[elemChunk][elemIndex] == -1) {
this.fElementDeclFirstAttributeDeclIndex[elemChunk][elemIndex] = attributeDeclIndex;
} else {
index = this.fElementDeclLastAttributeDeclIndex[elemChunk][elemIndex];
attrChunk = index >> 8;
attrIndex = index & 0xFF;
this.fAttributeDeclNextAttributeDeclIndex[attrChunk][attrIndex] = attributeDeclIndex;
}
this.fElementDeclLastAttributeDeclIndex[elemChunk][elemIndex] = attributeDeclIndex;
}
}
public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException {
XMLNotationDecl notationDecl = new XMLNotationDecl();
notationDecl.setValues(name, identifier.getPublicId(), identifier.getLiteralSystemId(), identifier.getBaseSystemId());
this.notationDecls.add(notationDecl);
}
public List getNotationDecls() {
return this.notationDecls;
}
private void printAttribute(int attributeDeclIndex) {
XMLAttributeDecl attributeDecl = new XMLAttributeDecl();
if (getAttributeDecl(attributeDeclIndex, attributeDecl)) {
System.out.print(" { ");
System.out.print(attributeDecl.name.localpart);
System.out.print(" }");
}
}
private void ensureElementDeclCapacity(int chunk) {
if (chunk >= this.fElementDeclName.length) {
this.fElementDeclName = resize(this.fElementDeclName, this.fElementDeclName.length * 2);
this.fElementDeclType = resize(this.fElementDeclType, this.fElementDeclType.length * 2);
this.fElementDeclFirstAttributeDeclIndex = resize(this.fElementDeclFirstAttributeDeclIndex, this.fElementDeclFirstAttributeDeclIndex.length * 2);
this.fElementDeclLastAttributeDeclIndex = resize(this.fElementDeclLastAttributeDeclIndex, this.fElementDeclLastAttributeDeclIndex.length * 2);
} else if (this.fElementDeclName[chunk] != null) {
return;
}
this.fElementDeclName[chunk] = new QName[256];
this.fElementDeclType[chunk] = new short[256];
this.fElementDeclFirstAttributeDeclIndex[chunk] = new int[256];
this.fElementDeclLastAttributeDeclIndex[chunk] = new int[256];
}
private void ensureAttributeDeclCapacity(int chunk) {
if (chunk >= this.fAttributeDeclName.length) {
this.fAttributeDeclName = resize(this.fAttributeDeclName, this.fAttributeDeclName.length * 2);
this.fAttributeDeclType = resize(this.fAttributeDeclType, this.fAttributeDeclType.length * 2);
this.fAttributeDeclEnumeration = resize(this.fAttributeDeclEnumeration, this.fAttributeDeclEnumeration.length * 2);
this.fAttributeDeclDefaultType = resize(this.fAttributeDeclDefaultType, this.fAttributeDeclDefaultType.length * 2);
this.fAttributeDeclDefaultValue = resize(this.fAttributeDeclDefaultValue, this.fAttributeDeclDefaultValue.length * 2);
this.fAttributeDeclNonNormalizedDefaultValue = resize(this.fAttributeDeclNonNormalizedDefaultValue, this.fAttributeDeclNonNormalizedDefaultValue.length * 2);
this.fAttributeDeclNextAttributeDeclIndex = resize(this.fAttributeDeclNextAttributeDeclIndex, this.fAttributeDeclNextAttributeDeclIndex.length * 2);
} else if (this.fAttributeDeclName[chunk] != null) {
return;
}
this.fAttributeDeclName[chunk] = new QName[256];
this.fAttributeDeclType[chunk] = new short[256];
this.fAttributeDeclEnumeration[chunk] = new String[256][];
this.fAttributeDeclDefaultType[chunk] = new short[256];
this.fAttributeDeclDefaultValue[chunk] = new String[256];
this.fAttributeDeclNonNormalizedDefaultValue[chunk] = new String[256];
this.fAttributeDeclNextAttributeDeclIndex[chunk] = new int[256];
}
private static byte[][] resize(byte[][] array, int newsize) {
byte[][] newarray = new byte[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
private static short[][] resize(short[][] array, int newsize) {
short[][] newarray = new short[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
private static int[][] resize(int[][] array, int newsize) {
int[][] newarray = new int[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
private static Object[][] resize(Object[][] array, int newsize) {
Object[][] newarray = new Object[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
private static QName[][] resize(QName[][] array, int newsize) {
QName[][] newarray = new QName[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
private static String[][] resize(String[][] array, int newsize) {
String[][] newarray = new String[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
private static String[][][] resize(String[][][] array, int newsize) {
String[][][] newarray = new String[newsize][][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
protected static final class QNameHashtable {
public static final boolean UNIQUE_STRINGS = true;
private static final int INITIAL_BUCKET_SIZE = 4;
private static final int HASHTABLE_SIZE = 101;
private Object[][] fHashTable = new Object[101][];
public void put(String key, int value) {
int hash = (hash(key) + 2) % 101;
Object[] bucket = this.fHashTable[hash];
if (bucket == null) {
bucket = new Object[9];
bucket[0] = new int[] { 1 };
bucket[1] = key;
bucket[2] = new int[] { value };
this.fHashTable[hash] = bucket;
} else {
int count = ((int[])bucket[0])[0];
int offset = 1 + 2 * count;
if (offset == bucket.length) {
int newSize = count + 4;
Object[] newBucket = new Object[1 + 2 * newSize];
System.arraycopy(bucket, 0, newBucket, 0, offset);
bucket = newBucket;
this.fHashTable[hash] = bucket;
}
boolean found = false;
int j = 1;
for (int i = 0; i < count; i++) {
if ((String)bucket[j] == key) {
((int[])bucket[j + 1])[0] = value;
found = true;
break;
}
j += 2;
}
if (!found) {
bucket[offset++] = key;
bucket[offset] = new int[] { value };
((int[])bucket[0])[0] = ++count;
}
}
}
public int get(String key) {
int hash = (hash(key) + 2) % 101;
Object[] bucket = this.fHashTable[hash];
if (bucket == null)
return -1;
int count = ((int[])bucket[0])[0];
int j = 1;
for (int i = 0; i < count; i++) {
if ((String)bucket[j] == key)
return ((int[])bucket[j + 1])[0];
j += 2;
}
return -1;
}
protected int hash(String symbol) {
if (symbol == null)
return 0;
int code = 0;
int length = symbol.length();
for (int i = 0; i < length; i++)
code = code * 37 + symbol.charAt(i);
return code & 0x7FFFFFF;
}
}
private boolean normalizeDefaultAttrValue(XMLString value) {
int oldLength = value.length;
boolean skipSpace = true;
int current = value.offset;
int end = value.offset + value.length;
for (int i = value.offset; i < end; i++) {
if (value.ch[i] == ' ') {
if (!skipSpace) {
value.ch[current++] = ' ';
skipSpace = true;
}
} else {
if (current != i)
value.ch[current] = value.ch[i];
current++;
skipSpace = false;
}
}
if (current != end) {
if (skipSpace)
current--;
value.length = current - value.offset;
return true;
}
return false;
}
public void endDTD(Augmentations augs) throws XNIException {}
}

View file

@ -0,0 +1,23 @@
package com.sun.xml.stream.dtd.nonvalidating;
import com.sun.xml.stream.xerces.xni.QName;
public class XMLAttributeDecl {
public final QName name = new QName();
public final XMLSimpleType simpleType = new XMLSimpleType();
public boolean optional;
public void setValues(QName name, XMLSimpleType simpleType, boolean optional) {
this.name.setValues(name);
this.simpleType.setValues(simpleType);
this.optional = optional;
}
public void clear() {
this.name.clear();
this.simpleType.clear();
this.optional = false;
}
}

View file

@ -0,0 +1,37 @@
package com.sun.xml.stream.dtd.nonvalidating;
import com.sun.xml.stream.xerces.xni.QName;
public class XMLElementDecl {
public static final short TYPE_ANY = 0;
public static final short TYPE_EMPTY = 1;
public static final short TYPE_MIXED = 2;
public static final short TYPE_CHILDREN = 3;
public static final short TYPE_SIMPLE = 4;
public final QName name = new QName();
public int scope = -1;
public short type = -1;
public final XMLSimpleType simpleType = new XMLSimpleType();
public void setValues(QName name, int scope, short type, XMLSimpleType simpleType) {
this.name.setValues(name);
this.scope = scope;
this.type = type;
this.simpleType.setValues(simpleType);
}
public void clear() {
this.name.clear();
this.type = -1;
this.scope = -1;
this.simpleType.clear();
}
}

View file

@ -0,0 +1,25 @@
package com.sun.xml.stream.dtd.nonvalidating;
public class XMLNotationDecl {
public String name;
public String publicId;
public String systemId;
public String baseSystemId;
public void setValues(String name, String publicId, String systemId, String baseSystemId) {
this.name = name;
this.publicId = publicId;
this.systemId = systemId;
this.baseSystemId = baseSystemId;
}
public void clear() {
this.name = null;
this.publicId = null;
this.systemId = null;
this.baseSystemId = null;
}
}

View file

@ -0,0 +1,81 @@
package com.sun.xml.stream.dtd.nonvalidating;
public class XMLSimpleType {
public static final short TYPE_CDATA = 0;
public static final short TYPE_ENTITY = 1;
public static final short TYPE_ENUMERATION = 2;
public static final short TYPE_ID = 3;
public static final short TYPE_IDREF = 4;
public static final short TYPE_NMTOKEN = 5;
public static final short TYPE_NOTATION = 6;
public static final short TYPE_NAMED = 7;
public static final short DEFAULT_TYPE_DEFAULT = 3;
public static final short DEFAULT_TYPE_FIXED = 1;
public static final short DEFAULT_TYPE_IMPLIED = 0;
public static final short DEFAULT_TYPE_REQUIRED = 2;
public short type;
public String name;
public String[] enumeration;
public boolean list;
public short defaultType;
public String defaultValue;
public String nonNormalizedDefaultValue;
public void setValues(short type, String name, String[] enumeration, boolean list, short defaultType, String defaultValue, String nonNormalizedDefaultValue) {
this.type = type;
this.name = name;
if (enumeration != null && enumeration.length > 0) {
this.enumeration = new String[enumeration.length];
System.arraycopy(enumeration, 0, this.enumeration, 0, this.enumeration.length);
} else {
this.enumeration = null;
}
this.list = list;
this.defaultType = defaultType;
this.defaultValue = defaultValue;
this.nonNormalizedDefaultValue = nonNormalizedDefaultValue;
}
public void setValues(XMLSimpleType simpleType) {
this.type = simpleType.type;
this.name = simpleType.name;
if (simpleType.enumeration != null && simpleType.enumeration.length > 0) {
this.enumeration = new String[simpleType.enumeration.length];
System.arraycopy(simpleType.enumeration, 0, this.enumeration, 0, this.enumeration.length);
} else {
this.enumeration = null;
}
this.list = simpleType.list;
this.defaultType = simpleType.defaultType;
this.defaultValue = simpleType.defaultValue;
this.nonNormalizedDefaultValue = simpleType.nonNormalizedDefaultValue;
}
public void clear() {
this.type = -1;
this.name = null;
this.enumeration = null;
this.list = false;
this.defaultType = -1;
this.defaultValue = null;
this.nonNormalizedDefaultValue = null;
}
}

View file

@ -0,0 +1,102 @@
package com.sun.xml.stream.events;
import java.io.Writer;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
public class AttributeImpl extends DummyEvent implements Attribute {
private String fValue;
private String fNonNormalizedvalue;
private QName fQName;
private String fAttributeType = "CDATA";
private boolean fIsSpecified;
public AttributeImpl() {
init();
}
public AttributeImpl(String name, String value) {
init();
this.fQName = new QName(name);
this.fValue = value;
}
public AttributeImpl(String prefix, String name, String value) {
this(prefix, null, name, value, null, null, false);
}
public AttributeImpl(String prefix, String uri, String localPart, String value, String type) {
this(prefix, uri, localPart, value, null, type, false);
}
public AttributeImpl(String prefix, String uri, String localPart, String value, String nonNormalizedvalue, String type, boolean isSpecified) {
this(new QName(uri, localPart, prefix), value, nonNormalizedvalue, type, isSpecified);
}
public AttributeImpl(QName qname, String value, String nonNormalizedvalue, String type, boolean isSpecified) {
init();
this.fQName = qname;
this.fValue = value;
if (type != null && !type.equals(""))
this.fAttributeType = type;
this.fNonNormalizedvalue = nonNormalizedvalue;
this.fIsSpecified = isSpecified;
}
public String toString() {
if (this.fQName.getPrefix() != null && this.fQName.getPrefix().length() > 0)
return this.fQName.getPrefix() + ":" + this.fQName.getLocalPart() + "='" + this.fValue + "'";
return this.fQName.getLocalPart() + "='" + this.fValue + "'";
}
public void setName(QName name) {
this.fQName = name;
}
public QName getName() {
return this.fQName;
}
public void setValue(String value) {
this.fValue = value;
}
public String getValue() {
return this.fValue;
}
public void setNonNormalizedValue(String nonNormalizedvalue) {
this.fNonNormalizedvalue = nonNormalizedvalue;
}
public String getNonNormalizedValue() {
return this.fNonNormalizedvalue;
}
public void setAttributeType(String attributeType) {
this.fAttributeType = attributeType;
}
public String getDTDType() {
return this.fAttributeType;
}
public void setSpecified(boolean isSpecified) {
this.fIsSpecified = isSpecified;
}
public boolean isSpecified() {
return this.fIsSpecified;
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
protected void init() {
setEventType(10);
}
}

View file

@ -0,0 +1,91 @@
package com.sun.xml.stream.events;
import com.sun.xml.stream.xerces.util.XMLChar;
import java.io.Writer;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Characters;
public class CharacterEvent extends DummyEvent implements Characters {
private String fData;
private boolean fIsCData;
private boolean fIsIgnorableWhitespace;
private boolean fIsSpace = false;
private boolean fCheckIfSpaceNeeded = true;
public CharacterEvent() {
this.fIsCData = false;
init();
}
public CharacterEvent(String data) {
this.fIsCData = false;
init();
this.fData = data;
}
public CharacterEvent(String data, boolean flag) {
init();
this.fData = data;
this.fIsCData = flag;
}
public CharacterEvent(String data, boolean flag, boolean isIgnorableWhiteSpace) {
init();
this.fData = data;
this.fIsCData = flag;
this.fIsIgnorableWhitespace = isIgnorableWhiteSpace;
}
protected void init() {
setEventType(4);
}
public String getData() {
return this.fData;
}
public void setData(String data) {
this.fData = data;
this.fCheckIfSpaceNeeded = true;
}
public boolean isCData() {
return this.fIsCData;
}
public String toString() {
if (this.fIsCData)
return "<![CDATA[" + getData() + "]]>";
return this.fData;
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
public boolean isIgnorableWhiteSpace() {
return this.fIsIgnorableWhitespace;
}
public boolean isWhiteSpace() {
if (this.fCheckIfSpaceNeeded) {
checkWhiteSpace();
this.fCheckIfSpaceNeeded = false;
}
return this.fIsSpace;
}
private void checkWhiteSpace() {
if (this.fData != null && this.fData.length() > 0) {
this.fIsSpace = true;
for (int i = 0; i < this.fData.length(); i++) {
if (!XMLChar.isSpace(this.fData.charAt(i))) {
this.fIsSpace = false;
break;
}
}
}
}
}

View file

@ -0,0 +1,28 @@
package com.sun.xml.stream.events;
import javax.xml.stream.events.Comment;
public class CommentEvent extends DummyEvent implements Comment {
private String fText;
public CommentEvent() {
init();
}
public CommentEvent(String text) {
init();
this.fText = text;
}
protected void init() {
setEventType(5);
}
public String toString() {
return "<!--" + getText() + "-->";
}
public String getText() {
return this.fText;
}
}

View file

@ -0,0 +1,57 @@
package com.sun.xml.stream.events;
import java.util.List;
import javax.xml.stream.events.DTD;
public class DTDEvent extends DummyEvent implements DTD {
private String fDoctypeDeclaration;
private List fNotations;
private List fEntities;
public DTDEvent() {
init();
}
public DTDEvent(String doctypeDeclaration) {
init();
this.fDoctypeDeclaration = doctypeDeclaration;
}
public void setDocumentTypeDeclaration(String doctypeDeclaration) {
this.fDoctypeDeclaration = doctypeDeclaration;
}
public String getDocumentTypeDeclaration() {
return this.fDoctypeDeclaration;
}
public void setEntities(List entites) {
this.fEntities = entites;
}
public List getEntities() {
return this.fEntities;
}
public void setNotations(List notations) {
this.fNotations = notations;
}
public List getNotations() {
return this.fNotations;
}
public Object getProcessedDTD() {
return null;
}
protected void init() {
setEventType(11);
}
public String toString() {
return this.fDoctypeDeclaration;
}
}

View file

@ -0,0 +1,96 @@
package com.sun.xml.stream.events;
import java.io.Writer;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
public abstract class DummyEvent implements XMLEvent {
private int fEventType;
protected Location fLocation = null;
public DummyEvent() {}
public DummyEvent(int i) {
this.fEventType = i;
}
public int getEventType() {
return this.fEventType;
}
protected void setEventType(int eventType) {
this.fEventType = eventType;
}
public boolean isStartElement() {
return (this.fEventType == 1);
}
public boolean isEndElement() {
return (this.fEventType == 2);
}
public boolean isEntityReference() {
return (this.fEventType == 9);
}
public boolean isProcessingInstruction() {
return (this.fEventType == 3);
}
public boolean isCharacterData() {
return (this.fEventType == 4);
}
public boolean isStartDocument() {
return (this.fEventType == 7);
}
public boolean isEndDocument() {
return (this.fEventType == 8);
}
public Location getLocation() {
return this.fLocation;
}
void setLocation(Location loc) {
this.fLocation = loc;
}
public Characters asCharacters() {
return (Characters)this;
}
public EndElement asEndElement() {
return (EndElement)this;
}
public StartElement asStartElement() {
return (StartElement)this;
}
public QName getSchemaType() {
return null;
}
public boolean isAttribute() {
return (this.fEventType == 10);
}
public boolean isCharacters() {
return (this.fEventType == 4);
}
public boolean isNamespace() {
return (this.fEventType == 13);
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
}

View file

@ -0,0 +1,21 @@
package com.sun.xml.stream.events;
import java.io.Writer;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EndDocument;
public class EndDocumentEvent extends DummyEvent implements EndDocument {
public EndDocumentEvent() {
init();
}
protected void init() {
setEventType(8);
}
public String toString() {
return "ENDDOCUMENT";
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
}

View file

@ -0,0 +1,70 @@
package com.sun.xml.stream.events;
import com.sun.xml.stream.util.ReadOnlyIterator;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.Namespace;
public class EndElementEvent extends DummyEvent implements EndElement {
List fNamespaces = null;
QName fQName;
public EndElementEvent() {
init();
}
protected void init() {
setEventType(2);
this.fNamespaces = new ArrayList();
}
public EndElementEvent(String prefix, String uri, String localpart) {
this(new QName(uri, localpart, prefix));
}
public EndElementEvent(QName qname) {
this.fQName = qname;
init();
}
public QName getName() {
return this.fQName;
}
public void setName(QName qname) {
this.fQName = qname;
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
public Iterator getNamespaces() {
if (this.fNamespaces != null)
this.fNamespaces.iterator();
return new ReadOnlyIterator();
}
void addNamespace(Namespace attr) {
if (attr != null)
this.fNamespaces.add(attr);
}
public String toString() {
String s = "</" + nameAsString();
s = s + ">";
return s;
}
public String nameAsString() {
if ("".equals(this.fQName.getNamespaceURI()))
return this.fQName.getLocalPart();
if (this.fQName.getPrefix() != null)
return "['" + this.fQName.getNamespaceURI() + "']:" + this.fQName.getPrefix() + ":" + this.fQName.getLocalPart();
return "['" + this.fQName.getNamespaceURI() + "']:" + this.fQName.getLocalPart();
}
}

View file

@ -0,0 +1,87 @@
package com.sun.xml.stream.events;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
import javax.xml.stream.events.EntityDeclaration;
public class EntityDeclarationImpl extends DummyEvent implements EntityDeclaration {
private XMLResourceIdentifier fXMLResourceIdentifier;
private String fEntityName;
private String fReplacementText;
private String fNotationName;
public EntityDeclarationImpl() {
init();
}
public EntityDeclarationImpl(String entityName, String replacementText) {
this(entityName, replacementText, null);
}
public EntityDeclarationImpl(String entityName, String replacementText, XMLResourceIdentifier resourceIdentifier) {
init();
this.fEntityName = entityName;
this.fReplacementText = replacementText;
this.fXMLResourceIdentifier = resourceIdentifier;
}
public void setEntityName(String entityName) {
this.fEntityName = entityName;
}
public String getEntityName() {
return this.fEntityName;
}
public void setEntityReplacementText(String replacementText) {
this.fReplacementText = replacementText;
}
public void setXMLResourceIdentifier(XMLResourceIdentifier resourceIdentifier) {
this.fXMLResourceIdentifier = resourceIdentifier;
}
public XMLResourceIdentifier getXMLResourceIdentifier() {
return this.fXMLResourceIdentifier;
}
public String getSystemId() {
if (this.fXMLResourceIdentifier != null)
return this.fXMLResourceIdentifier.getLiteralSystemId();
return null;
}
public String getPublicId() {
if (this.fXMLResourceIdentifier != null)
return this.fXMLResourceIdentifier.getPublicId();
return null;
}
public String getBaseURI() {
if (this.fXMLResourceIdentifier != null)
return this.fXMLResourceIdentifier.getBaseSystemId();
return null;
}
public String getName() {
return this.fEntityName;
}
public String getNotationName() {
return this.fNotationName;
}
public void setNotationName(String notationName) {
this.fNotationName = notationName;
}
public String getReplacementText() {
return this.fReplacementText;
}
protected void init() {
setEventType(15);
}
}

View file

@ -0,0 +1,43 @@
package com.sun.xml.stream.events;
import java.io.Writer;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EntityDeclaration;
import javax.xml.stream.events.EntityReference;
public class EntityReferenceEvent extends DummyEvent implements EntityReference {
private EntityDeclaration fEntityDeclaration;
private String fEntityName;
public EntityReferenceEvent() {
init();
}
public EntityReferenceEvent(String entityName, EntityDeclaration entityDeclaration) {
init();
this.fEntityName = entityName;
this.fEntityDeclaration = entityDeclaration;
}
public String getName() {
return this.fEntityName;
}
public String toString() {
String text = this.fEntityDeclaration.getReplacementText();
if (text == null)
text = "";
return "&" + getName() + ";='" + text + "'";
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
public EntityDeclaration getDeclaration() {
return this.fEntityDeclaration;
}
protected void init() {
setEventType(9);
}
}

View file

@ -0,0 +1,58 @@
package com.sun.xml.stream.events;
import javax.xml.stream.Location;
public class LocationImpl implements Location {
String systemId;
String publicId;
int colNo;
int lineNo;
int charOffset;
LocationImpl(Location loc) {
this.systemId = loc.getSystemId();
this.publicId = loc.getPublicId();
this.lineNo = loc.getLineNumber();
this.colNo = loc.getColumnNumber();
this.charOffset = loc.getCharacterOffset();
}
public int getCharacterOffset() {
return this.charOffset;
}
public int getColumnNumber() {
return this.colNo;
}
public int getLineNumber() {
return this.lineNo;
}
public String getPublicId() {
return this.publicId;
}
public String getSystemId() {
return this.systemId;
}
public String toString() {
StringBuffer sbuffer = new StringBuffer();
sbuffer.append("Line number = " + getLineNumber());
sbuffer.append("\n");
sbuffer.append("Column number = " + getColumnNumber());
sbuffer.append("\n");
sbuffer.append("System Id = " + getSystemId());
sbuffer.append("\n");
sbuffer.append("Public Id = " + getPublicId());
sbuffer.append("\n");
sbuffer.append("CharacterOffset = " + getCharacterOffset());
sbuffer.append("\n");
return sbuffer.toString();
}
}

View file

@ -0,0 +1,41 @@
package com.sun.xml.stream.events;
import javax.xml.namespace.QName;
public class NamedEvent extends DummyEvent {
private QName name;
public NamedEvent() {}
public NamedEvent(QName qname) {
this.name = qname;
}
public NamedEvent(String prefix, String uri, String localpart) {
this.name = new QName(uri, localpart, prefix);
}
public String getPrefix() {
return this.name.getPrefix();
}
public QName getName() {
return this.name;
}
public void setName(QName qname) {
this.name = qname;
}
public String nameAsString() {
if ("".equals(this.name.getNamespaceURI()))
return this.name.getLocalPart();
if (this.name.getPrefix() != null)
return "['" + this.name.getNamespaceURI() + "']:" + getPrefix() + ":" + this.name.getLocalPart();
return "['" + this.name.getNamespaceURI() + "']:" + this.name.getLocalPart();
}
public String getNamespace() {
return this.name.getNamespaceURI();
}
}

View file

@ -0,0 +1,62 @@
package com.sun.xml.stream.events;
import javax.xml.namespace.QName;
import javax.xml.stream.events.Namespace;
public class NamespaceImpl extends AttributeImpl implements Namespace {
public NamespaceImpl() {
init();
}
public NamespaceImpl(String namespaceURI) {
super("xmlns", "http://www.w3.org/2000/xmlns/", "", namespaceURI, null);
init();
}
public NamespaceImpl(String prefix, String namespaceURI) {
super("xmlns", "http://www.w3.org/2000/xmlns/", prefix, namespaceURI, null);
init();
}
public boolean isDefaultNamespaceDeclaration() {
QName name = getName();
if (name != null && name.getLocalPart().equals(""))
return true;
return false;
}
void setPrefix(String prefix) {
if (prefix == null) {
setName(new QName("http://www.w3.org/2000/xmlns/", "", "xmlns"));
} else {
setName(new QName("http://www.w3.org/2000/xmlns/", prefix, "xmlns"));
}
}
public String getPrefix() {
QName name = getName();
if (name != null)
return name.getLocalPart();
return null;
}
public String getNamespaceURI() {
return getValue();
}
void setNamespaceURI(String uri) {
setValue(uri);
}
protected void init() {
setEventType(13);
}
public int getEventType() {
return 13;
}
public boolean isNamespace() {
return true;
}
}

View file

@ -0,0 +1,54 @@
package com.sun.xml.stream.events;
import com.sun.xml.stream.dtd.nonvalidating.XMLNotationDecl;
import javax.xml.stream.events.NotationDeclaration;
public class NotationDeclarationImpl extends DummyEvent implements NotationDeclaration {
String fName = null;
String fPublicId = null;
String fSystemId = null;
public NotationDeclarationImpl() {
setEventType(14);
}
public NotationDeclarationImpl(String name, String publicId, String systemId) {
this.fName = name;
this.fPublicId = publicId;
this.fSystemId = systemId;
setEventType(14);
}
public NotationDeclarationImpl(XMLNotationDecl notation) {
this.fName = notation.name;
this.fPublicId = notation.publicId;
this.fSystemId = notation.systemId;
setEventType(14);
}
public String getName() {
return this.fName;
}
public String getPublicId() {
return this.fPublicId;
}
public String getSystemId() {
return this.fSystemId;
}
void setPublicId(String publicId) {
this.fPublicId = publicId;
}
void setSystemId(String systemId) {
this.fSystemId = systemId;
}
void setName(String name) {
this.fName = name;
}
}

View file

@ -0,0 +1,59 @@
package com.sun.xml.stream.events;
import java.io.Writer;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.ProcessingInstruction;
public class ProcessingInstructionEvent extends DummyEvent implements ProcessingInstruction {
private String fName;
private String fContent;
public ProcessingInstructionEvent() {
init();
}
public ProcessingInstructionEvent(String targetName, String data) {
this(targetName, data, null);
}
public ProcessingInstructionEvent(String targetName, String data, Location loc) {
init();
this.fName = targetName;
this.fContent = data;
setLocation(loc);
}
protected void init() {
setEventType(3);
}
public String getTarget() {
return this.fName;
}
public void setTarget(String targetName) {
this.fName = targetName;
}
public void setData(String data) {
this.fContent = data;
}
public String getData() {
return this.fContent;
}
public String toString() {
if (this.fContent != null && this.fName != null)
return "<?" + this.fName + this.fContent + "?>";
if (this.fName != null)
return "<?" + this.fName + "?>";
if (this.fContent != null)
return "<?" + this.fContent + "?>";
return "<??>";
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
}

View file

@ -0,0 +1,131 @@
package com.sun.xml.stream.events;
import javax.xml.stream.Location;
import javax.xml.stream.events.StartDocument;
public class StartDocumentEvent extends DummyEvent implements StartDocument {
protected String fSystemId;
protected String fEncodingScheam;
protected boolean fStandalone;
protected String fVersion;
private boolean fEncodingSchemeSet;
private boolean fStandaloneSet;
public StartDocumentEvent() {
this("UTF-8", "1.0", true, null);
}
public StartDocumentEvent(String encoding) {
this(encoding, "1.0", true, null);
}
public StartDocumentEvent(String encoding, String version) {
this(encoding, version, true, null);
}
public StartDocumentEvent(String encoding, String version, boolean standalone) {
this(encoding, version, standalone, null);
}
public StartDocumentEvent(String encoding, String version, boolean standalone, Location loc) {
init();
this.fEncodingScheam = encoding;
this.fVersion = version;
this.fStandalone = standalone;
this.fEncodingSchemeSet = false;
this.fStandaloneSet = false;
this.fLocation = loc;
}
protected void init() {
setEventType(7);
}
public String getSystemId() {
if (this.fLocation == null)
return "";
return this.fLocation.getSystemId();
}
public String getCharacterEncodingScheme() {
return this.fEncodingScheam;
}
public boolean isStandalone() {
return this.fStandalone;
}
public String getVersion() {
return this.fVersion;
}
public void setStandalone(boolean flag) {
this.fStandaloneSet = true;
this.fStandalone = flag;
}
public void setStandalone(String s) {
this.fStandaloneSet = true;
if (s == null) {
this.fStandalone = true;
return;
}
if (s.equals("yes")) {
this.fStandalone = true;
} else {
this.fStandalone = false;
}
}
public boolean encodingSet() {
return this.fEncodingSchemeSet;
}
public boolean standaloneSet() {
return this.fStandaloneSet;
}
public void setEncoding(String encoding) {
this.fEncodingScheam = encoding;
}
void setDeclaredEncoding(boolean value) {
this.fEncodingSchemeSet = value;
}
public void setVersion(String s) {
this.fVersion = s;
}
void clear() {
this.fEncodingScheam = "UTF-8";
this.fStandalone = true;
this.fVersion = "1.0";
this.fEncodingSchemeSet = false;
this.fStandaloneSet = false;
}
public String toString() {
String s = "<?xml version=\"" + this.fVersion + "\"";
s = s + " encoding='" + this.fEncodingScheam + "'";
if (this.fStandaloneSet) {
if (this.fStandalone) {
s = s + " standalone='yes'?>";
} else {
s = s + " standalone='no'?>";
}
} else {
s = s + "?>";
}
return s;
}
public boolean isStartDocument() {
return true;
}
}

View file

@ -0,0 +1,159 @@
package com.sun.xml.stream.events;
import com.sun.xml.stream.util.ReadOnlyIterator;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
public class StartElementEvent extends DummyEvent implements StartElement {
private Map fAttributes;
private List fNamespaces;
private NamespaceContext fNamespaceContext = null;
private QName fQName;
public StartElementEvent(String prefix, String uri, String localpart) {
this(new QName(uri, localpart, prefix));
}
public StartElementEvent(QName qname) {
this.fQName = qname;
init();
}
public StartElementEvent(StartElement startelement) {
this(startelement.getName());
addAttributes(startelement.getAttributes());
addNamespaceAttributes(startelement.getNamespaces());
}
protected void init() {
setEventType(1);
this.fAttributes = new HashMap();
this.fNamespaces = new ArrayList();
}
public QName getName() {
return this.fQName;
}
public void setName(QName qname) {
this.fQName = qname;
}
public Iterator getAttributes() {
if (this.fAttributes != null) {
Collection coll = this.fAttributes.values();
return new ReadOnlyIterator(coll.iterator());
}
return new ReadOnlyIterator();
}
public Iterator getNamespaces() {
if (this.fNamespaces != null)
return new ReadOnlyIterator(this.fNamespaces.iterator());
return new ReadOnlyIterator();
}
public Attribute getAttributeByName(QName qname) {
if (qname == null)
return null;
return (Attribute)this.fAttributes.get(qname);
}
public String getNamespace() {
return this.fQName.getNamespaceURI();
}
public String getNamespaceURI(String prefix) {
if (getNamespace() != null && this.fQName.getPrefix().equals(prefix))
return getNamespace();
if (this.fNamespaceContext != null)
return this.fNamespaceContext.getNamespaceURI(prefix);
return null;
}
public String toString() {
String s = "<" + nameAsString();
if (this.fAttributes != null) {
Iterator<Attribute> it = getAttributes();
Attribute attr = null;
while (it.hasNext()) {
attr = it.next();
s = s + " " + attr.toString();
}
}
if (this.fNamespaces != null) {
Iterator<Namespace> it = this.fNamespaces.iterator();
Namespace attr = null;
while (it.hasNext()) {
attr = it.next();
s = s + " " + attr.toString();
}
}
s = s + ">";
return s;
}
public String nameAsString() {
if ("".equals(this.fQName.getNamespaceURI()))
return this.fQName.getLocalPart();
if (this.fQName.getPrefix() != null)
return "['" + this.fQName.getNamespaceURI() + "']:" + this.fQName.getPrefix() + ":" + this.fQName.getLocalPart();
return "['" + this.fQName.getNamespaceURI() + "']:" + this.fQName.getLocalPart();
}
public NamespaceContext getNamespaceContext() {
return this.fNamespaceContext;
}
public void setNamespaceContext(NamespaceContext nc) {
this.fNamespaceContext = nc;
}
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {}
void addAttribute(Attribute attr) {
if (attr.isNamespace()) {
this.fNamespaces.add(attr);
} else {
this.fAttributes.put(attr.getName(), attr);
}
}
void addAttributes(Iterator attrs) {
if (attrs == null)
return;
while (attrs.hasNext()) {
Attribute attr = attrs.next();
this.fAttributes.put(attr.getName(), attr);
}
}
void addNamespaceAttribute(Namespace attr) {
if (attr == null)
return;
this.fNamespaces.add(attr);
}
void addNamespaceAttributes(Iterator attrs) {
if (attrs == null)
return;
while (attrs.hasNext()) {
Namespace attr = attrs.next();
this.fNamespaces.add(attr);
}
}
}

View file

@ -0,0 +1,192 @@
package com.sun.xml.stream.events;
import com.sun.xml.stream.xerces.util.NamespaceContextWrapper;
import com.sun.xml.stream.xerces.util.NamespaceSupport;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.util.XMLEventAllocator;
import javax.xml.stream.util.XMLEventConsumer;
public class XMLEventAllocatorImpl implements XMLEventAllocator {
public XMLEvent allocate(XMLStreamReader xMLStreamReader) throws XMLStreamException {
if (xMLStreamReader == null)
throw new XMLStreamException("Reader cannot be null");
return getXMLEvent(xMLStreamReader);
}
public void allocate(XMLStreamReader xMLStreamReader, XMLEventConsumer xMLEventConsumer) throws XMLStreamException {
XMLEvent currentEvent = getXMLEvent(xMLStreamReader);
if (currentEvent != null)
xMLEventConsumer.add(currentEvent);
}
public XMLEventAllocator newInstance() {
return new XMLEventAllocatorImpl();
}
XMLEvent getXMLEvent(XMLStreamReader streamReader) {
StartElementEvent startElementEvent;
EndElementEvent endElementEvent;
ProcessingInstructionEvent piEvent;
CharacterEvent characterEvent1;
CommentEvent commentEvent;
StartDocumentEvent sdEvent;
EndDocumentEvent endDocumentEvent;
EntityReferenceEvent entityEvent;
CharacterEvent cDataEvent, spaceEvent;
XMLEvent event = null;
int eventType = streamReader.getEventType();
switch (eventType) {
case 1:
startElementEvent = new StartElementEvent(getQName(streamReader));
fillAttributes(startElementEvent, streamReader);
if ((Boolean)streamReader.getProperty("javax.xml.stream.isNamespaceAware")) {
fillNamespaceAttributes(startElementEvent, streamReader);
setNamespaceContext(startElementEvent, streamReader);
}
startElementEvent.setLocation(streamReader.getLocation());
event = startElementEvent;
break;
case 2:
endElementEvent = new EndElementEvent(getQName(streamReader));
endElementEvent.setLocation(streamReader.getLocation());
if ((Boolean)streamReader.getProperty("javax.xml.stream.isNamespaceAware"))
fillNamespaceAttributes(endElementEvent, streamReader);
event = endElementEvent;
break;
case 3:
piEvent = new ProcessingInstructionEvent(streamReader.getPITarget(), streamReader.getPIData());
piEvent.setLocation(streamReader.getLocation());
event = piEvent;
break;
case 4:
characterEvent1 = new CharacterEvent(streamReader.getText());
characterEvent1.setLocation(streamReader.getLocation());
event = characterEvent1;
break;
case 5:
commentEvent = new CommentEvent(streamReader.getText());
commentEvent.setLocation(streamReader.getLocation());
event = commentEvent;
break;
case 7:
sdEvent = new StartDocumentEvent();
sdEvent.setVersion(streamReader.getVersion());
sdEvent.setEncoding(streamReader.getEncoding());
if (streamReader.getCharacterEncodingScheme() != null) {
sdEvent.setDeclaredEncoding(true);
} else {
sdEvent.setDeclaredEncoding(false);
}
sdEvent.setStandalone(streamReader.isStandalone());
sdEvent.setLocation(streamReader.getLocation());
event = sdEvent;
break;
case 8:
endDocumentEvent = new EndDocumentEvent();
endDocumentEvent.setLocation(streamReader.getLocation());
event = endDocumentEvent;
break;
case 9:
entityEvent = new EntityReferenceEvent(streamReader.getLocalName(), new EntityDeclarationImpl(streamReader.getLocalName(), streamReader.getText()));
entityEvent.setLocation(streamReader.getLocation());
event = entityEvent;
break;
case 10:
event = null;
break;
case 11:
event = new DTDEvent(streamReader.getText());
break;
case 12:
cDataEvent = new CharacterEvent(streamReader.getText(), true);
cDataEvent.setLocation(streamReader.getLocation());
event = cDataEvent;
break;
case 6:
spaceEvent = new CharacterEvent(streamReader.getText(), false, true);
spaceEvent.setLocation(streamReader.getLocation());
event = spaceEvent;
break;
}
return event;
}
protected XMLEvent getNextEvent(XMLStreamReader streamReader) throws XMLStreamException {
streamReader.next();
return getXMLEvent(streamReader);
}
protected void fillAttributes(StartElementEvent event, XMLStreamReader xmlr) {
int len = xmlr.getAttributeCount();
QName qname = null;
String prefix = null;
String localpart = null;
AttributeImpl attr = null;
NamespaceImpl nattr = null;
for (int i = 0; i < len; i++) {
qname = xmlr.getAttributeName(i);
prefix = qname.getPrefix();
localpart = qname.getLocalPart();
attr = new AttributeImpl();
attr.setName(qname);
attr.setAttributeType(xmlr.getAttributeType(i));
attr.setSpecified(xmlr.isAttributeSpecified(i));
attr.setValue(xmlr.getAttributeValue(i));
event.addAttribute(attr);
}
}
protected void fillNamespaceAttributes(StartElementEvent event, XMLStreamReader xmlr) {
int count = xmlr.getNamespaceCount();
String uri = null;
String prefix = null;
NamespaceImpl attr = null;
for (int i = 0; i < count; i++) {
uri = xmlr.getNamespaceURI(i);
prefix = xmlr.getNamespacePrefix(i);
if (prefix == null)
prefix = "";
attr = new NamespaceImpl(prefix, uri);
event.addNamespaceAttribute(attr);
}
}
protected void fillNamespaceAttributes(EndElementEvent event, XMLStreamReader xmlr) {
int count = xmlr.getNamespaceCount();
String uri = null;
String prefix = null;
NamespaceImpl attr = null;
for (int i = 0; i < count; i++) {
uri = xmlr.getNamespaceURI(i);
prefix = xmlr.getNamespacePrefix(i);
if (prefix == null)
prefix = "";
attr = new NamespaceImpl(prefix, uri);
event.addNamespace(attr);
}
}
private void setNamespaceContext(StartElementEvent event, XMLStreamReader xmlr) {
NamespaceContextWrapper contextWrapper = (NamespaceContextWrapper)xmlr.getNamespaceContext();
NamespaceSupport ns = new NamespaceSupport(contextWrapper.getNamespaceContext());
event.setNamespaceContext(new NamespaceContextWrapper(ns));
}
private QName getQName(XMLStreamReader xmlr) {
String prefix = xmlr.getPrefix();
String uri = xmlr.getNamespaceURI();
String localpart = xmlr.getLocalName();
QName qn = null;
if (prefix != null && uri != null) {
qn = new QName(uri, localpart, prefix);
} else if (prefix == null && uri != null) {
qn = new QName(uri, localpart);
} else if (prefix == null && uri == null) {
qn = new QName(localpart);
}
return qn;
}
}

View file

@ -0,0 +1,196 @@
package com.sun.xml.stream.events;
import java.util.Iterator;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.Comment;
import javax.xml.stream.events.DTD;
import javax.xml.stream.events.EndDocument;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.EntityDeclaration;
import javax.xml.stream.events.EntityReference;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.ProcessingInstruction;
import javax.xml.stream.events.StartDocument;
import javax.xml.stream.events.StartElement;
public class ZephyrEventFactory extends XMLEventFactory {
Location location = null;
public Attribute createAttribute(String localName, String value) {
AttributeImpl attr = new AttributeImpl(localName, value);
if (this.location != null)
attr.setLocation(this.location);
return attr;
}
public Attribute createAttribute(QName name, String value) {
return createAttribute(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), value);
}
public Attribute createAttribute(String prefix, String namespaceURI, String localName, String value) {
AttributeImpl attr = new AttributeImpl(prefix, namespaceURI, localName, value, null);
if (this.location != null)
attr.setLocation(this.location);
return attr;
}
public Characters createCData(String content) {
CharacterEvent charEvent = new CharacterEvent(content, true);
if (this.location != null)
charEvent.setLocation(this.location);
return charEvent;
}
public Characters createCharacters(String content) {
CharacterEvent charEvent = new CharacterEvent(content);
if (this.location != null)
charEvent.setLocation(this.location);
return charEvent;
}
public Comment createComment(String text) {
CommentEvent charEvent = new CommentEvent(text);
if (this.location != null)
charEvent.setLocation(this.location);
return charEvent;
}
public DTD createDTD(String dtd) {
DTDEvent dtdEvent = new DTDEvent(dtd);
if (this.location != null)
dtdEvent.setLocation(this.location);
return dtdEvent;
}
public EndDocument createEndDocument() {
EndDocumentEvent event = new EndDocumentEvent();
if (this.location != null)
event.setLocation(this.location);
return event;
}
public EndElement createEndElement(QName name, Iterator namespaces) {
return createEndElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart());
}
public EndElement createEndElement(String prefix, String namespaceUri, String localName) {
EndElementEvent event = new EndElementEvent(prefix, namespaceUri, localName);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public EndElement createEndElement(String prefix, String namespaceUri, String localName, Iterator namespaces) {
EndElementEvent event = new EndElementEvent(prefix, namespaceUri, localName);
if (namespaces != null)
while (namespaces.hasNext())
event.addNamespace(namespaces.next());
if (this.location != null)
event.setLocation(this.location);
return event;
}
public EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
EntityReferenceEvent event = new EntityReferenceEvent(name, entityDeclaration);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public Characters createIgnorableSpace(String content) {
CharacterEvent event = new CharacterEvent(content, false, true);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public Namespace createNamespace(String namespaceURI) {
NamespaceImpl event = new NamespaceImpl(namespaceURI);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public Namespace createNamespace(String prefix, String namespaceURI) {
NamespaceImpl event = new NamespaceImpl(prefix, namespaceURI);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public ProcessingInstruction createProcessingInstruction(String target, String data) {
ProcessingInstructionEvent event = new ProcessingInstructionEvent(target, data);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public Characters createSpace(String content) {
CharacterEvent event = new CharacterEvent(content);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public StartDocument createStartDocument() {
StartDocumentEvent event = new StartDocumentEvent();
if (this.location != null)
event.setLocation(this.location);
return event;
}
public StartDocument createStartDocument(String encoding) {
StartDocumentEvent event = new StartDocumentEvent(encoding);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public StartDocument createStartDocument(String encoding, String version) {
StartDocumentEvent event = new StartDocumentEvent(encoding, version);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public StartDocument createStartDocument(String encoding, String version, boolean standalone) {
StartDocumentEvent event = new StartDocumentEvent(encoding, version, standalone);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public StartElement createStartElement(QName name, Iterator attributes, Iterator namespaces) {
return createStartElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), attributes, namespaces);
}
public StartElement createStartElement(String prefix, String namespaceUri, String localName) {
StartElementEvent event = new StartElementEvent(prefix, namespaceUri, localName);
if (this.location != null)
event.setLocation(this.location);
return event;
}
public StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator namespaces) {
return createStartElement(prefix, namespaceUri, localName, attributes, namespaces, (NamespaceContext)null);
}
public StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator namespaces, NamespaceContext context) {
StartElementEvent elem = new StartElementEvent(prefix, namespaceUri, localName);
elem.addAttributes(attributes);
elem.addNamespaceAttributes(namespaces);
elem.setNamespaceContext(context);
if (this.location != null)
elem.setLocation(this.location);
return elem;
}
public void setLocation(Location location) {
this.location = location;
}
}

View file

@ -0,0 +1,29 @@
package com.sun.xml.stream.util;
import java.util.Iterator;
public class ReadOnlyIterator implements Iterator {
Iterator iterator = null;
public ReadOnlyIterator() {}
public ReadOnlyIterator(Iterator itr) {
this.iterator = itr;
}
public boolean hasNext() {
if (this.iterator != null)
return this.iterator.hasNext();
return false;
}
public Object next() {
if (this.iterator != null)
return this.iterator.next();
return null;
}
public void remove() {
throw new UnsupportedOperationException("Remove operation is not supported");
}
}

View file

@ -0,0 +1,139 @@
package com.sun.xml.stream.writers;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class WriterUtility {
public static final String START_COMMENT = "<!--";
public static final String END_COMMENT = "-->";
public static final String DEFAULT_ENCODING = " encoding=\"utf-8\"";
public static final String DEFAULT_XMLDECL = "<?xml version=\"1.0\" ?>";
public static final String DEFAULT_XML_VERSION = "1.0";
public static final char CLOSE_START_TAG = '>';
public static final char OPEN_START_TAG = '<';
public static final String OPEN_END_TAG = "</";
public static final char CLOSE_END_TAG = '>';
public static final String START_CDATA = "<![CDATA[";
public static final String END_CDATA = "]]>";
public static final String CLOSE_EMPTY_ELEMENT = "/>";
public static final String SPACE = " ";
public static final String UTF_8 = "utf-8";
static final boolean DEBUG_XML_CONTENT = false;
boolean fEscapeCharacters = true;
Writer fWriter = null;
CharsetEncoder fEncoder;
public WriterUtility() {
this.fEncoder = getDefaultEncoder();
}
public WriterUtility(Writer writer) {
this.fWriter = writer;
if (writer instanceof OutputStreamWriter) {
String charset = ((OutputStreamWriter)writer).getEncoding();
if (charset != null)
this.fEncoder = Charset.forName(charset).newEncoder();
} else if (writer instanceof FileWriter) {
String charset = ((FileWriter)writer).getEncoding();
if (charset != null)
this.fEncoder = Charset.forName(charset).newEncoder();
} else {
this.fEncoder = getDefaultEncoder();
}
}
public void setWriter(Writer writer) {
this.fWriter = writer;
}
public void setEscapeCharacters(boolean escape) {
this.fEscapeCharacters = escape;
}
public boolean getEscapeCharacters() {
return this.fEscapeCharacters;
}
public void writeXMLContent(char[] content, int start, int length) throws IOException {
writeXMLContent(content, start, length, getEscapeCharacters());
}
private void writeXMLContent(char[] content, int start, int length, boolean escapeCharacter) throws IOException {
int end = start + length;
int startWritePos = start;
for (int index = start; index < end; index++) {
char ch = content[index];
if (this.fEncoder != null && !this.fEncoder.canEncode(ch)) {
this.fWriter.write(content, startWritePos, index - startWritePos);
this.fWriter.write("&#x");
this.fWriter.write(Integer.toHexString(ch));
this.fWriter.write(59);
startWritePos = index + 1;
}
switch (ch) {
case '<':
if (escapeCharacter) {
this.fWriter.write(content, startWritePos, index - startWritePos);
this.fWriter.write("&lt;");
startWritePos = index + 1;
}
break;
case '&':
if (escapeCharacter) {
this.fWriter.write(content, startWritePos, index - startWritePos);
this.fWriter.write("&amp;");
startWritePos = index + 1;
}
break;
case '>':
if (escapeCharacter) {
this.fWriter.write(content, startWritePos, index - startWritePos);
this.fWriter.write("&gt;");
startWritePos = index + 1;
}
break;
}
}
this.fWriter.write(content, startWritePos, end - startWritePos);
}
public void writeXMLContent(String content) throws IOException {
if (content == null || content.length() == 0)
return;
writeXMLContent(content.toCharArray(), 0, content.length());
}
public void writeXMLAttributeValue(String value) throws IOException {
writeXMLContent(value.toCharArray(), 0, value.length(), true);
}
private CharsetEncoder getDefaultEncoder() {
try {
String encoding = System.getProperty("file.encoding");
if (encoding != null)
return Charset.forName(encoding).newEncoder();
} catch (Exception ex) {}
return null;
}
}

View file

@ -0,0 +1,429 @@
package com.sun.xml.stream.writers;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMResult;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.xml.sax.helpers.NamespaceSupport;
public class XMLDOMWriterImpl implements XMLStreamWriter {
private Document ownerDoc = null;
private Node currentNode = null;
private Node node = null;
private NamespaceSupport namespaceContext = null;
private Method mXmlVersion = null;
private boolean[] needContextPop = null;
private StringBuffer stringBuffer = null;
private int resizeValue = 20;
private int depth = 0;
public XMLDOMWriterImpl(DOMResult result) {
this.node = result.getNode();
if (this.node.getNodeType() == 9) {
this.ownerDoc = (Document)this.node;
} else {
this.ownerDoc = this.node.getOwnerDocument();
this.currentNode = this.node;
}
getDLThreeMethods();
this.stringBuffer = new StringBuffer();
this.needContextPop = new boolean[this.resizeValue];
this.namespaceContext = new NamespaceSupport();
}
private void getDLThreeMethods() {
try {
this.mXmlVersion = this.ownerDoc.getClass().getMethod("setXmlVersion", String.class);
} catch (NoSuchMethodException mex) {
this.mXmlVersion = null;
} catch (SecurityException se) {
this.mXmlVersion = null;
}
}
public void close() throws XMLStreamException {}
public void flush() throws XMLStreamException {}
public NamespaceContext getNamespaceContext() {
return null;
}
public String getPrefix(String namespaceURI) throws XMLStreamException {
String prefix = null;
if (this.namespaceContext != null)
prefix = this.namespaceContext.getPrefix(namespaceURI);
return prefix;
}
public Object getProperty(String str) throws IllegalArgumentException {
throw new UnsupportedOperationException();
}
public void setDefaultNamespace(String uri) throws XMLStreamException {
this.namespaceContext.declarePrefix("", uri);
if (!this.needContextPop[this.depth])
this.needContextPop[this.depth] = true;
}
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException {
throw new UnsupportedOperationException();
}
public void setPrefix(String prefix, String uri) throws XMLStreamException {
if (prefix == null)
throw new XMLStreamException("Prefix cannot be null");
this.namespaceContext.declarePrefix(prefix, uri);
if (!this.needContextPop[this.depth])
this.needContextPop[this.depth] = true;
}
public void writeAttribute(String localName, String value) throws XMLStreamException {
if (this.currentNode.getNodeType() == 1) {
Attr attr = this.ownerDoc.createAttribute(localName);
attr.setValue(value);
((Element)this.currentNode).setAttributeNode(attr);
} else {
throw new IllegalStateException("Current DOM Node type is " + this.currentNode.getNodeType() + "and does not allow attributes to be set ");
}
}
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
if (this.currentNode.getNodeType() == 1) {
String prefix = null;
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (this.namespaceContext != null)
prefix = this.namespaceContext.getPrefix(namespaceURI);
if (prefix == null)
throw new XMLStreamException("Namespace URI " + namespaceURI + "is not bound to any prefix");
String qualifiedName = null;
if (prefix.equals("")) {
qualifiedName = localName;
} else {
qualifiedName = getQName(prefix, localName);
}
Attr attr = this.ownerDoc.createAttributeNS(namespaceURI, qualifiedName);
attr.setValue(value);
((Element)this.currentNode).setAttributeNode(attr);
} else {
throw new IllegalStateException("Current DOM Node type is " + this.currentNode.getNodeType() + "and does not allow attributes to be set ");
}
}
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
if (this.currentNode.getNodeType() == 1) {
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (prefix == null)
throw new XMLStreamException("prefix cannot be null");
String qualifiedName = null;
if (prefix.equals("")) {
qualifiedName = localName;
} else {
qualifiedName = getQName(prefix, localName);
}
Attr attr = this.ownerDoc.createAttributeNS(namespaceURI, qualifiedName);
attr.setValue(value);
((Element)this.currentNode).setAttributeNodeNS(attr);
} else {
throw new IllegalStateException("Current DOM Node type is " + this.currentNode.getNodeType() + "and does not allow attributes to be set ");
}
}
public void writeCData(String data) throws XMLStreamException {
if (data == null)
throw new XMLStreamException("CDATA cannot be null");
CDATASection cdata = this.ownerDoc.createCDATASection(data);
getNode().appendChild(cdata);
}
public void writeCharacters(String charData) throws XMLStreamException {
Text text = this.ownerDoc.createTextNode(charData);
this.currentNode.appendChild(text);
}
public void writeCharacters(char[] values, int param, int param2) throws XMLStreamException {
Text text = this.ownerDoc.createTextNode(new String(values, param, param2));
this.currentNode.appendChild(text);
}
public void writeComment(String str) throws XMLStreamException {
Comment comment = this.ownerDoc.createComment(str);
getNode().appendChild(comment);
}
public void writeDTD(String str) throws XMLStreamException {
throw new UnsupportedOperationException();
}
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
if (this.currentNode.getNodeType() == 1) {
String qname = "xmlns";
((Element)this.currentNode).setAttributeNS("http://www.w3.org/2000/xmlns/", qname, namespaceURI);
} else {
throw new IllegalStateException("Current DOM Node type is " + this.currentNode.getNodeType() + "and does not allow attributes to be set ");
}
}
public void writeEmptyElement(String localName) throws XMLStreamException {
if (this.ownerDoc != null) {
Element element = this.ownerDoc.createElement(localName);
if (this.currentNode != null) {
this.currentNode.appendChild(element);
} else {
this.ownerDoc.appendChild(element);
}
}
}
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
if (this.ownerDoc != null) {
String qualifiedName = null;
String prefix = null;
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (this.namespaceContext != null)
prefix = this.namespaceContext.getPrefix(namespaceURI);
if (prefix == null)
throw new XMLStreamException("Namespace URI " + namespaceURI + "is not bound to any prefix");
if ("".equals(prefix)) {
qualifiedName = localName;
} else {
qualifiedName = getQName(prefix, localName);
}
Element element = this.ownerDoc.createElementNS(namespaceURI, qualifiedName);
if (this.currentNode != null) {
this.currentNode.appendChild(element);
} else {
this.ownerDoc.appendChild(element);
}
}
}
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
if (this.ownerDoc != null) {
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (prefix == null)
throw new XMLStreamException("Prefix cannot be null");
String qualifiedName = null;
if ("".equals(prefix)) {
qualifiedName = localName;
} else {
qualifiedName = getQName(prefix, localName);
}
Element el = this.ownerDoc.createElementNS(namespaceURI, qualifiedName);
if (this.currentNode != null) {
this.currentNode.appendChild(el);
} else {
this.ownerDoc.appendChild(el);
}
}
}
public void writeEndDocument() throws XMLStreamException {
this.currentNode = null;
for (int i = 0; i < this.depth; i++) {
if (this.needContextPop[this.depth]) {
this.needContextPop[this.depth] = false;
this.namespaceContext.popContext();
}
this.depth--;
}
this.depth = 0;
}
public void writeEndElement() throws XMLStreamException {
Node node = this.currentNode.getParentNode();
if (this.currentNode.getNodeType() == 9) {
this.currentNode = null;
} else {
this.currentNode = node;
}
if (this.needContextPop[this.depth]) {
this.needContextPop[this.depth] = false;
this.namespaceContext.popContext();
}
this.depth--;
}
public void writeEntityRef(String name) throws XMLStreamException {
EntityReference er = this.ownerDoc.createEntityReference(name);
this.currentNode.appendChild(er);
}
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (prefix == null)
throw new XMLStreamException("prefix cannot be null");
String qname = null;
if (prefix == null || prefix.equals("")) {
qname = "xmlns";
} else {
qname = getQName("xmlns", prefix);
}
((Element)this.currentNode).setAttributeNS("http://www.w3.org/2000/xmlns/", qname, namespaceURI);
}
public void writeProcessingInstruction(String target) throws XMLStreamException {
if (target == null)
throw new XMLStreamException("Target cannot be null");
ProcessingInstruction pi = this.ownerDoc.createProcessingInstruction(target, "");
this.currentNode.appendChild(pi);
}
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
if (target == null)
throw new XMLStreamException("Target cannot be null");
ProcessingInstruction pi = this.ownerDoc.createProcessingInstruction(target, data);
this.currentNode.appendChild(pi);
}
public void writeStartDocument() throws XMLStreamException {
try {
if (this.mXmlVersion != null)
this.mXmlVersion.invoke(this.ownerDoc, "1.0");
} catch (IllegalAccessException iae) {
throw new XMLStreamException(iae);
} catch (InvocationTargetException ite) {
throw new XMLStreamException(ite);
}
}
public void writeStartDocument(String version) throws XMLStreamException {
try {
if (this.mXmlVersion != null)
this.mXmlVersion.invoke(this.ownerDoc, version);
} catch (IllegalAccessException iae) {
throw new XMLStreamException(iae);
} catch (InvocationTargetException ite) {
throw new XMLStreamException(ite);
}
}
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
try {
if (this.mXmlVersion != null)
this.mXmlVersion.invoke(this.ownerDoc, version);
} catch (IllegalAccessException iae) {
throw new XMLStreamException(iae);
} catch (InvocationTargetException ite) {
throw new XMLStreamException(ite);
}
}
public void writeStartElement(String localName) throws XMLStreamException {
if (this.ownerDoc != null) {
Element element = this.ownerDoc.createElement(localName);
if (this.currentNode != null) {
this.currentNode.appendChild(element);
} else {
this.ownerDoc.appendChild(element);
}
this.currentNode = element;
}
if (this.needContextPop[this.depth])
this.namespaceContext.pushContext();
this.depth++;
}
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
if (this.ownerDoc != null) {
String qualifiedName = null;
String prefix = null;
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (this.namespaceContext != null)
prefix = this.namespaceContext.getPrefix(namespaceURI);
if (prefix == null)
throw new XMLStreamException("Namespace URI " + namespaceURI + "is not bound to any prefix");
if ("".equals(prefix)) {
qualifiedName = localName;
} else {
qualifiedName = getQName(prefix, localName);
}
Element element = this.ownerDoc.createElementNS(namespaceURI, qualifiedName);
if (this.currentNode != null) {
this.currentNode.appendChild(element);
} else {
this.ownerDoc.appendChild(element);
}
this.currentNode = element;
}
if (this.needContextPop[this.depth])
this.namespaceContext.pushContext();
this.depth++;
}
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
if (this.ownerDoc != null) {
String qname = null;
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (prefix == null)
throw new XMLStreamException("Prefix cannot be null");
if (prefix.equals("")) {
qname = localName;
} else {
qname = getQName(prefix, localName);
}
Element el = this.ownerDoc.createElementNS(namespaceURI, qname);
if (this.currentNode != null) {
this.currentNode.appendChild(el);
} else {
this.ownerDoc.appendChild(el);
}
this.currentNode = el;
if (this.needContextPop[this.depth])
this.namespaceContext.pushContext();
this.depth++;
}
}
private String getQName(String prefix, String localName) {
this.stringBuffer.setLength(0);
this.stringBuffer.append(prefix);
this.stringBuffer.append(":");
this.stringBuffer.append(localName);
return this.stringBuffer.toString();
}
private Node getNode() {
if (this.currentNode == null)
return this.ownerDoc;
return this.currentNode;
}
}

View file

@ -0,0 +1,147 @@
package com.sun.xml.stream.writers;
import java.util.Iterator;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.Comment;
import javax.xml.stream.events.DTD;
import javax.xml.stream.events.EntityReference;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.ProcessingInstruction;
import javax.xml.stream.events.StartDocument;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
public class XMLEventWriterImpl implements XMLEventWriter {
private XMLStreamWriter fStreamWriter;
private static final boolean DEBUG = false;
public XMLEventWriterImpl(XMLStreamWriter streamWriter) {
this.fStreamWriter = streamWriter;
}
public void add(XMLEventReader xMLEventReader) throws XMLStreamException {
if (xMLEventReader == null)
throw new XMLStreamException("Event reader shouldn't be null");
while (xMLEventReader.hasNext())
add(xMLEventReader.nextEvent());
}
public void add(XMLEvent xMLEvent) throws XMLStreamException {
DTD dtd;
StartDocument startDocument;
StartElement startElement;
Namespace namespace;
Comment comment;
ProcessingInstruction processingInstruction;
Characters characters1;
EntityReference entityReference;
Attribute attribute;
Characters characters;
QName qname;
Iterator<Namespace> iterator;
Iterator<Attribute> attributes;
int type = xMLEvent.getEventType();
switch (type) {
case 11:
dtd = (DTD)xMLEvent;
this.fStreamWriter.writeDTD(dtd.getDocumentTypeDeclaration());
break;
case 7:
startDocument = (StartDocument)xMLEvent;
this.fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), startDocument.getVersion());
break;
case 1:
startElement = xMLEvent.asStartElement();
qname = startElement.getName();
this.fStreamWriter.writeStartElement(qname.getPrefix(), qname.getLocalPart(), qname.getNamespaceURI());
iterator = startElement.getNamespaces();
while (iterator.hasNext()) {
Namespace namespace1 = iterator.next();
this.fStreamWriter.writeNamespace(namespace1.getPrefix(), namespace1.getNamespaceURI());
}
attributes = startElement.getAttributes();
while (attributes.hasNext()) {
Attribute attribute1 = attributes.next();
QName aqname = attribute1.getName();
this.fStreamWriter.writeAttribute(aqname.getPrefix(), aqname.getNamespaceURI(), aqname.getLocalPart(), attribute1.getValue());
}
break;
case 13:
namespace = (Namespace)xMLEvent;
this.fStreamWriter.writeNamespace(namespace.getPrefix(), namespace.getNamespaceURI());
break;
case 5:
comment = (Comment)xMLEvent;
this.fStreamWriter.writeComment(comment.getText());
break;
case 3:
processingInstruction = (ProcessingInstruction)xMLEvent;
this.fStreamWriter.writeProcessingInstruction(processingInstruction.getTarget(), processingInstruction.getData());
break;
case 4:
characters1 = xMLEvent.asCharacters();
if (characters1.isCData()) {
this.fStreamWriter.writeCData(characters1.getData());
} else {
this.fStreamWriter.writeCharacters(characters1.getData());
}
break;
case 9:
entityReference = (EntityReference)xMLEvent;
this.fStreamWriter.writeEntityRef(entityReference.getName());
break;
case 10:
attribute = (Attribute)xMLEvent;
qname = attribute.getName();
this.fStreamWriter.writeAttribute(qname.getPrefix(), qname.getNamespaceURI(), qname.getLocalPart(), attribute.getValue());
break;
case 12:
characters = (Characters)xMLEvent;
if (characters.isCData())
this.fStreamWriter.writeCData(characters.getData());
break;
case 2:
this.fStreamWriter.writeEndElement();
break;
case 8:
this.fStreamWriter.writeEndDocument();
break;
}
}
public void close() throws XMLStreamException {
this.fStreamWriter.close();
}
public void flush() throws XMLStreamException {
this.fStreamWriter.flush();
}
public NamespaceContext getNamespaceContext() {
return this.fStreamWriter.getNamespaceContext();
}
public String getPrefix(String namespaceURI) throws XMLStreamException {
return this.fStreamWriter.getPrefix(namespaceURI);
}
public void setDefaultNamespace(String uri) throws XMLStreamException {
this.fStreamWriter.setDefaultNamespace(uri);
}
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException {
this.fStreamWriter.setNamespaceContext(namespaceContext);
}
public void setPrefix(String prefix, String uri) throws XMLStreamException {
this.fStreamWriter.setPrefix(prefix, uri);
}
}

View file

@ -0,0 +1,993 @@
package com.sun.xml.stream.writers;
import com.sun.xml.stream.PropertyManager;
import com.sun.xml.stream.util.ReadOnlyIterator;
import com.sun.xml.stream.xerces.util.NamespaceSupport;
import com.sun.xml.stream.xerces.util.SymbolTable;
import com.sun.xml.stream.xerces.xni.QName;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import java.util.Vector;
import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
public class XMLStreamWriterImpl extends WriterUtility implements XMLStreamWriter {
private OutputStream fOutputStream;
private String fEncoding;
private ElementStack fElementStack = new ElementStack();
private boolean fStartTagOpened = false;
private ElementState fCurrentElementState = null;
private ElementState fillElementState = null;
private NamespaceSupport fInternalNamespaceContext = null;
private boolean fIsRepairingNamespace = false;
private ArrayList fNamespaceDecls = null;
private Random fPrefixGen = null;
private PropertyManager fPropertyManager = null;
private SymbolTable fSymbolTable = new SymbolTable();
private ArrayList fAttributeCache = null;
private String DEFAULT_PREFIX = null;
private static final boolean DEBUG = false;
private NamespaceContextImpl fNamespaceContext = null;
private static ReadOnlyIterator fReadOnlyIterator = new ReadOnlyIterator();
public XMLStreamWriterImpl(OutputStream outputStream, PropertyManager props) {
this.fOutputStream = outputStream;
this.fWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
this.fPropertyManager = props;
init();
}
public XMLStreamWriterImpl(OutputStream outputStream, String encoding, PropertyManager props) throws UnsupportedEncodingException {
this.fOutputStream = outputStream;
this.fEncoding = encoding;
this.fWriter = new BufferedWriter(new OutputStreamWriter(outputStream, encoding));
this.fPropertyManager = props;
init();
}
public XMLStreamWriterImpl(Writer writer, PropertyManager props) {
this.fWriter = writer;
this.fPropertyManager = props;
init();
}
private void init() {
this.fPropertyManager.setProperty("http://apache.org/xml/properties/internal/symbol-table", this.fSymbolTable);
this.fNamespaceDecls = new ArrayList();
this.fPrefixGen = new Random();
if (this.fPropertyManager != null) {
Boolean ob = (Boolean)this.fPropertyManager.getProperty("javax.xml.stream.isRepairingNamespaces");
this.fIsRepairingNamespace = ob;
ob = (Boolean)this.fPropertyManager.getProperty("escapeCharacters");
setEscapeCharacters(ob.booleanValue());
}
this.fAttributeCache = new ArrayList();
this.fInternalNamespaceContext = new NamespaceSupport();
this.fInternalNamespaceContext.reset();
this.fNamespaceContext = new NamespaceContextImpl();
this.fNamespaceContext.internalContext = this.fInternalNamespaceContext;
this.DEFAULT_PREFIX = this.fSymbolTable.addSymbol("");
this.fillElementState = new ElementState();
}
public void close() throws XMLStreamException {
try {
this.fWriter.close();
} catch (IOException ioexception) {
throw new XMLStreamException(ioexception);
}
}
public void flush() throws XMLStreamException {
try {
this.fWriter.flush();
} catch (IOException ioexception) {
throw new XMLStreamException(ioexception);
}
}
public NamespaceContext getNamespaceContext() {
return this.fNamespaceContext;
}
public String getPrefix(String uri) throws XMLStreamException {
return this.fNamespaceContext.getPrefix(uri);
}
public Object getProperty(String str) throws IllegalArgumentException {
if (str == null)
throw new NullPointerException();
if (!this.fPropertyManager.containsProperty(str))
throw new IllegalArgumentException(str + " is not supported");
return this.fPropertyManager.getProperty(str);
}
public void setDefaultNamespace(String uri) throws XMLStreamException {
if (uri != null)
uri = this.fSymbolTable.addSymbol(uri);
if (this.fIsRepairingNamespace) {
if (isDefaultNamespace(uri))
return;
QName qname = new QName();
qname.setValues(this.DEFAULT_PREFIX, "xmlns", null, uri);
this.fNamespaceDecls.add(qname);
return;
}
this.fInternalNamespaceContext.declarePrefix(this.DEFAULT_PREFIX, uri);
}
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException {
this.fNamespaceContext.userContext = namespaceContext;
}
public void setPrefix(String prefix, String uri) throws XMLStreamException {
if (prefix == null)
throw new XMLStreamException("Prefix cannot be null");
if (uri == null)
throw new XMLStreamException("URI cannot be null");
prefix = this.fSymbolTable.addSymbol(prefix);
uri = this.fSymbolTable.addSymbol(uri);
if (this.fIsRepairingNamespace) {
String tmpURI = this.fInternalNamespaceContext.getURI(prefix);
if (tmpURI != null && tmpURI == uri)
return;
if (checkUserNamespaceContext(prefix, uri))
return;
QName qname = new QName();
qname.setValues(prefix, "xmlns", null, uri);
this.fNamespaceDecls.add(qname);
return;
}
this.fInternalNamespaceContext.declarePrefix(prefix, uri);
}
public void writeAttribute(String localName, String value) throws XMLStreamException {
try {
if (!this.fStartTagOpened)
throw new XMLStreamException("Attribute not associated with any element");
if (this.fIsRepairingNamespace) {
Attribute attr = new Attribute(value);
attr.setValues(null, localName, null, null);
this.fAttributeCache.add(attr);
return;
}
this.fWriter.write(" ");
this.fWriter.write(localName);
this.fWriter.write("=");
this.fWriter.write("\"");
writeXMLAttributeValue(value);
this.fWriter.write("\"");
} catch (IOException ie) {
throw new XMLStreamException(ie);
}
}
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
try {
if (!this.fStartTagOpened)
throw new XMLStreamException("Attribute not associated with any element");
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
String prefix = this.fInternalNamespaceContext.getPrefix(namespaceURI);
if (!this.fIsRepairingNamespace) {
if (prefix == null)
throw new XMLStreamException("Prefix cannot be null");
} else {
Attribute attr = new Attribute(value);
attr.setValues(null, localName, null, namespaceURI);
this.fAttributeCache.add(attr);
return;
}
writeAttributeWithPrefix(prefix, localName, value);
} catch (IOException ie) {
throw new XMLStreamException(ie);
}
}
private void writeAttributeWithPrefix(String prefix, String localName, String value) throws IOException {
this.fWriter.write(" ");
if (prefix != null && prefix != "") {
this.fWriter.write(prefix);
this.fWriter.write(":");
}
this.fWriter.write(localName);
this.fWriter.write("=");
this.fWriter.write("\"");
writeXMLAttributeValue(value);
this.fWriter.write("\"");
}
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
try {
if (!this.fStartTagOpened)
throw new XMLStreamException("Attribute not associated with any element");
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (localName == null)
throw new XMLStreamException("Local name cannot be null");
if (!this.fIsRepairingNamespace) {
if (prefix == null)
throw new XMLStreamException("prefix cannot be null");
} else {
if (prefix != null)
prefix = this.fSymbolTable.addSymbol(prefix);
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
Attribute attr = new Attribute(value);
attr.setValues(prefix, localName, null, namespaceURI);
this.fAttributeCache.add(attr);
return;
}
writeAttributeWithPrefix(prefix, localName, value);
} catch (IOException ie) {
throw new XMLStreamException(ie);
}
}
public void writeCData(String cdata) throws XMLStreamException {
try {
if (cdata == null)
throw new XMLStreamException("cdata cannot be null");
if (this.fStartTagOpened)
closeStartTag();
this.fWriter.write("<![CDATA[");
this.fWriter.write(cdata);
this.fWriter.write("]]>");
} catch (IOException ie) {
throw new XMLStreamException(ie);
}
}
public void writeCharacters(String data) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
writeXMLContent(data);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeCharacters(char[] data, int start, int len) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
writeXMLContent(data, start, len);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeComment(String comment) throws XMLStreamException {
try {
this.fWriter.write("<!--");
if (comment != null)
this.fWriter.write(comment);
this.fWriter.write("-->");
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeDTD(String dtd) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
this.fWriter.write(dtd);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeDefaultNamespace(String uri) throws XMLStreamException {
try {
if (!this.fStartTagOpened)
throw new XMLStreamException("Namespace Attribute not associated with any element");
if (this.fIsRepairingNamespace) {
QName qname = new QName();
qname.setValues("", "xmlns", null, uri);
this.fNamespaceDecls.add(qname);
return;
}
this.fWriter.write(" ");
this.fWriter.write("xmlns");
this.fWriter.write("=");
this.fWriter.write("\"");
this.fWriter.write(uri);
this.fWriter.write("\"");
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeEmptyElement(String localName) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
openStartTag();
this.fElementStack.push(null, localName, null, null, true);
this.fInternalNamespaceContext.pushContext();
if (this.fIsRepairingNamespace)
return;
this.fWriter.write(localName);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
String prefix = this.fNamespaceContext.getPrefix(namespaceURI);
writeEmptyElement(prefix, localName, namespaceURI);
}
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
try {
if (localName == null)
throw new XMLStreamException("Local Name cannot be null");
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (prefix != null)
prefix = this.fSymbolTable.addSymbol(prefix);
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
if (this.fStartTagOpened)
closeStartTag();
openStartTag();
this.fElementStack.push(prefix, localName, null, namespaceURI, true);
this.fInternalNamespaceContext.pushContext();
if (!this.fIsRepairingNamespace) {
if (prefix == null)
throw new XMLStreamException("NamespaceURI " + namespaceURI + " has not been bound to any prefix");
} else {
return;
}
if (prefix != null && prefix != "") {
this.fWriter.write(prefix);
this.fWriter.write(":");
}
this.fWriter.write(localName);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeEndDocument() throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
ElementState elem = null;
while (!this.fElementStack.empty()) {
elem = this.fElementStack.pop();
this.fInternalNamespaceContext.popContext();
if (elem.isEmpty)
continue;
this.fWriter.write("</");
if (elem.prefix != null && !elem.prefix.equals("")) {
this.fWriter.write(elem.prefix);
this.fWriter.write(":");
}
this.fWriter.write(elem.localpart);
this.fWriter.write(62);
}
} catch (IOException ie) {
throw new XMLStreamException(ie);
} catch (ArrayIndexOutOfBoundsException ae) {
throw new XMLStreamException("No more elements to write");
}
}
public void writeEndElement() throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
this.fCurrentElementState = this.fElementStack.pop();
if (this.fCurrentElementState == null)
throw new XMLStreamException("No element was found to write");
if (this.fCurrentElementState.isEmpty)
return;
this.fWriter.write("</");
if (this.fCurrentElementState.prefix != null && !this.fCurrentElementState.prefix.equals("")) {
this.fWriter.write(this.fCurrentElementState.prefix);
this.fWriter.write(":");
}
this.fWriter.write(this.fCurrentElementState.localpart);
this.fWriter.write(62);
this.fInternalNamespaceContext.popContext();
} catch (IOException ie) {
throw new XMLStreamException(ie);
} catch (ArrayIndexOutOfBoundsException ae) {
throw new XMLStreamException("No element was found to write");
}
}
public void writeEntityRef(String refName) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
this.fWriter.write(38);
this.fWriter.write(refName);
this.fWriter.write(59);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
try {
QName qname = null;
if (!this.fStartTagOpened)
throw new XMLStreamException("Namespace Attribute not associated with any element");
if (prefix == null || prefix.equals("")) {
writeDefaultNamespace(namespaceURI);
return;
}
if (namespaceURI == null)
throw new XMLStreamException("Namespace`uri cannot be null");
prefix = this.fSymbolTable.addSymbol(prefix);
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
if (this.fIsRepairingNamespace) {
String tmpURI = this.fInternalNamespaceContext.getURI(prefix);
if (tmpURI != null && tmpURI == namespaceURI)
return;
qname = new QName();
qname.setValues(prefix, "xmlns", null, namespaceURI);
this.fNamespaceDecls.add(qname);
return;
}
String tmp = this.fInternalNamespaceContext.getURI(prefix);
if (tmp == null || tmp == namespaceURI)
this.fInternalNamespaceContext.declarePrefix(prefix, namespaceURI);
writenamespace(prefix, namespaceURI);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
private void writenamespace(String prefix, String namespaceURI) throws IOException {
this.fWriter.write(" ");
this.fWriter.write("xmlns");
if (prefix != null && prefix != "") {
this.fWriter.write(":");
this.fWriter.write(prefix);
}
this.fWriter.write("=");
this.fWriter.write("\"");
this.fWriter.write(namespaceURI);
this.fWriter.write("\"");
}
public void writeProcessingInstruction(String target) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
if (target != null) {
this.fWriter.write("<?");
this.fWriter.write(target);
this.fWriter.write("?>");
return;
}
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
throw new XMLStreamException("PI target cannot be null");
}
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
try {
if (this.fStartTagOpened)
closeStartTag();
if (target == null || data == null)
throw new XMLStreamException("PI target cannot be null");
this.fWriter.write("<?");
this.fWriter.write(target);
this.fWriter.write(" ");
this.fWriter.write(data);
this.fWriter.write("?>");
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeStartDocument() throws XMLStreamException {
try {
this.fWriter.write("<?xml version=\"1.0\" ?>");
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeStartDocument(String version) throws XMLStreamException {
try {
if (version == null || version.equals("")) {
writeStartDocument();
return;
}
this.fWriter.write("<?xml version=\"");
this.fWriter.write(version);
this.fWriter.write("\"");
this.fWriter.write("?>");
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
try {
if (encoding == null && version == null) {
writeStartDocument();
return;
}
if (encoding == null) {
writeStartDocument(version);
return;
}
this.fWriter.write("<?xml version=\"");
if (version == null || version.equals("")) {
this.fWriter.write("1.0");
} else {
this.fWriter.write(version);
}
if (!encoding.equals("")) {
this.fWriter.write("\" encoding=\"");
this.fWriter.write(encoding);
}
this.fWriter.write(34);
this.fWriter.write("?>");
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeStartElement(String localName) throws XMLStreamException {
try {
if (localName == null)
throw new XMLStreamException("Local Name cannot be null");
if (this.fStartTagOpened)
closeStartTag();
openStartTag();
this.fElementStack.push(null, localName, null, null, false);
this.fInternalNamespaceContext.pushContext();
if (this.fIsRepairingNamespace)
return;
this.fWriter.write(localName);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
if (localName == null)
throw new XMLStreamException("Local Name cannot be null");
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
String prefix = null;
if (!this.fIsRepairingNamespace) {
prefix = this.fNamespaceContext.getPrefix(namespaceURI);
if (prefix != null)
prefix = this.fSymbolTable.addSymbol(prefix);
}
writeStartElement(prefix, localName, namespaceURI);
}
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
try {
if (localName == null)
throw new XMLStreamException("Local Name cannot be null");
if (namespaceURI == null)
throw new XMLStreamException("NamespaceURI cannot be null");
if (!this.fIsRepairingNamespace &&
prefix == null)
throw new XMLStreamException("Prefix cannot be null");
if (this.fStartTagOpened)
closeStartTag();
openStartTag();
namespaceURI = this.fSymbolTable.addSymbol(namespaceURI);
if (prefix != null)
prefix = this.fSymbolTable.addSymbol(prefix);
this.fElementStack.push(prefix, localName, null, namespaceURI, false);
this.fInternalNamespaceContext.pushContext();
String tmpPrefix = this.fNamespaceContext.getPrefix(namespaceURI);
if (prefix != null && (tmpPrefix == null || !prefix.equals(tmpPrefix)))
this.fInternalNamespaceContext.declarePrefix(prefix, namespaceURI);
if (this.fIsRepairingNamespace) {
if (prefix == null || (tmpPrefix != null && prefix.equals(tmpPrefix)))
return;
QName qname = new QName();
qname.setValues(prefix, "xmlns", null, namespaceURI);
this.fNamespaceDecls.add(qname);
return;
}
if (prefix != null && prefix != "") {
this.fWriter.write(prefix);
this.fWriter.write(":");
}
this.fWriter.write(localName);
} catch (IOException ex) {
throw new XMLStreamException(ex);
}
}
private void closeStartTag() throws XMLStreamException {
try {
this.fCurrentElementState = this.fElementStack.peek();
if (this.fIsRepairingNamespace) {
repair();
correctPrefix(this.fCurrentElementState);
if (this.fCurrentElementState.prefix != null && this.fCurrentElementState.prefix != "") {
this.fWriter.write(this.fCurrentElementState.prefix);
this.fWriter.write(":");
}
this.fWriter.write(this.fCurrentElementState.localpart);
int len = this.fNamespaceDecls.size();
QName qname = null;
for (int i = 0; i < len; i++) {
qname = this.fNamespaceDecls.get(i);
if (qname != null) {
this.fInternalNamespaceContext.declarePrefix(qname.prefix, qname.uri);
writenamespace(qname.prefix, qname.uri);
}
}
this.fNamespaceDecls.clear();
Attribute attr = null;
for (int j = 0; j < this.fAttributeCache.size(); j++) {
attr = this.fAttributeCache.get(j);
if (attr.prefix != null && attr.uri != null) {
String tmp = this.fInternalNamespaceContext.getPrefix(attr.uri);
if (tmp == null || tmp != attr.prefix) {
this.fInternalNamespaceContext.declarePrefix(attr.prefix, attr.uri);
writenamespace(attr.prefix, attr.uri);
}
}
writeAttributeWithPrefix(attr.prefix, attr.localpart, attr.value);
}
this.fAttributeCache.clear();
}
if (this.fCurrentElementState.isEmpty) {
this.fElementStack.pop();
this.fWriter.write("/>");
} else {
this.fWriter.write(62);
}
this.fStartTagOpened = false;
} catch (IOException ex) {
this.fStartTagOpened = false;
throw new XMLStreamException(ex);
}
}
private void openStartTag() throws IOException {
this.fStartTagOpened = true;
this.fWriter.write(60);
}
private void correctPrefix(QName attr) {
String tmpPrefix = null;
String prefix = attr.prefix;
String uri = attr.uri;
if (prefix == null) {
if (uri == null)
return;
uri = this.fSymbolTable.addSymbol(uri);
QName decl = null;
for (int i = 0; i < this.fNamespaceDecls.size(); i++) {
decl = this.fNamespaceDecls.get(i);
if (decl != null && decl.uri == attr.uri) {
attr.prefix = decl.prefix;
return;
}
}
tmpPrefix = this.fNamespaceContext.getPrefix(uri);
if (tmpPrefix == "")
return;
if (tmpPrefix == null) {
StringBuffer genPrefix = new StringBuffer("zdef");
for (int j = 0; j < 1; j++)
genPrefix.append(this.fPrefixGen.nextInt());
prefix = genPrefix.toString();
prefix = this.fSymbolTable.addSymbol(prefix);
} else {
prefix = this.fSymbolTable.addSymbol(tmpPrefix);
}
if (tmpPrefix == null) {
QName qname = new QName();
qname.setValues(prefix, "xmlns", null, uri);
this.fNamespaceDecls.add(qname);
this.fInternalNamespaceContext.declarePrefix(this.fSymbolTable.addSymbol(prefix), uri);
}
}
attr.prefix = prefix;
}
private boolean isDefaultNamespace(String uri) {
String defaultNamespace = this.fInternalNamespaceContext.getURI(this.DEFAULT_PREFIX);
if (uri == defaultNamespace)
return true;
return false;
}
private boolean checkUserNamespaceContext(String prefix, String uri) {
if (this.fNamespaceContext.userContext != null) {
String tmpURI = this.fNamespaceContext.userContext.getNamespaceURI(prefix);
if (tmpURI != null && tmpURI.equals(uri))
return true;
}
return false;
}
protected void repair() {
Attribute attr = null;
Attribute attr2 = null;
this.fCurrentElementState = this.fElementStack.peek();
removeDuplicateDecls();
int i;
for (i = 0; i < this.fAttributeCache.size(); i++) {
attr = this.fAttributeCache.get(i);
if (attr.prefix != null && this.fCurrentElementState.prefix != null)
correctPrefix(this.fCurrentElementState, attr);
}
if (!isDeclared(this.fCurrentElementState) &&
this.fCurrentElementState.prefix != null && this.fCurrentElementState.uri != null)
this.fNamespaceDecls.add(this.fCurrentElementState);
for (i = 0; i < this.fAttributeCache.size(); i++) {
attr = this.fAttributeCache.get(i);
for (int j = i + 1; j < this.fAttributeCache.size(); j++) {
attr2 = this.fAttributeCache.get(j);
if (attr.prefix == null && attr2.prefix != null)
correctPrefix(attr, attr2);
}
}
repairNamespaceDecl(this.fCurrentElementState);
i = 0;
for (i = 0; i < this.fAttributeCache.size(); i++) {
attr = this.fAttributeCache.get(i);
repairNamespaceDecl(attr);
}
QName qname = null;
for (i = 0; i < this.fNamespaceDecls.size(); i++) {
qname = this.fNamespaceDecls.get(i);
if (qname != null)
this.fInternalNamespaceContext.declarePrefix(qname.prefix, qname.uri);
}
for (i = 0; i < this.fAttributeCache.size(); i++) {
attr = this.fAttributeCache.get(i);
correctPrefix(attr);
}
}
void correctPrefix(QName attr1, QName attr2) {
String tmpPrefix = null;
QName decl = null;
boolean done = false;
if (attr1.prefix.equals(attr2.prefix) && !attr1.uri.equals(attr2.uri)) {
tmpPrefix = this.fNamespaceContext.getPrefix(attr2.uri);
if (tmpPrefix != null) {
attr2.prefix = this.fSymbolTable.addSymbol(tmpPrefix);
} else {
decl = null;
for (int n = 0; n < this.fNamespaceDecls.size(); n++) {
decl = this.fNamespaceDecls.get(n);
if (decl.uri == attr2.uri) {
attr2.prefix = decl.prefix;
return;
}
}
StringBuffer genPrefix = new StringBuffer("zdef");
for (int k = 0; k < 1; k++)
genPrefix.append(this.fPrefixGen.nextInt());
tmpPrefix = genPrefix.toString();
tmpPrefix = this.fSymbolTable.addSymbol(tmpPrefix);
attr2.prefix = tmpPrefix;
QName qname = new QName();
qname.setValues(tmpPrefix, "xmlns", null, attr2.uri);
this.fNamespaceDecls.add(qname);
}
}
}
void removeDuplicateDecls() {
for (int i = 0; i < this.fNamespaceDecls.size(); i++) {
QName decl1 = this.fNamespaceDecls.get(i);
for (int j = i + 1; j < this.fNamespaceDecls.size(); j++) {
QName decl2 = this.fNamespaceDecls.get(j);
if (decl1 != null && decl1.equals(decl2))
this.fNamespaceDecls.set(j, null);
}
}
}
void repairNamespaceDecl(QName attr) {
QName decl = null;
for (int j = 0; j < this.fNamespaceDecls.size(); j++) {
decl = this.fNamespaceDecls.get(j);
if (decl != null &&
attr.prefix != null && attr.prefix.equals(decl.prefix) && !attr.uri.equals(decl.uri)) {
String tmpURI = this.fNamespaceContext.getNamespaceURI(attr.prefix);
if (tmpURI != null)
if (tmpURI.equals(attr.uri)) {
this.fNamespaceDecls.set(j, null);
} else {
decl.uri = attr.uri;
}
}
}
}
boolean isDeclared(QName attr) {
QName decl = null;
for (int n = 0; n < this.fNamespaceDecls.size(); n++) {
decl = this.fNamespaceDecls.get(n);
if (attr.prefix != null && attr.prefix == decl.prefix && decl.uri == attr.uri)
return true;
}
if (attr.uri != null &&
this.fNamespaceContext.getPrefix(attr.uri) != null)
return true;
return false;
}
protected class ElementStack {
protected XMLStreamWriterImpl.ElementState[] fElements = new XMLStreamWriterImpl.ElementState[10];
protected short fDepth;
public ElementStack() {
for (int i = 0; i < this.fElements.length; i++)
this.fElements[i] = new XMLStreamWriterImpl.ElementState();
}
public XMLStreamWriterImpl.ElementState push(XMLStreamWriterImpl.ElementState element) {
if (this.fDepth == this.fElements.length) {
XMLStreamWriterImpl.ElementState[] array = new XMLStreamWriterImpl.ElementState[this.fElements.length * 2];
System.arraycopy(this.fElements, 0, array, 0, this.fDepth);
this.fElements = array;
for (int i = this.fDepth; i < this.fElements.length; i++)
this.fElements[i] = new XMLStreamWriterImpl.ElementState();
}
this.fElements[this.fDepth].setValues(element);
this.fDepth = (short)(this.fDepth + 1);
return this.fElements[this.fDepth];
}
public XMLStreamWriterImpl.ElementState push(String prefix, String localpart, String rawname, String uri, boolean isEmpty) {
if (this.fDepth == this.fElements.length) {
XMLStreamWriterImpl.ElementState[] array = new XMLStreamWriterImpl.ElementState[this.fElements.length * 2];
System.arraycopy(this.fElements, 0, array, 0, this.fDepth);
this.fElements = array;
for (int i = this.fDepth; i < this.fElements.length; i++)
this.fElements[i] = new XMLStreamWriterImpl.ElementState();
}
this.fElements[this.fDepth].setValues(prefix, localpart, rawname, uri, isEmpty);
this.fDepth = (short)(this.fDepth + 1);
return this.fElements[this.fDepth];
}
public XMLStreamWriterImpl.ElementState pop() {
return this.fElements[this.fDepth = (short)(this.fDepth - 1)];
}
public void clear() {
this.fDepth = 0;
}
public XMLStreamWriterImpl.ElementState peek() {
return this.fElements[this.fDepth - 1];
}
public boolean empty() {
return !(this.fDepth > 0);
}
}
class ElementState extends QName {
public boolean isEmpty = false;
public ElementState() {}
public ElementState(String prefix, String localpart, String rawname, String uri) {
super(prefix, localpart, rawname, uri);
}
public void setValues(String prefix, String localpart, String rawname, String uri, boolean isEmpty) {
setValues(prefix, localpart, rawname, uri);
this.isEmpty = isEmpty;
}
}
class Attribute extends QName {
String value;
Attribute(String value) {
this.value = value;
}
}
class NamespaceContextImpl implements NamespaceContext {
NamespaceContext userContext = null;
NamespaceSupport internalContext = null;
public String getNamespaceURI(String prefix) {
String uri = null;
if (prefix != null)
prefix = XMLStreamWriterImpl.this.fSymbolTable.addSymbol(prefix);
if (this.internalContext != null) {
uri = this.internalContext.getURI(prefix);
if (uri != null)
return uri;
}
if (this.userContext != null) {
uri = this.userContext.getNamespaceURI(prefix);
return uri;
}
return null;
}
public String getPrefix(String uri) {
String prefix = null;
if (uri != null)
uri = XMLStreamWriterImpl.this.fSymbolTable.addSymbol(uri);
if (this.internalContext != null) {
prefix = this.internalContext.getPrefix(uri);
if (prefix != null)
return prefix;
}
if (this.userContext != null)
return this.userContext.getPrefix(uri);
return null;
}
public Iterator getPrefixes(String uri) {
Vector<String> prefixes = null;
Iterator<String> itr = null;
if (uri != null)
uri = XMLStreamWriterImpl.this.fSymbolTable.addSymbol(uri);
if (this.userContext != null)
itr = this.userContext.getPrefixes(uri);
if (this.internalContext != null)
prefixes = this.internalContext.getPrefixes(uri);
if (prefixes == null && itr != null)
return itr;
if (prefixes != null && itr == null)
return new ReadOnlyIterator(prefixes.iterator());
if (prefixes != null && itr != null) {
String ob = null;
while (itr.hasNext()) {
ob = itr.next();
if (ob != null)
ob = XMLStreamWriterImpl.this.fSymbolTable.addSymbol(ob);
if (!prefixes.contains(ob))
prefixes.add(ob);
}
return new ReadOnlyIterator(prefixes.iterator());
}
return XMLStreamWriterImpl.fReadOnlyIterator;
}
}
}

View file

@ -0,0 +1,74 @@
package com.sun.xml.stream.xerces.impl.io;
import com.sun.xml.stream.xerces.util.MessageFormatter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Locale;
public class ASCIIReader extends Reader {
public static final int DEFAULT_BUFFER_SIZE = 2048;
protected InputStream fInputStream;
protected byte[] fBuffer;
private MessageFormatter fFormatter = null;
private Locale fLocale = null;
public ASCIIReader(InputStream inputStream, MessageFormatter messageFormatter, Locale locale) {
this(inputStream, 2048, messageFormatter, locale);
}
public ASCIIReader(InputStream inputStream, int size, MessageFormatter messageFormatter, Locale locale) {
this.fInputStream = inputStream;
this.fBuffer = new byte[size];
this.fFormatter = messageFormatter;
this.fLocale = locale;
}
public int read() throws IOException {
int b0 = this.fInputStream.read();
if (b0 > 128)
throw new IOException(this.fFormatter.formatMessage(this.fLocale, "InvalidASCII", new Object[] { Integer.toString(b0) }));
return b0;
}
public int read(char[] ch, int offset, int length) throws IOException {
if (length > this.fBuffer.length)
length = this.fBuffer.length;
int count = this.fInputStream.read(this.fBuffer, 0, length);
for (int i = 0; i < count; i++) {
int b0 = this.fBuffer[i];
if (b0 > 128)
throw new IOException(this.fFormatter.formatMessage(this.fLocale, "InvalidASCII", new Object[] { Integer.toString(b0) }));
ch[offset + i] = (char)b0;
}
return count;
}
public long skip(long n) throws IOException {
return this.fInputStream.skip(n);
}
public boolean ready() throws IOException {
return false;
}
public boolean markSupported() {
return this.fInputStream.markSupported();
}
public void mark(int readAheadLimit) throws IOException {
this.fInputStream.mark(readAheadLimit);
}
public void reset() throws IOException {
this.fInputStream.reset();
}
public void close() throws IOException {
this.fInputStream.close();
}
}

View file

@ -0,0 +1,138 @@
package com.sun.xml.stream.xerces.impl.io;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
public class UCSReader extends Reader {
public static final int DEFAULT_BUFFER_SIZE = 8192;
public static final short UCS2LE = 1;
public static final short UCS2BE = 2;
public static final short UCS4LE = 4;
public static final short UCS4BE = 8;
protected InputStream fInputStream;
protected byte[] fBuffer;
protected short fEncoding;
public UCSReader(InputStream inputStream, short encoding) {
this(inputStream, 8192, encoding);
}
public UCSReader(InputStream inputStream, int size, short encoding) {
this.fInputStream = inputStream;
this.fBuffer = new byte[size];
this.fEncoding = encoding;
}
public int read() throws IOException {
int b0 = this.fInputStream.read() & 0xFF;
if (b0 == 255)
return -1;
int b1 = this.fInputStream.read() & 0xFF;
if (b1 == 255)
return -1;
if (this.fEncoding >= 4) {
int b2 = this.fInputStream.read() & 0xFF;
if (b2 == 255)
return -1;
int b3 = this.fInputStream.read() & 0xFF;
if (b3 == 255)
return -1;
System.err.println("b0 is " + (b0 & 0xFF) + " b1 " + (b1 & 0xFF) + " b2 " + (b2 & 0xFF) + " b3 " + (b3 & 0xFF));
if (this.fEncoding == 8)
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0;
}
if (this.fEncoding == 2)
return (b0 << 8) + b1;
return (b1 << 8) + b0;
}
public int read(char[] ch, int offset, int length) throws IOException {
int byteLength = length << ((this.fEncoding >= 4) ? 2 : 1);
if (byteLength > this.fBuffer.length)
byteLength = this.fBuffer.length;
int count = this.fInputStream.read(this.fBuffer, 0, byteLength);
if (count == -1)
return -1;
if (this.fEncoding >= 4) {
int numToRead = 4 - (count & 0x3) & 0x3;
for (int j = 0; j < numToRead; j++) {
int charRead = this.fInputStream.read();
if (charRead == -1) {
for (j = j; j < numToRead; j++)
this.fBuffer[count + j] = 0;
break;
}
this.fBuffer[count + j] = (byte)charRead;
}
count += numToRead;
} else {
int numToRead = count & 0x1;
if (numToRead != 0) {
count++;
int charRead = this.fInputStream.read();
if (charRead == -1) {
this.fBuffer[count] = 0;
} else {
this.fBuffer[count] = (byte)charRead;
}
}
}
int numChars = count >> ((this.fEncoding >= 4) ? 2 : 1);
int curPos = 0;
for (int i = 0; i < numChars; i++) {
int b0 = this.fBuffer[curPos++] & 0xFF;
int b1 = this.fBuffer[curPos++] & 0xFF;
if (this.fEncoding >= 4) {
int b2 = this.fBuffer[curPos++] & 0xFF;
int b3 = this.fBuffer[curPos++] & 0xFF;
if (this.fEncoding == 8) {
ch[offset + i] = (char)((b0 << 24) + (b1 << 16) + (b2 << 8) + b3);
} else {
ch[offset + i] = (char)((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);
}
} else if (this.fEncoding == 2) {
ch[offset + i] = (char)((b0 << 8) + b1);
} else {
ch[offset + i] = (char)((b1 << 8) + b0);
}
}
return numChars;
}
public long skip(long n) throws IOException {
int charWidth = (this.fEncoding >= 4) ? 2 : 1;
long bytesSkipped = this.fInputStream.skip(n << charWidth);
if ((bytesSkipped & (long)(charWidth | 0x1)) == 0L)
return bytesSkipped >> charWidth;
return (bytesSkipped >> charWidth) + 1L;
}
public boolean ready() throws IOException {
return false;
}
public boolean markSupported() {
return this.fInputStream.markSupported();
}
public void mark(int readAheadLimit) throws IOException {
this.fInputStream.mark(readAheadLimit);
}
public void reset() throws IOException {
this.fInputStream.reset();
}
public void close() throws IOException {
this.fInputStream.close();
}
}

View file

@ -0,0 +1,382 @@
package com.sun.xml.stream.xerces.impl.io;
import com.sun.xml.stream.xerces.impl.msg.XMLMessageFormatter;
import com.sun.xml.stream.xerces.util.MessageFormatter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.UTFDataFormatException;
import java.util.Locale;
public class UTF8Reader extends Reader {
public static final int DEFAULT_BUFFER_SIZE = 2048;
private static final boolean DEBUG_READ = false;
protected InputStream fInputStream;
protected byte[] fBuffer;
protected int fOffset;
private int fSurrogate = -1;
private MessageFormatter fFormatter = null;
private Locale fLocale = null;
public UTF8Reader(InputStream inputStream) {
this(inputStream, 2048, new XMLMessageFormatter(), Locale.getDefault());
}
public UTF8Reader(InputStream inputStream, MessageFormatter messageFormatter, Locale locale) {
this(inputStream, 2048, messageFormatter, locale);
}
public UTF8Reader(InputStream inputStream, int size, MessageFormatter messageFormatter, Locale locale) {
this.fInputStream = inputStream;
this.fBuffer = new byte[size];
this.fFormatter = messageFormatter;
this.fLocale = locale;
}
public int read() throws IOException {
int c = this.fSurrogate;
if (this.fSurrogate == -1) {
int index = 0;
int b0 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b0 == -1)
return -1;
if (b0 < 128) {
c = (char)b0;
} else if ((b0 & 0xE0) == 192) {
int b1 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b1 == -1)
expectedByte(2, 2);
if ((b1 & 0xC0) != 128)
invalidByte(2, 2, b1);
c = b0 << 6 & 0x7C0 | b1 & 0x3F;
} else if ((b0 & 0xF0) == 224) {
int b1 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b1 == -1)
expectedByte(2, 3);
if ((b1 & 0xC0) != 128)
invalidByte(2, 3, b1);
int b2 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b2 == -1)
expectedByte(3, 3);
if ((b2 & 0xC0) != 128)
invalidByte(3, 3, b2);
c = b0 << 12 & 0xF000 | b1 << 6 & 0xFC0 | b2 & 0x3F;
} else if ((b0 & 0xF8) == 240) {
int b1 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b1 == -1)
expectedByte(2, 4);
if ((b1 & 0xC0) != 128)
invalidByte(2, 3, b1);
int b2 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b2 == -1)
expectedByte(3, 4);
if ((b2 & 0xC0) != 128)
invalidByte(3, 3, b2);
int b3 = (index == this.fOffset) ? this.fInputStream.read() : (this.fBuffer[index++] & 0xFF);
if (b3 == -1)
expectedByte(4, 4);
if ((b3 & 0xC0) != 128)
invalidByte(4, 4, b3);
int uuuuu = b0 << 2 & 0x1C | b1 >> 4 & 0x3;
if (uuuuu > 16)
invalidSurrogate(uuuuu);
int wwww = uuuuu - 1;
int hs = 0xD800 | wwww << 6 & 0x3C0 | b1 << 2 & 0x3C | b2 >> 4 & 0x3;
int ls = 0xDC00 | b2 << 6 & 0x3C0 | b3 & 0x3F;
c = hs;
this.fSurrogate = ls;
} else {
invalidByte(1, 1, b0);
}
} else {
this.fSurrogate = -1;
}
return c;
}
public int read(char[] ch, int offset, int length) throws IOException {
int out = offset;
if (this.fSurrogate != -1) {
ch[offset + 1] = (char)this.fSurrogate;
this.fSurrogate = -1;
length--;
out++;
}
int count = 0;
if (this.fOffset == 0) {
if (length > this.fBuffer.length)
length = this.fBuffer.length;
count = this.fInputStream.read(this.fBuffer, 0, length);
if (count == -1)
return -1;
count += out - offset;
} else {
count = this.fOffset;
this.fOffset = 0;
}
int total = count;
boolean isAscii = true;
int lc = 0;
for (lc = 0; lc < total; lc++) {
int b0 = this.fBuffer[lc] & 0xFF;
if (b0 < 128) {
ch[out++] = (char)b0;
} else {
isAscii = false;
break;
}
}
if (isAscii)
return count;
for (int in = lc; in < total; in++) {
int b0 = this.fBuffer[in] & 0xFF;
if (b0 < 128) {
ch[out++] = (char)b0;
} else if ((b0 & 0xE0) == 192) {
int b1 = -1;
if (++in < total) {
b1 = this.fBuffer[in] & 0xFF;
} else {
b1 = this.fInputStream.read();
if (b1 == -1) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fOffset = 1;
return out - offset;
}
expectedByte(2, 2);
}
count++;
}
if ((b1 & 0xC0) != 128) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fOffset = 2;
return out - offset;
}
invalidByte(2, 2, b1);
}
int c = b0 << 6 & 0x7C0 | b1 & 0x3F;
ch[out++] = (char)c;
count--;
} else if ((b0 & 0xF0) == 224) {
int b1 = -1;
if (++in < total) {
b1 = this.fBuffer[in] & 0xFF;
} else {
b1 = this.fInputStream.read();
if (b1 == -1) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fOffset = 1;
return out - offset;
}
expectedByte(2, 3);
}
count++;
}
if ((b1 & 0xC0) != 128) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fOffset = 2;
return out - offset;
}
invalidByte(2, 3, b1);
}
int b2 = -1;
if (++in < total) {
b2 = this.fBuffer[in] & 0xFF;
} else {
b2 = this.fInputStream.read();
if (b2 == -1) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fOffset = 2;
return out - offset;
}
expectedByte(3, 3);
}
count++;
}
if ((b2 & 0xC0) != 128) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fBuffer[2] = (byte)b2;
this.fOffset = 3;
return out - offset;
}
invalidByte(3, 3, b2);
}
int c = b0 << 12 & 0xF000 | b1 << 6 & 0xFC0 | b2 & 0x3F;
ch[out++] = (char)c;
count -= 2;
} else if ((b0 & 0xF8) == 240) {
int b1 = -1;
if (++in < total) {
b1 = this.fBuffer[in] & 0xFF;
} else {
b1 = this.fInputStream.read();
if (b1 == -1) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fOffset = 1;
return out - offset;
}
expectedByte(2, 4);
}
count++;
}
if ((b1 & 0xC0) != 128) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fOffset = 2;
return out - offset;
}
invalidByte(2, 4, b1);
}
int b2 = -1;
if (++in < total) {
b2 = this.fBuffer[in] & 0xFF;
} else {
b2 = this.fInputStream.read();
if (b2 == -1) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fOffset = 2;
return out - offset;
}
expectedByte(3, 4);
}
count++;
}
if ((b2 & 0xC0) != 128) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fBuffer[2] = (byte)b2;
this.fOffset = 3;
return out - offset;
}
invalidByte(3, 4, b2);
}
int b3 = -1;
if (++in < total) {
b3 = this.fBuffer[in] & 0xFF;
} else {
b3 = this.fInputStream.read();
if (b3 == -1) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fBuffer[2] = (byte)b2;
this.fOffset = 3;
return out - offset;
}
expectedByte(4, 4);
}
count++;
}
if ((b3 & 0xC0) != 128) {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fBuffer[1] = (byte)b1;
this.fBuffer[2] = (byte)b2;
this.fBuffer[3] = (byte)b3;
this.fOffset = 4;
return out - offset;
}
invalidByte(4, 4, b2);
}
int uuuuu = b0 << 2 & 0x1C | b1 >> 4 & 0x3;
if (uuuuu > 16)
invalidSurrogate(uuuuu);
int wwww = uuuuu - 1;
int zzzz = b1 & 0xF;
int yyyyyy = b2 & 0x3F;
int xxxxxx = b3 & 0x3F;
int hs = 0xD800 | wwww << 6 & 0x3C0 | zzzz << 2 | yyyyyy >> 4;
int ls = 0xDC00 | yyyyyy << 6 & 0x3C0 | xxxxxx;
ch[out++] = (char)hs;
ch[out++] = (char)ls;
count -= 2;
} else {
if (out > offset) {
this.fBuffer[0] = (byte)b0;
this.fOffset = 1;
return out - offset;
}
invalidByte(1, 1, b0);
}
}
return count;
}
public long skip(long n) throws IOException {
long remaining = n;
char[] ch = new char[this.fBuffer.length];
while (true) {
int length = ((long)ch.length < remaining) ? ch.length : (int)remaining;
int count = read(ch, 0, length);
if (count > 0) {
remaining -= (long)count;
if (remaining <= 0L)
break;
continue;
}
break;
}
long skipped = n - remaining;
return skipped;
}
public boolean ready() throws IOException {
return false;
}
public boolean markSupported() {
return false;
}
public void mark(int readAheadLimit) throws IOException {
throw new IOException(this.fFormatter.formatMessage(this.fLocale, "OperationNotSupported", new Object[] { "mark()", "UTF-8" }));
}
public void reset() throws IOException {
this.fOffset = 0;
this.fSurrogate = -1;
}
public void close() throws IOException {
this.fInputStream.close();
}
private void expectedByte(int position, int count) throws UTFDataFormatException {
String message = this.fFormatter.formatMessage(this.fLocale, "ExpectedByte", new Object[] { Integer.toString(position), Integer.toString(count) });
throw new UTFDataFormatException(message);
}
private void invalidByte(int position, int count, int c) throws UTFDataFormatException {
String message = this.fFormatter.formatMessage(this.fLocale, "InvalidByte", new Object[] { Integer.toString(position), Integer.toString(count) });
throw new UTFDataFormatException(message);
}
private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
StringBuffer str = new StringBuffer();
str.append("high surrogate bits in UTF-8 sequence must not exceed 0x10 but found 0x");
String message = this.fFormatter.formatMessage(this.fLocale, "InvalidHighSurrogate", new Object[] { Integer.toHexString(uuuuu) });
throw new UTFDataFormatException(message);
}
}

View file

@ -0,0 +1,44 @@
# This file stores localized messages for the Xerces
# DOM implementation.
#
# The messages are arranged in key and value tuples in a ListResourceBundle.
#
# @version $Id: DOMMessages.properties,v 1.1.1.1 2003/06/23 06:51:31 nb131165 Exp $
BadMessageKey = The error message corresponding to the message key can not be found.
FormatFailed = An internal error occurred while formatting the following message:\n
# DOM Core
# exception codes
DOMSTRING_SIZE_ERR = The specified range of text does not fit into a DOMString.
HIERARCHY_REQUEST_ERR = An attempt was made to insert a node where it is not permitted.
INDEX_SIZE_ERR = The index or size is negative, or greater than the allowed value.
INUSE_ATTRIBUTE_ERR = An attempt is made to add an attribute that is already in use elsewhere.
INVALID_ACCESS_ERR = A parameter or an operation is not supported by the underlying object.
INVALID_CHARACTER_ERR = An invalid or illegal XML character is specified.
INVALID_MODIFICATION_ERR = An attempt is made to modify the type of the underlying object.
INVALID_STATE_ERR = An attempt is made to use an object that is not, or is no longer, usable.
NAMESPACE_ERR = An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
NOT_FOUND_ERR = An attempt is made to reference a node in a context where it does not exist.
NOT_SUPPORTED_ERR = The implementation does not support the requested type of object or operation.
NO_DATA_ALLOWED_ERR = Data is specified for a node which does not support data.
NO_MODIFICATION_ALLOWED_ERR = An attempt is made to modify an object where modifications are not allowed.
SYNTAX_ERR = An invalid or illegal string is specified.
VALIDATION_ERR = A call to a method such as insertBefore or removeChild would make the Node invalid with respect to document grammar.
WRONG_DOCUMENT_ERR = A node is used in a different document than the one that created it.
#error messages or exceptions
FEATURE_NOT_SUPPORTED = The feature {0} is recognized but the requested value cannot be set.
FEATURE_NOT_FOUND = The feature {0} is not recognized.
#Ranges
BAD_BOUNDARYPOINTS_ERR = The boundary-points of a Range do not meet specific requirements.
INVALID_NODE_TYPE_ERR = The container of a boundary-point of a Range is being set to either a node of an invalid type or a node with an ancestor of an invalid type.
#Events
UNSPECIFIED_EVENT_TYPE_ERR = The Event's type was not specified by initializing the event before the method was called.

View file

@ -0,0 +1,56 @@
package com.sun.xml.stream.xerces.impl.msg;
import com.sun.xml.stream.xerces.util.MessageFormatter;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
public class XMLMessageFormatter implements MessageFormatter {
public static final String XML_DOMAIN = "http://www.w3.org/TR/1998/REC-xml-19980210";
public static final String XMLNS_DOMAIN = "http://www.w3.org/TR/1999/REC-xml-names-19990114";
private Locale fLocale = null;
private ResourceBundle fResourceBundle = null;
public String formatMessage(Locale locale, String key, Object[] arguments) throws MissingResourceException {
String str;
if (this.fResourceBundle == null || locale != this.fLocale) {
if (locale != null) {
this.fResourceBundle = PropertyResourceBundle.getBundle("com.sun.xml.stream.xerces.impl.msg.XMLMessages", locale);
this.fLocale = locale;
}
if (this.fResourceBundle == null)
this.fResourceBundle = PropertyResourceBundle.getBundle("com.sun.xml.stream.xerces.impl.msg.XMLMessages");
}
try {
str = this.fResourceBundle.getString(key);
if (arguments != null)
try {
str = MessageFormat.format(str, arguments);
} catch (Exception e) {
str = this.fResourceBundle.getString("FormatFailed");
str = str + " " + this.fResourceBundle.getString(key);
}
} catch (MissingResourceException e) {
str = this.fResourceBundle.getString("BadMessageKey");
throw new MissingResourceException(key, str, key);
}
if (str == null) {
str = key;
if (arguments.length > 0) {
StringBuffer stringBuffer = new StringBuffer(str);
stringBuffer.append('?');
for (int i = 0; i < arguments.length; i++) {
if (i > 0)
stringBuffer.append('&');
stringBuffer.append(String.valueOf(arguments[i]));
}
}
}
return str;
}
}

View file

@ -0,0 +1,277 @@
# This file contains error and warning messages related to XML
# The messages are arranged in key and value tuples in a ListResourceBundle.
#
# @version
BadMessageKey = The error message corresponding to the message key can not be found.
FormatFailed = An internal error occurred while formatting the following message:\n
# Document messages
PrematureEOF=Premature end of file.
# 2.1 Well-Formed XML Documents
RootElementRequired = The root element is required in a well-formed document.
# 2.2 Characters
InvalidCharInCDSect = An invalid XML character (Unicode: 0x{0}) was found in the CDATA section.
InvalidCharInContent = An invalid XML character (Unicode: 0x{0}) was found in the element content of the document.
TwoColonsInQName = An invalid second ':' was found in the element type or attribute name.
InvalidCharInMisc = An invalid XML character (Unicode: 0x{0}) was found in markup after the end of the element content.
InvalidCharInProlog = An invalid XML character (Unicode: 0x{0}) was found in the prolog of the document.
InvalidCharInXMLDecl = An invalid XML character (Unicode: 0x{0}) was found in the XML declaration.
# 2.4 Character Data and Markup
CDEndInContent = The character sequence \"]]>\" must not appear in content unless used to mark the end of a CDATA section.
# 2.7 CDATA Sections
CDSectUnterminated = The CDATA section must end with \"]]>\".
# 2.8 Prolog and Document Type Declaration
XMLDeclMustBeFirst = The XML declaration may only appear at the very beginning of the document.
EqRequiredInXMLDecl = The '' = '' character must follow \"{0}\" in the XML declaration.
QuoteRequiredInXMLDecl = The value following \"{0}\" in the XML declaration must be a quoted string.
XMLDeclUnterminated = The XML declaration must end with \"?>\".
VersionInfoRequired = The version is required in the XML declaration.
SpaceRequiredBeforeVersionInXMLDecl = White space is required before the version pseudo attribute in the XML declaration.
SpaceRequiredBeforeEncodingInXMLDecl = White space is required before the encoding pseudo attribute in the XML declaration.
SpaceRequiredBeforeStandalone = White space is required before the encoding pseudo attribute in the XML declaration.
MarkupNotRecognizedInProlog = The markup in the document preceding the root element must be well-formed.
MarkupNotRecognizedInMisc = The markup in the document following the root element must be well-formed.
AlreadySeenDoctype = Already seen doctype.
ContentIllegalInProlog = Content is not allowed in prolog.
ReferenceIllegalInProlog = Reference is not allowed in prolog.
# Trailing Misc
ContentIllegalInTrailingMisc=Content is not allowed in trailing section.
ReferenceIllegalInTrailingMisc=Reference is not allowed in trailing section.
# 2.9 Standalone Document Declaration
SDDeclInvalid = The standalone document declaration value must be \"yes\" or \"no\", not \"{0}\".
# 2.12 Language Identification
XMLLangInvalid = The xml:lang attribute value \"{0}\" is an invalid language identifier.
# 3. Logical Structures
ETagRequired = The element type \"{0}\" must be terminated by the matching end-tag \"</{0}>\".
# 3.1 Start-Tags, End-Tags, and Empty-Element Tags
ElementUnterminated = Element type \"{0}\" must be followed by either attribute specifications, \">\" or \"/>\".
EqRequiredInAttribute = Attribute name \"{0}\" must be followed by the '' = '' character.
OpenQuoteExpected = Open quote is expected for attribute \"{0}\".
CloseQuoteExpected = Close quote is expected for attribute \"{0}\".
AttributeNotUnique = Attribute \"{1}\" was already specified for element \"{0}\".
AttributeNSNotUnique = Attribute \"{1}\" bound to namespace \"{2}\" was already specified for element \"{0}\".
ETagUnterminated = The end-tag for element type \"{0}\" must end with a ''>'' delimiter.
MarkupNotRecognizedInContent = The content of elements must consist of well-formed character data or markup.
DoctypeIllegalInContent = doctype not allowed in content.
# 4.1 Character and Entity References
ReferenceUnterminated = The reference must be terminated by a ';' delimiter.
# 4.3.2 Well-Formed Parsed Entities
ReferenceNotInOneEntity = The reference must be entirely contained within the same parsed entity.
ElementEntityMismatch = The element \"{0}\" must start and end within the same entity.
MarkupEntityMismatch=XML document structures must start and end within the same entity.
# Messages common to Document and DTD
# 2.2 Characters
InvalidCharInAttValue = An invalid XML character (Unicode: 0x{2}) was found in the value of attribute \"{1}\".
InvalidCharInComment = An invalid XML character (Unicode: 0x{0}) was found in the comment.
InvalidCharInPI = An invalid XML character (Unicode: 0x{0}) was found in the processing instruction.
InvalidCharInInternalSubset = An invalid XML character (Unicode: 0x{0}) was found in the internal subset of the DTD.
InvalidCharInTextDecl = An invalid XML character (Unicode: 0x{0}) was found in the text declaration.
# 2.3 Common Syntactic Constructs
QuoteRequiredInAttValue = The value of attribute \"{1}\" must begin with either a single or double quote character.
LessthanInAttValue = The value of attribute \"{1}\" must not contain the ''<'' character.
AttributeValueUnterminated = The value for attribute \"{1}\" must end with the matching quote character.
# 2.5 Comments
InvalidCommentStart = Comment must start with \"<!--\".
DashDashInComment = The string \"--\" is not permitted within comments.
CommentUnterminated = The comment must end with \"-->\".
COMMENT_NOT_IN_ONE_ENTITY = The comment is not enclosed xin the same entity.
# 2.6 Processing Instructions
PITargetRequired = The processing instruction must begin with the name of the target.
SpaceRequiredInPI = White space is required between the processing instruction target and data.
PIUnterminated = The processing instruction must end with \"?>\".
ReservedPITarget = The processing instruction target matching \"[xX][mM][lL]\" is not allowed.
PI_NOT_IN_ONE_ENTITY = The processing instruction is not enclosed in the same entity.
# 2.8 Prolog and Document Type Declaration
VersionInfoInvalid = Invalid version \"{0}\".
VersionNotSupported = XML version \"{0}\" is not supported, only XML 1.0 is supported.
# 4.1 Character and Entity References
DigitRequiredInCharRef = A decimal representation must immediately follow the \"&#\" in a character reference.
HexdigitRequiredInCharRef = A hexadecimal representation must immediately follow the \"&#x\" in a character reference.
SemicolonRequiredInCharRef = The character reference must end with the ';' delimiter.
InvalidCharRef = Character reference \"&#{0}\" is an invalid XML character.
NameRequiredInReference = The entity name must immediately follow the '&' in the entity reference.
SemicolonRequiredInReference = The reference to entity \"{0}\" must end with the '';'' delimiter.
# 4.3.1 The Text Declaration
TextDeclMustBeFirst = The text declaration may only appear at the very beginning of the external parsed entity.
EqRequiredInTextDecl = The '' = '' character must follow \"{0}\" in the text declaration.
QuoteRequiredInTextDecl = The value following \"{0}\" in the text declaration must be a quoted string.
CloseQuoteMissingInTextDecl = closing quote in the value following \"{0}\" in the text declaration is missing.
SpaceRequiredBeforeVersionInTextDecl = White space is required before the version pseudo attribute in the text declaration.
SpaceRequiredBeforeEncodingInTextDecl = White space is required before the encoding pseudo attribute in the text declaration.
TextDeclUnterminated = The text declaration must end with \"?>\".
EncodingDeclRequired = The encoding declaration is required in the text declaration.
NoMorePseudoAttributes = no more pseudo attributes is allowed.
MorePseudoAttributes = more pseudo attributes is expected.
PseudoAttrNameExpected = a pseudo attribute name is expected.
# 4.3.2 Well-Formed Parsed Entities
CommentNotInOneEntity = The comment must be entirely contained within the same parsed entity.
PINotInOneEntity = The processing instruction must be entirely contained within the same parsed entity.
# 4.3.3 Character Encoding in Entities
EncodingDeclInvalid = Invalid encoding name \"{0}\".
EncodingByteOrderUnsupported = Given byte order for encoding \"{0}\" is not supported.
InvalidByte = Invalid byte {0} of {1}-byte UTF-8 sequence.
ExpectedByte = Expected byte {0} of {1}-byte UTF-8 sequence.
InvalidHighSurrogate = High surrogate bits in UTF-8 sequence must not exceed 0x10 but found 0x{0}.
OperationNotSupported = Operation \"{0}\" not supported by {1} reader.
InvalidASCII = Byte \"{0}\" not 7-bit ASCII.
# DTD Messages
# 2.2 Characters
InvalidCharInEntityValue = An invalid XML character (Unicode: 0x{0}) was found in the literal entity value.
InvalidCharInExternalSubset = An invalid XML character (Unicode: 0x{0}) was found in the external subset of the DTD.
InvalidCharInIgnoreSect = An invalid XML character (Unicode: 0x{0}) was found in the excluded conditional section.
InvalidCharInPublicID = An invalid XML character (Unicode: 0x{0}) was found in the public identifier.
InvalidCharInSystemID = An invalid XML character (Unicode: 0x{0}) was found in the system identifier.
# 2.3 Common Syntactic Constructs
SpaceRequiredAfterSYSTEM = White space is required after keyword SYSTEM in DOCTYPE decl.
QuoteRequiredInSystemID = The system identifier must begin with either a single or double quote character.
SystemIDUnterminated = The system identifier must end with the matching quote character.
SpaceRequiredAfterPUBLIC = White spaces are required after keyword PUBLIC in DOCTYPE decl.
QuoteRequiredInPublicID = The public identifier must begin with either a single or double quote character.
PublicIDUnterminated = The public identifier must end with the matching quote character.
PubidCharIllegal = The character (Unicode: 0x{0}) is not permitted in the public identifier.
SpaceRequiredBetweenPublicAndSystem = White spaces are required between publicId and systemId.
# 2.8 Prolog and Document Type Declaration
MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL = White space is required after \"<!DOCTYPE\" in the document type declaration.
MSG_ROOT_ELEMENT_TYPE_REQUIRED = The root element type must appear after \"<!DOCTYPE\" in the document type declaration.
DoctypedeclUnterminated = The document type declaration for root element type \"{0}\" must end with ''>''.
PEReferenceWithinMarkup = The parameter entity reference \"%{0};\" cannot occur within markup in the internal subset of the DTD.
MSG_MARKUP_NOT_RECOGNIZED_IN_DTD = The markup declarations contained or pointed to by the document type declaration must be well-formed.
# 2.10 White Space Handling
MSG_XML_SPACE_DECLARATION_ILLEGAL = The attribute declaration for \"xml:space\" must be given as an enumerated type whose only possible values are \"default\" and \"preserve\".
# 3.2 Element Type Declarations
MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ELEMENTDECL = White space is required after \"<!ELEMENT\" in the element type declaration.
MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL = The element type is required in the element type declaration.
MSG_SPACE_REQUIRED_BEFORE_CONTENTSPEC_IN_ELEMENTDECL = White space is required after the element type \"{0}\" in the element type declaration.
MSG_CONTENTSPEC_REQUIRED_IN_ELEMENTDECL = The constraint is required after the element type \"{0}\" in the element type declaration.
ElementDeclUnterminated = The declaration for element type \"{0}\" must end with ''>''.
# 3.2.1 Element Content
MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN = A ''('' character or an element type is required in the declaration of element type \"{0}\".
MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN = A '')'' is required in the declaration of element type \"{0}\".
# 3.2.2 Mixed Content
MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT = An element type is required in the declaration of element type \"{0}\".
MSG_CLOSE_PAREN_REQUIRED_IN_MIXED = A '')'' is required in the declaration of element type \"{0}\".
MixedContentUnterminated = The mixed content model \"{0}\" must end with \")*\" when the types of child elements are constrained.
# 3.3 Attribute-List Declarations
MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ATTLISTDECL = White space is required after \"<!ATTLIST\" in the attribute-list declaration.
MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL = The element type is required in the attribute-list declaration.
MSG_SPACE_REQUIRED_BEFORE_ATTRIBUTE_NAME_IN_ATTDEF = White space is required before the attribute name in the attribute-list declaration for element \"{0}\".
AttNameRequiredInAttDef = The attribute name must be specified in the attribute-list declaration for element \"{0}\".
MSG_SPACE_REQUIRED_BEFORE_ATTTYPE_IN_ATTDEF = White space is required before the attribute type in the declaration of attribute \"{1}\" for element \"{0}\".
AttTypeRequiredInAttDef = The attribute type is required in the declaration of attribute \"{1}\" for element \"{0}\".
MSG_SPACE_REQUIRED_BEFORE_DEFAULTDECL_IN_ATTDEF = White space is required before the attribute default in the declaration of attribute \"{1}\" for element \"{0}\".
MSG_DUPLICATE_ATTRIBUTE_DEFINITION = More than one attribute definition is provided for the same attribute \"{1}\" of a given element \"{0}\".
# 3.3.1 Attribute Types
MSG_SPACE_REQUIRED_AFTER_NOTATION_IN_NOTATIONTYPE = White space must appear after \"NOTATION\" in the \"{1}\" attribute declaration.
MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE = The ''('' character must follow \"NOTATION\" in the \"{1}\" attribute declaration.
MSG_NAME_REQUIRED_IN_NOTATIONTYPE = The notation name is required in the notation type list for the \"{1}\" attribute declaration.
NotationTypeUnterminated = The notation type list must end with '')'' in the \"{1}\" attribute declaration.
MSG_NMTOKEN_REQUIRED_IN_ENUMERATION = The name token is required in the enumerated type list for the \"{1}\" attribute declaration.
EnumerationUnterminated = The enumerated type list must end with '')'' in the \"{1}\" attribute declaration.
# 3.3.2 Attribute Defaults
MSG_SPACE_REQUIRED_AFTER_FIXED_IN_DEFAULTDECL = White space must appear after \"FIXED\" in the \"{1}\" attribute declaration.
# 3.4 Conditional Sections
IncludeSectUnterminated = The included conditional section must end with \"]]>\".
IgnoreSectUnterminated = The excluded conditional section must end with \"]]>\".
# 4.1 Character and Entity References
NameRequiredInPEReference = The entity name must immediately follow the '%' in the parameter entity reference.
SemicolonRequiredInPEReference = The parameter entity reference \"%{0};\" must end with the '';'' delimiter.
# 4.2 Entity Declarations
MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL = White space is required after \"<!ENTITY\" in the entity declaration.
MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL = White space is required between \"<!ENTITY\" and the '%' character in the parameter entity declaration.
MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL = White space is required between the '%' and the entity name in the parameter entity declaration.
MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL = The name of the entity is required in the entity declaration.
MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL = White space is required between the entity name \"{0}\" and the definition in the entity declaration.
MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL = White space is required between \"NDATA\" and the notation name in the declaration for the entity \"{0}\".
MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL = White space is required before \"NDATA\" in the declaration for the entity \"{0}\".
MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL = The notation name is required after \"NDATA\" in the declaration for the entity \"{0}\".
EntityDeclUnterminated = The declaration for the entity \"{0}\" must end with ''>''.
MSG_DUPLICATE_ENTITY_DEFINITION = Entity \"{0}\" is declared more than once.
# 4.2.2 External Entities
ExternalIDRequired = The external entity declaration must begin with either \"SYSTEM\" or \"PUBLIC\".
MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID = White space is required between \"PUBLIC\" and the public identifier.
MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID = White space is required between the public identifier and the system identifier.
MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID = White space is required between \"SYSTEM\" and the system identifier.
MSG_URI_FRAGMENT_IN_SYSTEMID = The fragment identifier should not be specified as part of the system identifier \"{0}\".
# 4.7 Notation Declarations
MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL = White space is required after \"<!NOTATION\" in the notation declaration.
MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL = The name of the notation is required in the notation declaration.
MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL = White space is required after the notation name \"{0}\" in the notation declaration.
ExternalIDorPublicIDRequired = The declaration for the notation \"{0}\" must include a system or public identifier.
NotationDeclUnterminated = The declaration for the notation \"{0}\" must end with ''>''.
# Validation messages
DuplicateTypeInMixedContent = The element type \"{1}\" was already specified in the content model of the element decl \"{0}\".
ENTITIESInvalid = Attribute value \"{1}\" of type ENTITIES must be the names of one or more unparsed entities.
ENTITYInvalid = Attribute value \"{1}\" of type ENTITY must be the name of an unparsed entity.
IDDefaultTypeInvalid = The ID attribute \"{0}\" must have a declared default of \"#IMPLIED\" or \"#REQUIRED\".
IDInvalid = Attribute value \"{0}\" of type ID must be a name.
IDNotUnique = Attribute value \"{0}\" of type ID must be unique within the document.
IDREFInvalid = Attribute value \"{0}\" of type IDREF must be a name.
IDREFSInvalid = Attribute value \"{0}\" of type IDREFS must be one or more names.
ILL_FORMED_PARAMETER_ENTITY_WHEN_USED_IN_DECL = The replacement text of parameter entity \"{0}\" must include properly nested declarations when the entity reference is used as a complete declaration.
ImproperDeclarationNesting = The replacement text of parameter entity \"{0}\" must include properly nested declarations.
ImproperGroupNesting = The replacement text of parameter entity \"{0}\" must include properly nested pairs of parentheses.
INVALID_PE_IN_CONDITIONAL = The replacement text of parameter entity \"{0}\" must include the entire conditional section or just INCLUDE or IGNORE.
MSG_ATTRIBUTE_NOT_DECLARED = Attribute \"{1}\" must be declared for element type \"{0}\".
MSG_ATTRIBUTE_VALUE_NOT_IN_LIST = Attribute \"{0}\" with value \"{1}\" must have a value from the list \"{2}\".
MSG_ATTVALUE_CHANGED_DURING_NORMALIZATION_WHEN_STANDALONE = The value \"{1}\" of attribute \"{0}\" must not be changed by normalization (to \"{2}\") in a standalone document.
MSG_CONTENT_INCOMPLETE = The content of element type \"{0}\" is incomplete, it must match \"{1}\".
MSG_CONTENT_INVALID = The content of element type \"{0}\" must match \"{1}\".
MSG_DEFAULTED_ATTRIBUTE_NOT_SPECIFIED = Attribute \"{1}\" for element type \"{0}\" has a default value and must be specified in a standalone document.
MSG_DUPLICATE_ATTDEF = Attribute \"{1}\" is already declared for element type \"{0}\".
MSG_ELEMENT_ALREADY_DECLARED = Element type \"{0}\" must not be declared more than once.
MSG_ELEMENT_NOT_DECLARED = Element type \"{0}\" must be declared.
MSG_GRAMMAR_NOT_FOUND = Document is invalid: no grammar found.
MSG_ELEMENT_WITH_ID_REQUIRED = An element with the identifier \"{0}\" must appear in the document.
MSG_EXTERNAL_ENTITY_NOT_PERMITTED = The reference to external entity \"{0}\" is not permitted in a standalone document.
MSG_FIXED_ATTVALUE_INVALID = Attribute \"{1}\" with value \"{2}\" must have a value of \"{3}\".
MSG_MORE_THAN_ONE_ID_ATTRIBUTE = Element type \"{0}\" already has attribute \"{1}\" of type ID, a second attribute \"{2}\" of type ID is not permitted.
MSG_MORE_THAN_ONE_NOTATION_ATTRIBUTE = Element type \"{0}\" already has attribute \"{1}\" of type NOTATION, a second attribute \"{2}\" of type NOTATION is not permitted.
MSG_NOTATION_NOT_DECLARED_FOR_NOTATIONTYPE_ATTRIBUTE = The notation \"{1}\" must be declared when referenced in the notation type list for attribute \"{0}\".
MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL = The notation \"{1}\" must be declared when referenced in the unparsed entity declaration for \"{0}\".
MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE = The reference to entity \"{0}\" declared in an external parsed entity is not permitted in a standalone document.
MSG_REQUIRED_ATTRIBUTE_NOT_SPECIFIED = Attribute \"{1}\" is required and must be specified for element type \"{0}\".
MSG_WHITE_SPACE_IN_ELEMENT_CONTENT_WHEN_STANDALONE = White space must not occur between elements declared in an external parsed entity with element content in a standalone document.
NMTOKENInvalid = Attribute value \"{0}\" of type NMTOKEN must be a name token.
NMTOKENSInvalid = Attribute value \"{0}\" of type NMTOKENS must be one or more name tokens.
RootElementTypeMustMatchDoctypedecl = Document root element \"{1}\", must match DOCTYPE root \"{0}\".
UndeclaredElementInContentSpec = The content model of element \"{0}\" refers to the undeclared element \"{1}\".
ENTITYFailedInitializeGrammar = ENTITYDatatype Validator: Failed Need to call initialize method with a valid Grammar reference.
ENTITYNotUnparsed = ENTITY \"{0}\" is not unparsed.
ENTITYNotValid = ENTITY \"{0}\" is not valid.
EmptyList = Value of type ENTITIES, IDREFS, and NMTOKENS cannot be empty list.
# Entity related messages
# 3.1 Start-Tags, End-Tags, and Empty-Element Tags
ReferenceToExternalEntity = The external entity reference \"&{0};\" is not permitted in an attribute value.
# 4.1 Character and Entity References
EntityNotDeclared = The entity \"{0}\" was referenced, but not declared.
ReferenceToUnparsedEntity = The unparsed entity reference \"&{0};\" is not permitted.
RecursiveReference = Recursive entity reference \"{0}\". (Reference path: {1}),
RecursiveGeneralReference = Recursive general entity reference \"&{0};\". (Reference path: {1}),
RecursivePEReference = Recursive parameter entity reference \"%{0};\". (Reference path: {1}),
# 4.3.3 Character Encoding in Entities
EncodingNotSupported = The encoding \"{0}\" is not supported.
EncodingRequired = A parsed entity not encoded in either UTF-8 or UTF-16 must contain an encoding declaration.
# Namespaces support
# 4. Using Qualified Names
ElementXMLNSPrefix = Element \"{0}\" cannot have \"xmlns\" as its prefix.
ElementPrefixUnbound = The prefix \"{0}\" for element \"{1}\" is not bound.
AttributePrefixUnbound = The prefix \"{0}\" for attribute \"{1}\" is not bound.
EmptyPrefixedAttName = The value of the attribute \"{0}\" is invalid. Prefixed namespace bindings may not be empty.
PrefixDeclared = The namespace prefix \"{0}\" was not declared.
CantBindXMLNS = The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly.
CantBindXML = The prefix "xml" cannot be bound to any namespace other than its usual namespace; neither can the namespace for "xml" be bound to any prefix other than "xml".
MSG_ATT_DEFAULT_INVALID = The defaultValue \"{1}\" of attribute \"{0}\" is not legal as for the lexical constraints of this attribute type.
# REVISIT: These need messages
MSG_SPACE_REQUIRED_AFTER_SYSTEMLITERAL_IN_EXTERNALID=MSG_SPACE_REQUIRED_AFTER_SYSTEMLITERAL_IN_EXTERNALID
OpenQuoteMissingInDecl=OpenQuoteMissingInDecl
InvalidCharInLiteral=InvalidCharInLiteral
DoctypeNotAllowed=Doctype declaration is not allowed.

View file

@ -0,0 +1,331 @@
# This file contains error and warning messages related to XML Schema
# The messages are arranged in key and value tuples in a ListResourceBundle.
#
# @version $Id: XMLSchemaMessages.properties,v 1.1.1.1 2003/06/23 06:51:31 nb131165 Exp $
BadMessageKey = The error message corresponding to the message key can not be found.
FormatFailed = An internal error occurred while formatting the following message:\n
# For internal use
Internal-Error = Internal error: {0}.
dt-whitespace = Whitespace facet value is not available for the union simpleType ''{0}''
GrammarConflict = One of the grammar(s) returned from the user's grammar pool is in conflict with another grammar.
# Identity constraints
AbsentKeyValue = Identity Constraint error (cvc-identity-constraint.4.2.1): element \"{0}\" has a key with no value.
DuplicateField = Duplicate match in scope for field \"{0}\".
DuplicateKey = Duplicate key value [{0}] declared for identity constraint of element \"{1}\".
DuplicateUnique = Duplicate unique value [{0}] declared for identity constraint of element \"{1}\".
FieldMultipleMatch = Identity constraint error: field \"{0}\" matches more than one value within the scope of its selector; fields must match unique values.
FixedDiffersFromActual = The content of this element is not equivalent to the value of the \"fixed\" attribute in the element's declaration in the schema.
KeyMatchesNillable = Identity Constraint error (cvc-identity-constraint.4.2.3): element \"{0}\" has a key which matches an element which has nillable set to true.
KeyNotEnoughValues = Not enough values specified for <key name=\"{1}\"> identity constraint specified for element \"{0}\".
KeyNotFound = Key ''{0}'' with value ''{1}'' not found for identity constraint of element ''{2}''.
KeyRefNotEnoughValues = Not enough values specified for <keyref name=\"{1}\"> identity constraint specified for element \"{0}\".
KeyRefOutOfScope = Identity Constraint error: identity constraint \"{0}\" has a keyref which refers to a key or unique that is out of scope.
KeyRefReferNotFound = Key reference declaration \"{0}\" refers to unknown key with name \"{1}\".
UniqueNotEnoughValues = Not enough values specified for <unique> identity constraint specified for element \"{0}\".
UnknownField = Internal identity constraint error; unknown field \"{0}\
# Ideally, we should only use the following error keys, not the ones under
# "Identity constraints". And we should cover all of the following errors.
#validation (3.X.4)
cvc-assess-attr = cvc-assess-attr: error.
cvc-assess-elt = cvc-assess-elt: error.
cvc-attribute.1 = cvc-attribute.1: error.
cvc-attribute.2 = cvc-attribute.2: error.
cvc-attribute.3 = cvc-attribute.3: The value ''{2}'' of attribute ''{1}'' on element ''{0}'' is not valid with respect to its type.
cvc-attribute.4 = cvc-attribute.4: The value ''{2}'' of attribute ''{1}'' on element ''{0}'' is not valid with respect to its fixed '{'value constraint'}'.
cvc-au = cvc-au: error.
cvc-complex-type.1 = cvc-complex-type.1: error.
cvc-complex-type.2.1 = cvc-complex-type.2.1: Element ''{0}'' must have no character or element information item [children], because the type's content type is empty.
cvc-complex-type.2.2 = cvc-complex-type.2.2: Element ''{0}'' must have no element [children], and the value must be valid.
cvc-complex-type.2.3 = cvc-complex-type.2.3: Element ''{0}'' must have no character [children], because the type's content type is element-only.
cvc-complex-type.2.4.a = cvc-complex-type.2.4.a: Invalid content starting with element ''{0}''. The content must match ''{1}''.
cvc-complex-type.2.4.b = cvc-complex-type.2.4.b: The content of element ''{0}'' is not complete. It must match ''{1}''.
cvc-complex-type.2.4.c = cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ''{0}''.
cvc-complex-type.3.1 = cvc-complex-type.3.1: Value ''{2}'' of attribute ''{1}'' of element ''{0}'' is not valid with repect to the corresponding attribute use.
cvc-complex-type.3.2.1 = cvc-complex-type.3.2.1: Element ''{0}'' does not have an attribute wildcard for attribute ''{1}''.
cvc-complex-type.3.2.2 = cvc-complex-type.3.2.2: Attribute ''{1}'' is not allowed to appear in element ''{0}''.
cvc-complex-type.4 = cvc-complex-type.4: Attribute ''{1}'' must appear on element ''{0}''.
cvc-complex-type.5.1 = cvc-complex-type.5.1: In element ''{0}'', attribute ''{1}'' is a Wild ID. But there is already a Wild ID ''{2}''.
cvc-complex-type.5.2 = cvc-complex-type.5.2: In element ''{0}'', attribute ''{1}'' is a Wild ID. But there is already a attribute ''{2}'' from the attribute uses.
cvc-complex-type.5.3 = cvc-complex-type.5.2: Attribute ''{0}'' is a Wild ID. But there is already a attribute ''{1}'' from the attribute uses.
cvc-datatype-valid.1.1 = cvc-datatype-valid.1.1: The value ''{0}'' is not pattern valid with respect to type ''{1}''.
cvc-datatype-valid.1.2.1 = cvc-datatype-valid.1.2.1: ''{0}'' is not a valid ''{1}'' value.
cvc-datatype-valid.1.2.2 = cvc-datatype-valid.1.2.2: ''{0}'' is not a valid value of list type ''{1}''.
cvc-datatype-valid.1.2.3 = cvc-datatype-valid.1.2.3: ''{0}'' is not a valid value of union type ''{1}''.
cvc-datatype-valid.2 = cvc-datatype-valid.2: ''{0}'' is not from the value space of type ''{1}''.
cvc-elt.1 = cvc-elt.1: Cannot find the declaration of element ''{0}''.
cvc-elt.2 = cvc-elt.2: '{'abstract'}' of the element declaration of ''{0}'' must be false.
cvc-elt.3.1 = cvc-elt.3.1: Attribute ''{1}'' must not apprear on element ''{0}'', because '{'nillable'}' is false.
cvc-elt.3.2.1 = cvc-elt.3.2.1: Element ''{0}'' must have no character or element information [children], because ''{1}'' is specified.
cvc-elt.3.2.2 = cvc-elt.3.2.2: There must be no fixed '{'value constraint'}' for element ''{0}'', because ''{1}'' is specified.
cvc-elt.4.1 = cvc-elt.4.1: The value ''{2}'' of attribute ''{1}'' is not a valid QName on element ''{0}''.
cvc-elt.4.2 = cvc-elt.4.2: Cannot resolve ''{1}'' to a type definition for element ''{0}''.
cvc-elt.4.3 = cvc-elt.4.3: Type ''{1}'' is not validly derived from the type definition of element ''{0}''.
cvc-elt.5.1.1 = cvc-elt.5.1.1: '{'value constraint'}' ''{2}'' of element ''{0}'' is not a valid default for type ''{1}''.
cvc-elt.5.1.2 = cvc-elt.5.1.2: error.
cvc-elt.5.2.2.1 = cvc-elt.5.2.2.1: Element ''{0}'' must have no element information item [children].
cvc-elt.5.2.2.2.1 = cvc-elt.5.2.2.2.1: The value ''{1}'' of element ''{0}'' does not match the fixed value constrinat value ''{2}''.
cvc-elt.5.2.2.2.2 = cvc-elt.5.2.2.2.2: The value ''{1}'' of element ''{0}'' does not match the value constrinat value ''{2}''.
cvc-elt = cvc-elt: error.
cvc-enumeration-valid = cvc-enumeration-valid: Value ''{0}'' is not facet-valid with respect to enumeration ''{1}''.
cvc-facet-valid = cvc-facet-valid: error.
cvc-fractionDigits-valid = cvc-fractionDigits-valid: Value ''{0}'' with fractionDigits = ''{1}'' is not facet-valid with respect to fractionDigits ''{2}''.
cvc-id.1 = cvc-id.1: There is no ID/IDREF binding for IDREF ''{0}''.
cvc-id.2 = cvc-id.2: There are multiple occurrences of ID value ''{0}''.
cvc-id.3 = cvc-id.3: A field of identity constraint ''{0}'' matched element ''{1}'' but this element does not have a simple type.
cvc-identity-constraint = cvc-identity-constraint: error.
cvc-length-valid = cvc-length-valid: Value ''{0}'' with length = ''{1}'' is not facet-valid with respect to length ''{2}''.
cvc-maxExclusive-valid = cvc-maxExclusive-valid: Value ''{0}'' is not facet-valid with respect to maxExclusive ''{1}''.
cvc-maxInclusive-valid = cvc-maxInclusive-valid: Value ''{0}'' is not facet-valid with respect to maxInclusive ''{1}''.
cvc-maxLength-valid = cvc-maxLength-valid: Value ''{0}'' with length = ''{1}'' is not facet-valid with respect to maxLength ''{2}''.
cvc-minExclusive-valid = cvc-minExclusive-valid: Value ''{0}'' is not facet-valid with respect to minExclusive ''{1}''.
cvc-minInclusive-valid = cvc-minInclusive-valid: Value ''{0}'' is not facet-valid with respect to minInclusive ''{1}''.
cvc-minLength-valid = cvc-minLength-valid: Value ''{0}'' with length = ''{1}'' is not facet-valid with respect to minLength ''{2}''.
cvc-model-group = cvc-model-group: error.
cvc-particle = cvc-particle: error.
cvc-pattern-valid = cvc-pattern-valid: Value ''{0}'' is not facet-valid with respect to pattern ''{1}''.
cvc-resolve-instance = cvc-resolve-instance: error.
cvc-simple-type = cvc-simple-type: error.
cvc-totalDigits-valid = cvc-totalDigits-valid: Value ''{0}'' with totalDigits = ''{1}'' is not facet-valid with respect to totalDigits ''{2}''.
cvc-type.1 = cvc-type.1: error.
cvc-type.2 = cvc-type.2: The type definition must not be abstract.
cvc-type.3.1.1 = cvc-type.3.1.1: [attributes] of element ''{0}'' must be empty, excepting those whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is one of type, nil, schemaLocation or noNamespaceSchemaLocation.
cvc-type.3.1.2 = cvc-type.3.1.2: Element ''{0}'' must have no element information item [children].
cvc-type.3.1.3 = cvc-type.3.1.3: The value ''{1}'' of element ''{0}'' is not valid.
cvc-type.3.2 = cvc-type.3.2: error.
cvc-type = cvc-type: error.
cvc-wildcard = cvc-wildcard: error.
cvc-wildcard-namespace = cvc-wildcard-namespace: error.
#schema valid (3.X.3)
schema_reference.4 = schema_reference.4: Failed to read schema document ''{0}'', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
src-annotation = src-annotation: can only contain <appinfo> and <documentation> elements.
src-attribute.1 = src-attribute.1: ''default'' and ''fixed'' must not both be present in attribute declaration ''{0}''.
src-attribute.2 = src-attribute.2: : ''default'' is present in attribute ''{0}'', so ''use'' must be ''optional''.
src-attribute.3.1 = src-attribute.3.1: One of ''ref'' or ''name'' must be present in a local attribute declaration..
src-attribute.3.2 = src-attribute.3.2: The content must match (annotation?) for the attribute reference ''{0}''..
src-attribute.4 = src-attribute.4: Attribute ''{0}'' have both a type attribute and a annoymous simpleType child..
src-attribute.5 = src-attribute.5: error.
src-attribute_group = src-attribute_group: Attribute group ''{0}'' does not conform to the schema for schemas. Element ''{1}'' is invalid or misplaced.
src-ct.0.1 = src-ct.0.1: Complex Type Definition Representation Error for type ''{0}''. Element ''{1}'' is invalid, misplaced, or occurs too often.
src-element.1 = src-element.1: ''default'' and ''fixed'' must not both be present in element declaration ''{0}''.
src-ct.0.2 = src-ct.0.2: Complex Type Definition Representation Error for type ''{0}''. Element ''{1}'' must not be empty.
src-ct.0.3 = src-ct.0.3: Complex Type Definition Representation Error for type ''{0}''. A base type must be specified.
src-ct.1 = src-ct.1: Complex Type Definition Representation Error for type ''{0}''. When complexContent is used, the base type must be a complexType.
src-ct.2 = src-ct.2: Complex Type Definition Representation Error for type ''{0}''. When simpleContent is used, the base type must be a complexType whose content type is simple, or, only if extension is specified, a simple type.
src-element.2.1 = src-element.2.1: : One of ''ref'' or ''name'' must be present in a local element declaration.
src-element.2.2 = src-element.2.2: The content must match (annotation?) for the element reference ''{0}''.
src-element.3 = src-element.3: Element ''{0}'' have both a type attribute and a annoymous type child.
src-element.4 = src-element.4: error.
src-expredef = src-expredef: error.
src-identity-constraint.1 = src-identity-constraint.1: a ''<selector>'' or a ''<field>'' element can contain at most one ''<annotation>'' in its content; identity constraint ''{0}'' violates this constraint.
src-import.0 = src-import.0: Failed to read imported schema document ''{0}''.
src-import.1.1 = src-import.1.1: The namespace attribute ''{0}'' of an <import> element information item must not be the same as the targetNamespace of the schema it exists in.
src-import.2 = src-import.2: The root element of document ''{0}'' is not <xsd:schema>.
src-import.3.1 = src-import.3.1: The namespace attribute ''{0}'' of an <import> element information item must be identical to the targetNamespace attribute ''{1}'' of the imported document.
src-import.3.2 = src-import.3.2: There is no namespace attribute on the <import> element information item, so the imported document must have no targetNamespace attribute.
src-include.0 = src-include.0: Failed to read included schema document ''{0}''.
src-include.1 = src-include.1: The root element of document ''{0}'' is not <xsd:schema>.
src-include.2.1 = src-include.2.1: the targetNamespace of the schema ''{1}'' must be identical to that of the including schema ''{0}''.
src-list-itemType-or-simpleType = src-list-itemType-or-simpleType: error.
src-model_group = src-model_group: error.
src-model_group_defn = src-model_group_defn: error.
src-multiple-enumerations = src-multiple-enumerations: error.
src-multiple-patterns = src-multiple-patterns: error.
src-notation = src-notation: {0}.
src-qname = src-qname: error.
src-redefine.0 = src-redefine.0: Failed to read redefined schema document ''{0}''.
src-redefine.1 = src-redefine.1: The component ''{0}'' occurs in a schema different from that which was redefined.
src-redefine.2 = src-redefine.2: The root element of document ''{0}'' is not <xsd:schema>.
src-redefine.3.1 = src-redefine.3.1: the targetNamespace of the schema ''{1}'' must be identical to that of the redefining schema ''{0}''.
src-redefine.5 = src-redefine.5: <simpleType> or <complexType> children of <redefine> elements must have <extension> or <restriction> descendants referring to themselves.
src-redefine = src-redefine: A <redefine> element cannot contain a child of type ''{0}''.
src-redefine.6.1.1 = src-redefine.6.1.1: if a group child of a <redefine> element contains a group ref'ing itself, it must have exactly 1; this one has ''{0}''.
src-redefine.6.1.2 = src-redefine.6.1.2: the group ''{0}'' which contains a reference to a group being redefined must have minOccurs = maxOccurs = 1.
src-redefine.6.2.1 = src-redefine.6.2.1: no group in the redefined schema with a name matching ''{0}''.
src-redefine.6.2.2 = src-redefine.6.2.2: group ''{0}'' does not properly restrict the group it redefines; constraint violated: ''{1}''.
src-redefine.7.1 = src-redefine.7.1: if an attributeGroup child of a <redefine> element contains an attributeGroup ref'ing itself, it must have exactly 1; this one has ''{0}''.
src-redefine.7.2.1 = src-redefine.7.2.1: no attributeGroup in the redefined schema with a name matching ''{0}''.
src-redefine.7.2.2 = src-redefine.7.2.2: attributeGroup ''{0}'' does not properly restrict the attributeGroup it redefines; constraint violated: ''{1}''.
src-resolve = src-resolve: Cannot resolve the name ''{0}'' to a(n) {1} component.
src-resolve.4 = src-resolve.4: Components from namespace ''{1}'' are not referenceable from schema document ''{0}''.
src-restriction-base-or-simpleType = src-restriction-base-or-simpleType: error.
src-simple-type.2 = src-simple-type.2: <restriction> must have a base [attribute] or a <simpleType> among its [children], but not both.
src-simple-type.3 = src-simple-type.3: <list> must have an itemType [attribute] or a <simpleType> among its [children], but not both.
src-single-facet-value = src-single-facet-value: {0}
src-union-memberTypes-or-simpleTypes = src-union-memberTypes-or-simpleTypes: Either the memberTypes [attribute] of the <union> element must be non-empty or there must be at least one simpleType [child].
src-wildcard = src-wildcard: error {0}.
st-restrict-facets = st-restrict-facets: error.
#constraint valid (3.X.6)
ag-props-correct.1 = ag-props-correct.1: error.
ag-props-correct.2 = ag-props-correct.2: Error for attribute group ''{0}''. Duplicate attribute uses with the same name and target namespace are specified. Name of duplicate attribute use is ''{1}''.
ag-props-correct.3 = ag-props-correct.3: Error for attribute group ''{0}''. Two attribute declarations, ''{1}'' and ''{2}'' have types which derived from ID.
an-props-correct = an-props-correct: error.
a-props-correct.1 = a-props-correct.1: error.
a-props-correct.2 = a-props-correct.2: Invalid value constraint value ''{1}'' in attribute ''{0}''..
a-props-correct.3 = a-props-correct.3: There must not be a '{'value constraint'}' on attribute ''{0}'', because its '{'type definition'}' is or is derived from ID.
au-props-correct.1 = au-props-correct.1: error.
au-props-correct.2 = au-props-correct.2: The '{'value constraint'}' of the reference to attribute ''{0}'' must be fixed and its value must match the '{'value constraint'}' of ''{0}''.
cos-all-limited.1.2 = cos-all-limited.1.2: An ''all'' model group must appear in a particle with '{'min occurs'}'='{'max occurs'}'=1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type definition.
cos-all-limited.2 = cos-all-limited.2: The '{'max occurs'}' of an element in an ''all'' model group must be 0 or 1.
cos-applicable-facets = cos-applicable-facets: Facet ''{0}'' is not allowed by this type.
cos-aw-intersect = cos-aw-intersect: error.
cos-aw-union = cos-aw-union: error.
cos-choice-range = cos-choice-range: error.
cos-ct-derived-ok = cos-ct-derived-ok: error.
cos-ct-extends = cos-ct-extends: error.
cos-ct-extends.1.1 = cos-ct-extends.1.1: Error for type ''{0}''. Extension must not be in the final set of the base type.
cos-ct-extends.1.4.2.2.2.2.1 = cos-ct-extends.1.4.2.2.2.2.1: Error for type ''{0}''. The content type of a derived type and that of its base must both be mixed or element-only.
cos-element-consistent = cos-element-consistent: Error for type ''{0}''. Multiple elements with name ''{1}'', with different types, appear in the model group.
cos-equiv-class = cos-equiv-class: error.
cos-equiv-derived-ok-rec = cos-equiv-derived-ok-rec: error.
cos-group-emptiable = cos-group-emptiable: error.
cos-list-of-atomic = cos-list-of-atomic: type ''{0}''.
cos-no-circular-unions = cos-no-circular-unions: error.
cos-nonambig = cos-nonambig: {0} and {1} (or elements from their substitution group) violate \"Unique Particle Attribution\".
cos-ns-subset = cos-ns-subset: error.
cos-particle-extend = cos-particle-extend: error.
cos-particle-restrict = cos-particle-restrict: error.
cos-particle-restrict.2 = cos-particle-restrict.2: Forbidden particle restriction: ''{0}''.
cos-seq-range = cos-seq-range: error.
cos-st-derived-ok = cos-st-derived-ok: error.
cos-st-restricts = cos-st-restricts: error.
cos-valid-default.1 = cos-valid-default.1: error.
cos-valid-default.2.1 = cos-valid-default.2.1: Element ''{0}'' has a value constraint and must have a mixed or simple content model.
cos-valid-default.2.2.1 = cos-valid-default.2.2.1: error.
cos-valid-default.2.2.2 = cos-valid-default.2.2.2: For element ''{0}'', the '{'content type'}' is mixed, then the '{'content type'}''s particle must be emptiable.
c-props-correct.1 = c-props-correct.1: error.
c-props-correct.2 = c-props-correct.2: Cardinality of Fields for keyref ''{0}'' and key ''{1}'' must match.
ct-props-correct = ct-props-correct: error.
ct-props-correct.4 = ct-props-correct.4: Error for type ''{0}''. Duplicate attribute uses with the same name and target namespace are specified. Name of duplicate attribute use is ''{1}''.
ct-props-correct.5 = ct-props-correct.5: Error for type ''{0}''. Two attribute declarations, ''{1}'' and ''{2}'' have types which derived from ID.
derivation-ok-restriction = derivation-ok-restriction: error.
derivation-ok-restriction.1 = derivation-ok-restriction.1: Error for type ''{0}''. Restriction must not be in the final set of the base type.
derivation-ok-restriction.2.1.1= derivation-ok-restriction.2.1.1: Error for type ''{0}''. An attibute use in this type has a REQUIRED setting which is inconsistent with a matching attribute use in the base type.
derivation-ok-restriction.2.1.2= derivation-ok-restriction.2.1.2: Error for type ''{0}''. An attribute use in this type has a type which is not validly derived from the type of the matching attribute use in the base type.
derivation-ok-restriction.2.1.3= derivation-ok-restriction.2.1.3: Error for type ''{0}''. An attribute use in this type has an effective value constraint which is not consistent with the effective value constraint of the matching attribute use in the base type.
derivation-ok-restriction.2.2= derivation-ok-restriction.2.2: Error for type ''{0}''. An attribute use in this type does not have a matching attribute use in the base, and, the base type does not have a wildcard which matches this attribute use.
derivation-ok-restriction.3= derivation-ok-restriction.3: Error for type ''{0}''. There is an attribute use in the base type with REQUIRED as true, which does not have a matching attribute use in the derived type.
derivation-ok-restriction.4= derivation-ok-restriction.4: Error for type ''{0}''. The wildcard in the derivation is not a valid wildcard subset of the one in the base.
derivation-ok-restriction.5.1.1 = derivation-ok-restriction.5.1.1: Error for type ''{0}''. The content type is not a valid restriction of the content type of the base.
derivation-ok-restriction.5.2 = derivation-ok-restriction.5.2: Error for type ''{0}''. The content type of this type is empty, but the content type of the base is not.
derivation-ok-restriction.5.3 = derivation-ok-restriction.5.3: Error for type ''{0}''. The particle of the type is not a valid restriction of the particle of the base.
enumeration-required-notation = enumeration-required-notation: enumeration facet value required for NOTATION type in element/attribute ''{0}''.
enumeration-valid-restriction = enumeration-valid-restriction: enumeration value ''{0}'' is not in the value space of '{'base type definition'}'.
e-props-correct.1 = e-props-correct.1: error.
e-props-correct.2 = e-props-correct.2: Invalid value constraint value ''{1}'' in element ''{0}''.
e-props-correct.3 = e-props-correct.3: The '{'type definition'}' of element ''{0}'' must be validly derived from the '{'type definition'}' of the substitutionHead ''{1}''.
e-props-correct.4 = e-props-correct.4: There must not be a '{'value constraint'}' on element ''{0}'', because its '{'type definition'}' or '{'type definition'}''s '{'content type'}' is or is derived from ID.
fractionDigits-totalDigits = fractionDigits-totalDigits: fractionDigits value = ''{0}'' must be <= totalDigits value = ''{1}''.
length-minLength-maxLength = length-minLength-maxLength: It is an error for both length and either of minLength or maxLength to be specified.
length-valid-restriction = length-valid-restriction: Value of length = ''{0}'' must be = the value of that of the base type ''{1}''.
maxExclusive-valid-restriction.1 = maxExclusive-valid-restriction.1: maxExclusive value =''{0}'' must be <= maxExclusive of the base type ''{1}''.
maxExclusive-valid-restriction.2 = maxExclusive-valid-restriction.2: maxExclusive value =''{0}'' must be <= maxInclusive of the base type ''{1}''.
maxExclusive-valid-restriction.3 = maxExclusive-valid-restriction.3: maxExclusive value =''{0}'' must be > minInclusive of the base type ''{1}''.
maxExclusive-valid-restriction.4 = maxExclusive-valid-restriction.4: maxExclusive value =''{0}'' must be > minExclusive of the base type ''{1}''.
maxInclusive-maxExclusive = maxInclusive-maxExclusive: It is an error for both maxInclusive and maxExclusive to be specified for the same datatype.
maxInclusive-valid-restriction.1 = maxInclusive-valid-restriction.1: maxInclusive value =''{0}'' must be <= maxInclusive of the base type ''{1}''.
maxInclusive-valid-restriction.2 = maxInclusive-valid-restriction.2: maxInclusive value =''{0}'' must be < maxExclusive of the base type ''{1}''.
maxInclusive-valid-restriction.3 = maxInclusive-valid-restriction.3: maxInclusive value =''{0}'' must be >= minInclusive of the base type ''{1}''.
maxInclusive-valid-restriction.4 = maxInclusive-valid-restriction.4: maxInclusive value =''{0}'' must be > minExclusive of the base type ''{1}''.
maxLength-valid-restriction = maxLength-valid-restriction: maxLength value = ''{0}'' must be <= that of the base type ''{1}''.
mgd-props-correct = mgd-props-correct: error.
mg-props-correct = mg-props-correct: error.
minExclusive-less-than-equal-to-maxExclusive = minExclusive-less-than-equal-to-maxExclusive: minExclusive value = ''{0}'' must be <= maxExclusive value = ''{1}''.
minExclusive-less-than-maxInclusive = minExclusive-less-than-maxInclusive: minExclusive value = ''{0}'' must be < maxInclusive value = ''{1}''.
minExclusive-valid-restriction.1 = minExclusive-valid-restriction.1: minExclusive value =''{0}'' must be >= minExclusive of the base type ''{1}''.
minExclusive-valid-restriction.2 = minExclusive-valid-restriction.2: minExclusive value =''{0}'' must be <= maxInclusive of the base type ''{1}''.
minExclusive-valid-restriction.3 = minExclusive-valid-restriction.3: minExclusive value =''{0}'' must be >= minInclusive of the base type ''{1}''.
minExclusive-valid-restriction.4 = minExclusive-valid-restriction.4: minExclusive value =''{0}'' must be < maxExclusive of the base type ''{1}''.
minInclusive-less-than-equal-to-maxInclusive = minInclusive-less-than-equal-to-maxInclusive: minInclusive value = ''{0}'' must be <= maxInclusive value = ''{1}''.
minInclusive-less-than-maxExclusive = minInclusive-less-than-maxExclusive: minInclusive value = ''{0}'' must be < maxExclusive value = ''{1}''.
minInclusive-minExclusive = minInclusive-minExclusive: It is an error for both minInclusive and minExclusive to be specified for the same datatype.
minInclusive-valid-restriction.1 = minInclusive-valid-restriction.1: minInclusive value =''{0}'' must be >= minInclusive of the base type ''{1}''.
minInclusive-valid-restriction.2 = minInclusive-valid-restriction.2: minInclusive value =''{0}'' must be <= maxInclusive of the base type ''{1}''.
minInclusive-valid-restriction.3 = minInclusive-valid-restriction.3: minInclusive value =''{0}'' must be > minExclusive of the base type ''{1}''.
minInclusive-valid-restriction.4 = minInclusive-valid-restriction.4: minInclusive value =''{0}'' must be < maxExclusive of the base type ''{1}''.
minLength-less-than-equal-to-maxLength = minLength-less-than-equal-to-maxLength: value of minLength = ''{0}'' must be less than value of maxLength = ''{1}''.
minLength-valid-restriction = minLength-valid-restriction: error.
no-xmlns = no-xmlns: The '{'name'}' of an attribute declaration must not match ''xmlns''.
no-xsi = no-xsi: The '{'target namespace'}' of an attribute declaration must not match ''{0}''.
p-props-correct.2.1 = p-props-correct.2.1: '{'min occurs'}' = ''{1}'' must not be greater than '{'max occurs'}' = ''{2}'' for ''{0}''.
range-ok = range-ok: error.
rcase-MapAndSum = rcase-MapAndSum: error.
rcase-MapAndSum.1 = rcase-MapAndSum.1: There is not a complete functional mapping between the particles.
rcase-MapAndSum.2 = rcase-MapAndSum.2: Group's occurrence range is not a valid restriction of base group's occurrence range.
rcase-NameAndTypeOK = rcase-NameAndTypeOK: error.
rcase-NameAndTypeOK.1 = rcase-NameAndTypeOK.1: Elements have names and target namespaces which are not the same: Element ''{0}'' in namespace ''{1}'' and element ''{2}'' in namespace ''{3}''.
rcase-NameAndTypeOK.2 = rcase-NameAndTypeOK.2: Base particle's nillable is true, or the restricted particle's nillable is false. Element is ''{0}''.
rcase-NameAndTypeOK.3 = rcase-NameAndTypeOK.3: The occurrence range is not a valid restriction of the base's range. Element is ''{0}''.
rcase-NameAndTypeOK.4 = rcase-NameAndTypeOK.4: Element ''{0}'' is either not fixed, or not fixed with the same value as that in the base.
rcase-NameAndTypeOK.5 = rcase-NameAndTypeOK.5: Identity constraints for element ''{0}'' are not a subset of those in base.
rcase-NameAndTypeOK.6 = rcase-NameAndTypeOK.6: The disallowed substitutions for element ''{0}'' are not a superset of those in the base.
rcase-NameAndTypeOK.7 = rcase-NameAndTypeOK.7: Element ''{0}'' has a type which does not derive from the type of the base element.
rcase-NSCompat = rcase-NSCompat: error.
rcase-NSCompat.1 = rcase-NSCompat.2: Element ''{0}'' has a namespace ''{1}'' which is not allowed by the wildcard in the base.
rcase-NSCompat.2 = rcase-NSCompat.2: The occurrence range for element ''{0}'' is not a valid restriction of base's wildcard occurrence range.
rcase-NSRecurseCheckCardinality = rcase-NSRecurseCheckCardinality: error.
rcase-NSRecurseCheckCardinality.1 = rcase-NSRecurseCheckCardinality.1: Group's occurrence range is not a valid restriction of base wildcard's range.
rcase-NSRecurseCheckCardinality.2 = rcase-NSRecurseCheckCardinality.2: There is not a complete functional mapping between the particles.
rcase-NSSubset = rcase-NSSubset: error.
rcase-NSSubset.1 = rcase-NSSubset.1: Wildcard is not a subset of corresponding wildcard in base.
rcase-NSSubset.2 = rcase-NSSubset.2: Wildcard's occurrence range is not a valid restriction of that in the base.
rcase-Recurse = rcase-Recurse: error.
rcase-Recurse.1 = rcase-Recurse.1: Group's occurrence range is not a valid restriction of base group's occurrence range.
rcase-Recurse.2 = rcase-Recurse.2: There is not a complete functional mapping between the particles.
rcase-RecurseAsIfGroup = rcase-RecurseAsIfGroup: error.
rcase-RecurseLax = rcase-RecurseLax: error.
rcase-RecurseLax.1 = rcase-RecurseLax.1: Group's occurrence range is not a valid restriction of base group's occurrence range.
rcase-RecurseLax.2 = rcase-RecurseLax.2: There is not a complete functional mapping between the particles.
rcase-RecurseUnordered = rcase-RecurseUnordered: error.
rcase-RecurseUnordered.1 = rcase-RecurseUnordered.1: Group's occurrence range is not a valid restriction of base group's occurrence range.
rcase-RecurseUnordered.2 = rcase-RecurseUnordered.2: There is not a complete functional mapping between the particles.
sch-props-correct = sch-props-correct: Duplicate declaration for an element ''{0}''
sch-props-correct.1 = sch-props-correct.1: schema components of type ''{0}'' cannot occur after declarations or are not permitted as children of a <schema> element.
sch-props-correct.2 = sch-props-correct.2: a schema cannot contain two global components with the same name; this one contains two occurrences of ''{0}''.
st-props-correct.1 = st-props-correct.1: error.
st-props-correct.2 = st-props-correct.2: circular definitions detected for type ''{0}''.
st-props-correct.3 = st-props-correct.3: {final} of the {base type definition} contains restriction.
st-props-correct.4.1 = st-props-correct.4.1: The type definition is not a valid restriction with repect to the base type ''{0}''.
st-props-correct.4.2.1 = st-props-correct.4.2.1: {final} of the {base type definition} contains list.
st-props-correct.4.2.2 = st-props-correct.4.2.2: {final} of the {base type definition} contains union.
totalDigits-valid-restriction = totalDigits-valid-restriction: totalDigits value = ''{0}'' must be <= that of the base type ''{1}''.
whiteSpace-valid-restriction.1 = whiteSpace-valid-restriction.1: It is an error if whiteSpace = ''preserve'' or ''replace'' and fBase.whiteSpace = ''collapse''.
whiteSpace-valid-restriction.2 = whiteSpace-valid-restriction.2: It is an error if whiteSpace = ''preserve'' and fBase.whiteSpace = ''replace''.
w-props-correct = w-props-correct: error.
#schema for Schemas
s4s-att-invalid-value = s4s-att-invalid-value: Invalid attribute value for ''{1}'' in element ''{0}'': {2}.
s4s-att-must-appear = s4s-att-must-appear: Attribute ''{1}'' must appear in element ''{0}''.
s4s-att-not-allowed = s4s-att-not-allowed: Attribute ''{1}'' cannot appear in element ''{0}''.
s4s-elt-invalid = s4s-elt-invalid: Element ''{0}'' is not a valid element in schema document.
s4s-elt-must-match = s4s-elt-must-match: The content of ''{0}'' must match {1}.
s4s-elt-schema-ns = s4s-elt-schema-ns: The namespace of element ''{0}'' must be from the schema namespace.
s4s-elt-character = s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw ''{0}''.
# codes not defined by the spec
c-fields-xpaths = c-fields-xpaths: The field value = ''{0}'' is not valid.
c-general-xpath = c-general-xpath: The expression ''{0}'' is not valid with respect to the XPath subset supported by XML Schema.
c-general-xpath-ns = c-general-xpath-ns: a namespace prefix in XPath expression ''{0}'' was not bound to a namespace.
c-selector-xpath = c-selector-xpath: The selector value = ''{0}'' is not valid; selector xpaths cannot contain attributes.
EmptyTargetNamespace = EmptyTargetNamespace: In schema document ''{0}'', the value of the targetNamespace attribute cannot be empty string.
FacetValueFromBase = FacetValueFromBase: Value ''{0}'' of facet ''{1}'' must be from the value space of the base type.
FixedFacetValue = FixedFacetValue: ''{0}'' value = ''{1}'' must be equal to that of the base type ''{2}'' when '{'fixed'}' = true.
InvalidRegex = InvalidRegex: Pattern value ''{0}'' is not a valid regular expression: ''{1}''.
SchemaLocation = SchemaLocation: schemaLocation value = ''{0}'' must have even number of URI's.
TargetNamespace.1 = TargetNamespace.1: Expecting namespace ''{0}'', but the target namespace of the schema document is ''{1}''.
TargetNamespace.2 = TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace.
UndeclaredEntity = UndeclaredEntity: Entity ''{0}'' is not declared.
UndeclaredPrefix = UndeclaredPrefix: Cannot resolve ''{0}'' as a QName: the prefix ''{1}'' is not declared.

View file

@ -0,0 +1,22 @@
# This file stores error messages for the Xerces XML
# serializer. Many DOM Load/Save error messages also
# live here, since the serializer largely implements that package.
#
# As usual with properties files, the messages are arranged in
# key/value tuples.
#
# @version $Id: XMLSerializerMessages.properties,v 1.1.1.1 2003/06/23 06:51:31 nb131165 Exp $
ArgumentIsNull = Argument ''{0}'' is null.
NoWriterSupplied = No writer supplied for serializer.
MethodNotSupported = The method ''{0}'' is not supported by this factory.
ResetInMiddle = The serializer may not be reset in the middle of serialization.
Internal = Internal error: element state is zero.
NoName = There is no rawName and localName is null.
ElementQName = The element name ''{0}'' is not a QName.
ElementPrefix = Element ''{0}'' does not belong to any namespace: prefix could be undeclared or bound to some namespace.
AttributeQName = The attribute name ''{0}'' is not a QName.
AttributePrefix = Attribute ''{0}'' does not belong to any namespace: prefix could be undeclared or bound to some namespace.
InvalidNSDecl = Namespace declaration syntax is incorrect: {0}.
EndingCDATA = The character sequence \"]]>\" must not appear in content unless used to mark the end of a CDATA section.
SplittingCDATA = Splitting a CDATA section containing the CDATA section termination marker \"]]>\".

View file

@ -0,0 +1,213 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.Augmentations;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.NoSuchElementException;
public class AugmentationsImpl implements Augmentations {
private AugmentationsItemsContainer fAugmentationsContainer = new SmallContainer();
public Object putItem(String key, Object item) {
Object oldValue = this.fAugmentationsContainer.putItem(key, item);
if (oldValue == null && this.fAugmentationsContainer.isFull())
this.fAugmentationsContainer = this.fAugmentationsContainer.expand();
return oldValue;
}
public Object getItem(String key) {
return this.fAugmentationsContainer.getItem(key);
}
public Object removeItem(String key) {
return this.fAugmentationsContainer.removeItem(key);
}
public Enumeration keys() {
return this.fAugmentationsContainer.keys();
}
public void removeAllItems() {
this.fAugmentationsContainer.clear();
}
public String toString() {
return this.fAugmentationsContainer.toString();
}
abstract class AugmentationsItemsContainer {
public abstract Object putItem(Object param1Object1, Object param1Object2);
public abstract Object getItem(Object param1Object);
public abstract Object removeItem(Object param1Object);
public abstract Enumeration keys();
public abstract void clear();
public abstract boolean isFull();
public abstract AugmentationsItemsContainer expand();
}
class SmallContainer extends AugmentationsItemsContainer {
static final int SIZE_LIMIT = 10;
final Object[] fAugmentations = new Object[20];
int fNumEntries = 0;
public Enumeration keys() {
return new SmallContainerKeyEnumeration();
}
public Object getItem(Object key) {
for (int i = 0; i < this.fNumEntries * 2; i += 2) {
if (this.fAugmentations[i].equals(key))
return this.fAugmentations[i + 1];
}
return null;
}
public Object putItem(Object key, Object item) {
for (int i = 0; i < this.fNumEntries * 2; i += 2) {
if (this.fAugmentations[i].equals(key)) {
Object oldValue = this.fAugmentations[i + 1];
this.fAugmentations[i + 1] = item;
return oldValue;
}
}
this.fAugmentations[this.fNumEntries * 2] = key;
this.fAugmentations[this.fNumEntries * 2 + 1] = item;
this.fNumEntries++;
return null;
}
public Object removeItem(Object key) {
for (int i = 0; i < this.fNumEntries * 2; i += 2) {
if (this.fAugmentations[i].equals(key)) {
Object oldValue = this.fAugmentations[i + 1];
for (int j = i; j < this.fNumEntries * 2 - 2; j += 2) {
this.fAugmentations[j] = this.fAugmentations[j + 2];
this.fAugmentations[j + 1] = this.fAugmentations[j + 3];
}
this.fAugmentations[this.fNumEntries * 2 - 2] = null;
this.fAugmentations[this.fNumEntries * 2 - 1] = null;
this.fNumEntries--;
return oldValue;
}
}
return null;
}
public void clear() {
for (int i = 0; i < this.fNumEntries * 2; i += 2) {
this.fAugmentations[i] = null;
this.fAugmentations[i + 1] = null;
}
this.fNumEntries = 0;
}
public boolean isFull() {
return (this.fNumEntries == 10);
}
public AugmentationsImpl.AugmentationsItemsContainer expand() {
AugmentationsImpl.LargeContainer expandedContainer = new AugmentationsImpl.LargeContainer();
for (int i = 0; i < this.fNumEntries * 2; i += 2)
expandedContainer.putItem(this.fAugmentations[i], this.fAugmentations[i + 1]);
return expandedContainer;
}
public String toString() {
StringBuffer buff = new StringBuffer();
buff.append("SmallContainer - fNumEntries == " + this.fNumEntries);
for (int i = 0; i < 20; i += 2) {
buff.append("\nfAugmentations[");
buff.append(i);
buff.append("] == ");
buff.append(this.fAugmentations[i]);
buff.append("; fAugmentations[");
buff.append(i + 1);
buff.append("] == ");
buff.append(this.fAugmentations[i + 1]);
}
return buff.toString();
}
class SmallContainerKeyEnumeration implements Enumeration {
Object[] enumArray = new Object[SmallContainer.this.fNumEntries];
int next = 0;
SmallContainerKeyEnumeration() {
for (int i = 0; i < this$0.fNumEntries; i++)
this.enumArray[i] = this$0.fAugmentations[i * 2];
}
public boolean hasMoreElements() {
return (this.next < this.enumArray.length);
}
public Object nextElement() {
if (this.next >= this.enumArray.length)
throw new NoSuchElementException();
Object nextVal = this.enumArray[this.next];
this.enumArray[this.next] = null;
this.next++;
return nextVal;
}
}
}
class LargeContainer extends AugmentationsItemsContainer {
final Hashtable fAugmentations;
LargeContainer() {
this.fAugmentations = new Hashtable();
}
public Object getItem(Object key) {
return this.fAugmentations.get(key);
}
public Object putItem(Object key, Object item) {
return this.fAugmentations.put(key, item);
}
public Object removeItem(Object key) {
return this.fAugmentations.remove(key);
}
public Enumeration keys() {
return this.fAugmentations.keys();
}
public void clear() {
this.fAugmentations.clear();
}
public boolean isFull() {
return false;
}
public AugmentationsImpl.AugmentationsItemsContainer expand() {
return this;
}
public String toString() {
StringBuffer buff = new StringBuffer();
buff.append("LargeContainer");
Enumeration keys = this.fAugmentations.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
buff.append("\nkey == ");
buff.append(key);
buff.append("; value == ");
buff.append(this.fAugmentations.get(key));
}
return buff.toString();
}
}
}

View file

@ -0,0 +1,52 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.XNIException;
import com.sun.xml.stream.xerces.xni.parser.XMLErrorHandler;
import com.sun.xml.stream.xerces.xni.parser.XMLParseException;
import java.io.PrintWriter;
public class DefaultErrorHandler implements XMLErrorHandler {
protected PrintWriter fOut;
public DefaultErrorHandler() {
this(new PrintWriter(System.err));
}
public DefaultErrorHandler(PrintWriter out) {
this.fOut = out;
}
public void warning(String domain, String key, XMLParseException ex) throws XNIException {
printError("Warning", ex);
}
public void error(String domain, String key, XMLParseException ex) throws XNIException {
printError("Error", ex);
}
public void fatalError(String domain, String key, XMLParseException ex) throws XNIException {
printError("Fatal Error", ex);
throw ex;
}
private void printError(String type, XMLParseException ex) {
this.fOut.print("[");
this.fOut.print(type);
this.fOut.print("] ");
String systemId = ex.getExpandedSystemId();
if (systemId != null) {
int index = systemId.lastIndexOf('/');
if (index != -1)
systemId = systemId.substring(index + 1);
this.fOut.print(systemId);
}
this.fOut.print(':');
this.fOut.print(ex.getLineNumber());
this.fOut.print(':');
this.fOut.print(ex.getColumnNumber());
this.fOut.print(": ");
this.fOut.print(ex.getMessage());
this.fOut.println();
this.fOut.flush();
}
}

View file

@ -0,0 +1,436 @@
package com.sun.xml.stream.xerces.util;
import java.util.Hashtable;
public class EncodingMap {
protected static final Hashtable fIANA2JavaMap = new Hashtable();
protected static final Hashtable fJava2IANAMap = new Hashtable();
static {
fIANA2JavaMap.put("BIG5", "Big5");
fIANA2JavaMap.put("CSBIG5", "Big5");
fIANA2JavaMap.put("CP037", "CP037");
fIANA2JavaMap.put("IBM037", "CP037");
fIANA2JavaMap.put("CSIBM037", "CP037");
fIANA2JavaMap.put("EBCDIC-CP-US", "CP037");
fIANA2JavaMap.put("EBCDIC-CP-CA", "CP037");
fIANA2JavaMap.put("EBCDIC-CP-NL", "CP037");
fIANA2JavaMap.put("EBCDIC-CP-WT", "CP037");
fIANA2JavaMap.put("IBM273", "CP273");
fIANA2JavaMap.put("CP273", "CP273");
fIANA2JavaMap.put("CSIBM273", "CP273");
fIANA2JavaMap.put("IBM277", "CP277");
fIANA2JavaMap.put("CP277", "CP277");
fIANA2JavaMap.put("CSIBM277", "CP277");
fIANA2JavaMap.put("EBCDIC-CP-DK", "CP277");
fIANA2JavaMap.put("EBCDIC-CP-NO", "CP277");
fIANA2JavaMap.put("IBM278", "CP278");
fIANA2JavaMap.put("CP278", "CP278");
fIANA2JavaMap.put("CSIBM278", "CP278");
fIANA2JavaMap.put("EBCDIC-CP-FI", "CP278");
fIANA2JavaMap.put("EBCDIC-CP-SE", "CP278");
fIANA2JavaMap.put("IBM280", "CP280");
fIANA2JavaMap.put("CP280", "CP280");
fIANA2JavaMap.put("CSIBM280", "CP280");
fIANA2JavaMap.put("EBCDIC-CP-IT", "CP280");
fIANA2JavaMap.put("IBM284", "CP284");
fIANA2JavaMap.put("CP284", "CP284");
fIANA2JavaMap.put("CSIBM284", "CP284");
fIANA2JavaMap.put("EBCDIC-CP-ES", "CP284");
fIANA2JavaMap.put("EBCDIC-CP-GB", "CP285");
fIANA2JavaMap.put("IBM285", "CP285");
fIANA2JavaMap.put("CP285", "CP285");
fIANA2JavaMap.put("CSIBM285", "CP285");
fIANA2JavaMap.put("EBCDIC-JP-KANA", "CP290");
fIANA2JavaMap.put("IBM290", "CP290");
fIANA2JavaMap.put("CP290", "CP290");
fIANA2JavaMap.put("CSIBM290", "CP290");
fIANA2JavaMap.put("EBCDIC-CP-FR", "CP297");
fIANA2JavaMap.put("IBM297", "CP297");
fIANA2JavaMap.put("CP297", "CP297");
fIANA2JavaMap.put("CSIBM297", "CP297");
fIANA2JavaMap.put("EBCDIC-CP-AR1", "CP420");
fIANA2JavaMap.put("IBM420", "CP420");
fIANA2JavaMap.put("CP420", "CP420");
fIANA2JavaMap.put("CSIBM420", "CP420");
fIANA2JavaMap.put("EBCDIC-CP-HE", "CP424");
fIANA2JavaMap.put("IBM424", "CP424");
fIANA2JavaMap.put("CP424", "CP424");
fIANA2JavaMap.put("CSIBM424", "CP424");
fIANA2JavaMap.put("IBM437", "CP437");
fIANA2JavaMap.put("437", "CP437");
fIANA2JavaMap.put("CP437", "CP437");
fIANA2JavaMap.put("CSPC8CODEPAGE437", "CP437");
fIANA2JavaMap.put("EBCDIC-CP-CH", "CP500");
fIANA2JavaMap.put("IBM500", "CP500");
fIANA2JavaMap.put("CP500", "CP500");
fIANA2JavaMap.put("CSIBM500", "CP500");
fIANA2JavaMap.put("EBCDIC-CP-CH", "CP500");
fIANA2JavaMap.put("EBCDIC-CP-BE", "CP500");
fIANA2JavaMap.put("IBM775", "CP775");
fIANA2JavaMap.put("CP775", "CP775");
fIANA2JavaMap.put("CSPC775BALTIC", "CP775");
fIANA2JavaMap.put("IBM850", "CP850");
fIANA2JavaMap.put("850", "CP850");
fIANA2JavaMap.put("CP850", "CP850");
fIANA2JavaMap.put("CSPC850MULTILINGUAL", "CP850");
fIANA2JavaMap.put("IBM852", "CP852");
fIANA2JavaMap.put("852", "CP852");
fIANA2JavaMap.put("CP852", "CP852");
fIANA2JavaMap.put("CSPCP852", "CP852");
fIANA2JavaMap.put("IBM855", "CP855");
fIANA2JavaMap.put("855", "CP855");
fIANA2JavaMap.put("CP855", "CP855");
fIANA2JavaMap.put("CSIBM855", "CP855");
fIANA2JavaMap.put("IBM857", "CP857");
fIANA2JavaMap.put("857", "CP857");
fIANA2JavaMap.put("CP857", "CP857");
fIANA2JavaMap.put("CSIBM857", "CP857");
fIANA2JavaMap.put("IBM00858", "CP858");
fIANA2JavaMap.put("CP00858", "CP858");
fIANA2JavaMap.put("CCSID00858", "CP858");
fIANA2JavaMap.put("IBM860", "CP860");
fIANA2JavaMap.put("860", "CP860");
fIANA2JavaMap.put("CP860", "CP860");
fIANA2JavaMap.put("CSIBM860", "CP860");
fIANA2JavaMap.put("IBM861", "CP861");
fIANA2JavaMap.put("861", "CP861");
fIANA2JavaMap.put("CP861", "CP861");
fIANA2JavaMap.put("CP-IS", "CP861");
fIANA2JavaMap.put("CSIBM861", "CP861");
fIANA2JavaMap.put("IBM862", "CP862");
fIANA2JavaMap.put("862", "CP862");
fIANA2JavaMap.put("CP862", "CP862");
fIANA2JavaMap.put("CSPC862LATINHEBREW", "CP862");
fIANA2JavaMap.put("IBM863", "CP863");
fIANA2JavaMap.put("863", "CP863");
fIANA2JavaMap.put("CP863", "CP863");
fIANA2JavaMap.put("CSIBM863", "CP863");
fIANA2JavaMap.put("IBM864", "CP864");
fIANA2JavaMap.put("CP864", "CP864");
fIANA2JavaMap.put("CSIBM864", "CP864");
fIANA2JavaMap.put("IBM865", "CP865");
fIANA2JavaMap.put("865", "CP865");
fIANA2JavaMap.put("CP865", "CP865");
fIANA2JavaMap.put("CSIBM865", "CP865");
fIANA2JavaMap.put("IBM866", "CP866");
fIANA2JavaMap.put("866", "CP866");
fIANA2JavaMap.put("CP866", "CP866");
fIANA2JavaMap.put("CSIBM866", "CP866");
fIANA2JavaMap.put("IBM868", "CP868");
fIANA2JavaMap.put("CP868", "CP868");
fIANA2JavaMap.put("CSIBM868", "CP868");
fIANA2JavaMap.put("CP-AR", "CP868");
fIANA2JavaMap.put("IBM869", "CP869");
fIANA2JavaMap.put("CP869", "CP869");
fIANA2JavaMap.put("CSIBM869", "CP869");
fIANA2JavaMap.put("CP-GR", "CP869");
fIANA2JavaMap.put("IBM870", "CP870");
fIANA2JavaMap.put("CP870", "CP870");
fIANA2JavaMap.put("CSIBM870", "CP870");
fIANA2JavaMap.put("EBCDIC-CP-ROECE", "CP870");
fIANA2JavaMap.put("EBCDIC-CP-YU", "CP870");
fIANA2JavaMap.put("IBM871", "CP871");
fIANA2JavaMap.put("CP871", "CP871");
fIANA2JavaMap.put("CSIBM871", "CP871");
fIANA2JavaMap.put("EBCDIC-CP-IS", "CP871");
fIANA2JavaMap.put("IBM918", "CP918");
fIANA2JavaMap.put("CP918", "CP918");
fIANA2JavaMap.put("CSIBM918", "CP918");
fIANA2JavaMap.put("EBCDIC-CP-AR2", "CP918");
fIANA2JavaMap.put("IBM00924", "CP924");
fIANA2JavaMap.put("CP00924", "CP924");
fIANA2JavaMap.put("CCSID00924", "CP924");
fIANA2JavaMap.put("EBCDIC-LATIN9--EURO", "CP924");
fIANA2JavaMap.put("IBM1026", "CP1026");
fIANA2JavaMap.put("CP1026", "CP1026");
fIANA2JavaMap.put("CSIBM1026", "CP1026");
fIANA2JavaMap.put("IBM01140", "Cp1140");
fIANA2JavaMap.put("CP01140", "Cp1140");
fIANA2JavaMap.put("CCSID01140", "Cp1140");
fIANA2JavaMap.put("IBM01141", "Cp1141");
fIANA2JavaMap.put("CP01141", "Cp1141");
fIANA2JavaMap.put("CCSID01141", "Cp1141");
fIANA2JavaMap.put("IBM01142", "Cp1142");
fIANA2JavaMap.put("CP01142", "Cp1142");
fIANA2JavaMap.put("CCSID01142", "Cp1142");
fIANA2JavaMap.put("IBM01143", "Cp1143");
fIANA2JavaMap.put("CP01143", "Cp1143");
fIANA2JavaMap.put("CCSID01143", "Cp1143");
fIANA2JavaMap.put("IBM01144", "Cp1144");
fIANA2JavaMap.put("CP01144", "Cp1144");
fIANA2JavaMap.put("CCSID01144", "Cp1144");
fIANA2JavaMap.put("IBM01145", "Cp1145");
fIANA2JavaMap.put("CP01145", "Cp1145");
fIANA2JavaMap.put("CCSID01145", "Cp1145");
fIANA2JavaMap.put("IBM01146", "Cp1146");
fIANA2JavaMap.put("CP01146", "Cp1146");
fIANA2JavaMap.put("CCSID01146", "Cp1146");
fIANA2JavaMap.put("IBM01147", "Cp1147");
fIANA2JavaMap.put("CP01147", "Cp1147");
fIANA2JavaMap.put("CCSID01147", "Cp1147");
fIANA2JavaMap.put("IBM01148", "Cp1148");
fIANA2JavaMap.put("CP01148", "Cp1148");
fIANA2JavaMap.put("CCSID01148", "Cp1148");
fIANA2JavaMap.put("IBM01149", "Cp1149");
fIANA2JavaMap.put("CP01149", "Cp1149");
fIANA2JavaMap.put("CCSID01149", "Cp1149");
fIANA2JavaMap.put("EUC-JP", "EUCJIS");
fIANA2JavaMap.put("CSEUCPKDFMTJAPANESE", "EUCJIS");
fIANA2JavaMap.put("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", "EUCJIS");
fIANA2JavaMap.put("EUC-KR", "KSC5601");
fIANA2JavaMap.put("GB2312", "GB2312");
fIANA2JavaMap.put("CSGB2312", "GB2312");
fIANA2JavaMap.put("ISO-2022-JP", "JIS");
fIANA2JavaMap.put("CSISO2022JP", "JIS");
fIANA2JavaMap.put("ISO-2022-KR", "ISO2022KR");
fIANA2JavaMap.put("CSISO2022KR", "ISO2022KR");
fIANA2JavaMap.put("ISO-2022-CN", "ISO2022CN");
fIANA2JavaMap.put("X0201", "JIS0201");
fIANA2JavaMap.put("CSISO13JISC6220JP", "JIS0201");
fIANA2JavaMap.put("X0208", "JIS0208");
fIANA2JavaMap.put("ISO-IR-87", "JIS0208");
fIANA2JavaMap.put("X0208dbiJIS_X0208-1983", "JIS0208");
fIANA2JavaMap.put("CSISO87JISX0208", "JIS0208");
fIANA2JavaMap.put("X0212", "JIS0212");
fIANA2JavaMap.put("ISO-IR-159", "JIS0212");
fIANA2JavaMap.put("CSISO159JISX02121990", "JIS0212");
fIANA2JavaMap.put("GB18030", "GB18030");
fIANA2JavaMap.put("SHIFT_JIS", "SJIS");
fIANA2JavaMap.put("CSSHIFTJIS", "SJIS");
fIANA2JavaMap.put("MS_KANJI", "SJIS");
fIANA2JavaMap.put("WINDOWS-31J", "MS932");
fIANA2JavaMap.put("CSWINDOWS31J", "MS932");
fIANA2JavaMap.put("WINDOWS-1250", "Cp1250");
fIANA2JavaMap.put("WINDOWS-1251", "Cp1251");
fIANA2JavaMap.put("WINDOWS-1252", "Cp1252");
fIANA2JavaMap.put("WINDOWS-1253", "Cp1253");
fIANA2JavaMap.put("WINDOWS-1254", "Cp1254");
fIANA2JavaMap.put("WINDOWS-1255", "Cp1255");
fIANA2JavaMap.put("WINDOWS-1256", "Cp1256");
fIANA2JavaMap.put("WINDOWS-1257", "Cp1257");
fIANA2JavaMap.put("WINDOWS-1258", "Cp1258");
fIANA2JavaMap.put("TIS-620", "TIS620");
fIANA2JavaMap.put("ISO-8859-1", "ISO8859_1");
fIANA2JavaMap.put("ISO-IR-100", "ISO8859_1");
fIANA2JavaMap.put("ISO_8859-1", "ISO8859_1");
fIANA2JavaMap.put("LATIN1", "ISO8859_1");
fIANA2JavaMap.put("CSISOLATIN1", "ISO8859_1");
fIANA2JavaMap.put("L1", "ISO8859_1");
fIANA2JavaMap.put("IBM819", "ISO8859_1");
fIANA2JavaMap.put("CP819", "ISO8859_1");
fIANA2JavaMap.put("ISO-8859-2", "ISO8859_2");
fIANA2JavaMap.put("ISO-IR-101", "ISO8859_2");
fIANA2JavaMap.put("ISO_8859-2", "ISO8859_2");
fIANA2JavaMap.put("LATIN2", "ISO8859_2");
fIANA2JavaMap.put("CSISOLATIN2", "ISO8859_2");
fIANA2JavaMap.put("L2", "ISO8859_2");
fIANA2JavaMap.put("ISO-8859-3", "ISO8859_3");
fIANA2JavaMap.put("ISO-IR-109", "ISO8859_3");
fIANA2JavaMap.put("ISO_8859-3", "ISO8859_3");
fIANA2JavaMap.put("LATIN3", "ISO8859_3");
fIANA2JavaMap.put("CSISOLATIN3", "ISO8859_3");
fIANA2JavaMap.put("L3", "ISO8859_3");
fIANA2JavaMap.put("ISO-8859-4", "ISO8859_4");
fIANA2JavaMap.put("ISO-IR-110", "ISO8859_4");
fIANA2JavaMap.put("ISO_8859-4", "ISO8859_4");
fIANA2JavaMap.put("LATIN4", "ISO8859_4");
fIANA2JavaMap.put("CSISOLATIN4", "ISO8859_4");
fIANA2JavaMap.put("L4", "ISO8859_4");
fIANA2JavaMap.put("ISO-8859-5", "ISO8859_5");
fIANA2JavaMap.put("ISO-IR-144", "ISO8859_5");
fIANA2JavaMap.put("ISO_8859-5", "ISO8859_5");
fIANA2JavaMap.put("CYRILLIC", "ISO8859_5");
fIANA2JavaMap.put("CSISOLATINCYRILLIC", "ISO8859_5");
fIANA2JavaMap.put("ISO-8859-6", "ISO8859_6");
fIANA2JavaMap.put("ISO-IR-127", "ISO8859_6");
fIANA2JavaMap.put("ISO_8859-6", "ISO8859_6");
fIANA2JavaMap.put("ECMA-114", "ISO8859_6");
fIANA2JavaMap.put("ASMO-708", "ISO8859_6");
fIANA2JavaMap.put("ARABIC", "ISO8859_6");
fIANA2JavaMap.put("CSISOLATINARABIC", "ISO8859_6");
fIANA2JavaMap.put("ISO-8859-7", "ISO8859_7");
fIANA2JavaMap.put("ISO-IR-126", "ISO8859_7");
fIANA2JavaMap.put("ISO_8859-7", "ISO8859_7");
fIANA2JavaMap.put("ELOT_928", "ISO8859_7");
fIANA2JavaMap.put("ECMA-118", "ISO8859_7");
fIANA2JavaMap.put("GREEK", "ISO8859_7");
fIANA2JavaMap.put("CSISOLATINGREEK", "ISO8859_7");
fIANA2JavaMap.put("GREEK8", "ISO8859_7");
fIANA2JavaMap.put("ISO-8859-8", "ISO8859_8");
fIANA2JavaMap.put("ISO-8859-8-I", "ISO8859_8");
fIANA2JavaMap.put("ISO-IR-138", "ISO8859_8");
fIANA2JavaMap.put("ISO_8859-8", "ISO8859_8");
fIANA2JavaMap.put("HEBREW", "ISO8859_8");
fIANA2JavaMap.put("CSISOLATINHEBREW", "ISO8859_8");
fIANA2JavaMap.put("ISO-8859-9", "ISO8859_9");
fIANA2JavaMap.put("ISO-IR-148", "ISO8859_9");
fIANA2JavaMap.put("ISO_8859-9", "ISO8859_9");
fIANA2JavaMap.put("LATIN5", "ISO8859_9");
fIANA2JavaMap.put("CSISOLATIN5", "ISO8859_9");
fIANA2JavaMap.put("L5", "ISO8859_9");
fIANA2JavaMap.put("ISO-8859-15", "ISO8859_15");
fIANA2JavaMap.put("ISO_8859-15", "ISO8859_15");
fIANA2JavaMap.put("KOI8-R", "KOI8_R");
fIANA2JavaMap.put("CSKOI8R", "KOI8_R");
fIANA2JavaMap.put("US-ASCII", "ASCII");
fIANA2JavaMap.put("ISO-IR-6", "ASCII");
fIANA2JavaMap.put("ANSI_X3.4-1986", "ASCII");
fIANA2JavaMap.put("ISO_646.IRV:1991", "ASCII");
fIANA2JavaMap.put("ASCII", "ASCII");
fIANA2JavaMap.put("CSASCII", "ASCII");
fIANA2JavaMap.put("ISO646-US", "ASCII");
fIANA2JavaMap.put("US", "ASCII");
fIANA2JavaMap.put("IBM367", "ASCII");
fIANA2JavaMap.put("CP367", "ASCII");
fIANA2JavaMap.put("UTF-8", "UTF8");
fIANA2JavaMap.put("UTF-16", "UTF-16");
fIANA2JavaMap.put("UTF-16BE", "UnicodeBig");
fIANA2JavaMap.put("UTF-16LE", "UnicodeLittle");
fIANA2JavaMap.put("IBM-1047", "Cp1047");
fIANA2JavaMap.put("IBM1047", "Cp1047");
fIANA2JavaMap.put("CP1047", "Cp1047");
fIANA2JavaMap.put("IBM-37", "CP037");
fIANA2JavaMap.put("IBM-273", "CP273");
fIANA2JavaMap.put("IBM-277", "CP277");
fIANA2JavaMap.put("IBM-278", "CP278");
fIANA2JavaMap.put("IBM-280", "CP280");
fIANA2JavaMap.put("IBM-284", "CP284");
fIANA2JavaMap.put("IBM-285", "CP285");
fIANA2JavaMap.put("IBM-290", "CP290");
fIANA2JavaMap.put("IBM-297", "CP297");
fIANA2JavaMap.put("IBM-420", "CP420");
fIANA2JavaMap.put("IBM-424", "CP424");
fIANA2JavaMap.put("IBM-437", "CP437");
fIANA2JavaMap.put("IBM-500", "CP500");
fIANA2JavaMap.put("IBM-775", "CP775");
fIANA2JavaMap.put("IBM-850", "CP850");
fIANA2JavaMap.put("IBM-852", "CP852");
fIANA2JavaMap.put("IBM-855", "CP855");
fIANA2JavaMap.put("IBM-857", "CP857");
fIANA2JavaMap.put("IBM-858", "CP858");
fIANA2JavaMap.put("IBM-860", "CP860");
fIANA2JavaMap.put("IBM-861", "CP861");
fIANA2JavaMap.put("IBM-862", "CP862");
fIANA2JavaMap.put("IBM-863", "CP863");
fIANA2JavaMap.put("IBM-864", "CP864");
fIANA2JavaMap.put("IBM-865", "CP865");
fIANA2JavaMap.put("IBM-866", "CP866");
fIANA2JavaMap.put("IBM-868", "CP868");
fIANA2JavaMap.put("IBM-869", "CP869");
fIANA2JavaMap.put("IBM-870", "CP870");
fIANA2JavaMap.put("IBM-871", "CP871");
fIANA2JavaMap.put("IBM-918", "CP918");
fIANA2JavaMap.put("IBM-924", "CP924");
fIANA2JavaMap.put("IBM-1026", "CP1026");
fIANA2JavaMap.put("IBM-1140", "Cp1140");
fIANA2JavaMap.put("IBM-1141", "Cp1141");
fIANA2JavaMap.put("IBM-1142", "Cp1142");
fIANA2JavaMap.put("IBM-1143", "Cp1143");
fIANA2JavaMap.put("IBM-1144", "Cp1144");
fIANA2JavaMap.put("IBM-1145", "Cp1145");
fIANA2JavaMap.put("IBM-1146", "Cp1146");
fIANA2JavaMap.put("IBM-1147", "Cp1147");
fIANA2JavaMap.put("IBM-1148", "Cp1148");
fIANA2JavaMap.put("IBM-1149", "Cp1149");
fIANA2JavaMap.put("IBM-819", "ISO8859_1");
fIANA2JavaMap.put("IBM-367", "ASCII");
fJava2IANAMap.put("ISO8859_1", "ISO-8859-1");
fJava2IANAMap.put("ISO8859_2", "ISO-8859-2");
fJava2IANAMap.put("ISO8859_3", "ISO-8859-3");
fJava2IANAMap.put("ISO8859_4", "ISO-8859-4");
fJava2IANAMap.put("ISO8859_5", "ISO-8859-5");
fJava2IANAMap.put("ISO8859_6", "ISO-8859-6");
fJava2IANAMap.put("ISO8859_7", "ISO-8859-7");
fJava2IANAMap.put("ISO8859_8", "ISO-8859-8");
fJava2IANAMap.put("ISO8859_9", "ISO-8859-9");
fJava2IANAMap.put("ISO8859_15", "ISO-8859-15");
fJava2IANAMap.put("Big5", "BIG5");
fJava2IANAMap.put("CP037", "EBCDIC-CP-US");
fJava2IANAMap.put("CP273", "IBM273");
fJava2IANAMap.put("CP277", "EBCDIC-CP-DK");
fJava2IANAMap.put("CP278", "EBCDIC-CP-FI");
fJava2IANAMap.put("CP280", "EBCDIC-CP-IT");
fJava2IANAMap.put("CP284", "EBCDIC-CP-ES");
fJava2IANAMap.put("CP285", "EBCDIC-CP-GB");
fJava2IANAMap.put("CP290", "EBCDIC-JP-KANA");
fJava2IANAMap.put("CP297", "EBCDIC-CP-FR");
fJava2IANAMap.put("CP420", "EBCDIC-CP-AR1");
fJava2IANAMap.put("CP424", "EBCDIC-CP-HE");
fJava2IANAMap.put("CP437", "IBM437");
fJava2IANAMap.put("CP500", "EBCDIC-CP-CH");
fJava2IANAMap.put("CP775", "IBM775");
fJava2IANAMap.put("CP850", "IBM850");
fJava2IANAMap.put("CP852", "IBM852");
fJava2IANAMap.put("CP855", "IBM855");
fJava2IANAMap.put("CP857", "IBM857");
fJava2IANAMap.put("CP858", "IBM00858");
fJava2IANAMap.put("CP860", "IBM860");
fJava2IANAMap.put("CP861", "IBM861");
fJava2IANAMap.put("CP862", "IBM862");
fJava2IANAMap.put("CP863", "IBM863");
fJava2IANAMap.put("CP864", "IBM864");
fJava2IANAMap.put("CP865", "IBM865");
fJava2IANAMap.put("CP866", "IBM866");
fJava2IANAMap.put("CP868", "IBM868");
fJava2IANAMap.put("CP869", "IBM869");
fJava2IANAMap.put("CP870", "EBCDIC-CP-ROECE");
fJava2IANAMap.put("CP871", "EBCDIC-CP-IS");
fJava2IANAMap.put("CP918", "EBCDIC-CP-AR2");
fJava2IANAMap.put("CP924", "IBM00924");
fJava2IANAMap.put("CP1026", "IBM1026");
fJava2IANAMap.put("Cp01140", "IBM01140");
fJava2IANAMap.put("Cp01141", "IBM01141");
fJava2IANAMap.put("Cp01142", "IBM01142");
fJava2IANAMap.put("Cp01143", "IBM01143");
fJava2IANAMap.put("Cp01144", "IBM01144");
fJava2IANAMap.put("Cp01145", "IBM01145");
fJava2IANAMap.put("Cp01146", "IBM01146");
fJava2IANAMap.put("Cp01147", "IBM01147");
fJava2IANAMap.put("Cp01148", "IBM01148");
fJava2IANAMap.put("Cp01149", "IBM01149");
fJava2IANAMap.put("EUCJIS", "EUC-JP");
fJava2IANAMap.put("GB2312", "GB2312");
fJava2IANAMap.put("ISO2022KR", "ISO-2022-KR");
fJava2IANAMap.put("ISO2022CN", "ISO-2022-CN");
fJava2IANAMap.put("JIS", "ISO-2022-JP");
fJava2IANAMap.put("KOI8_R", "KOI8-R");
fJava2IANAMap.put("KSC5601", "EUC-KR");
fJava2IANAMap.put("GB18030", "GB18030");
fJava2IANAMap.put("SJIS", "SHIFT_JIS");
fJava2IANAMap.put("MS932", "WINDOWS-31J");
fJava2IANAMap.put("UTF8", "UTF-8");
fJava2IANAMap.put("Unicode", "UTF-16");
fJava2IANAMap.put("UnicodeBig", "UTF-16BE");
fJava2IANAMap.put("UnicodeLittle", "UTF-16LE");
fJava2IANAMap.put("JIS0201", "X0201");
fJava2IANAMap.put("JIS0208", "X0208");
fJava2IANAMap.put("JIS0212", "ISO-IR-159");
fJava2IANAMap.put("CP1047", "IBM1047");
}
public static void putIANA2JavaMapping(String ianaEncoding, String javaEncoding) {
fIANA2JavaMap.put(ianaEncoding, javaEncoding);
}
public static String getIANA2JavaMapping(String ianaEncoding) {
return (String)fIANA2JavaMap.get(ianaEncoding);
}
public static String removeIANA2JavaMapping(String ianaEncoding) {
return (String)fIANA2JavaMap.remove(ianaEncoding);
}
public static void putJava2IANAMapping(String javaEncoding, String ianaEncoding) {
fJava2IANAMap.put(javaEncoding, ianaEncoding);
}
public static String getJava2IANAMapping(String javaEncoding) {
return (String)fJava2IANAMap.get(javaEncoding);
}
public static String removeJava2IANAMapping(String javaEncoding) {
return (String)fJava2IANAMap.remove(javaEncoding);
}
}

View file

@ -0,0 +1,56 @@
package com.sun.xml.stream.xerces.util;
public final class IntStack {
private int fDepth;
private int[] fData;
public int size() {
return this.fDepth;
}
public void push(int value) {
ensureCapacity(this.fDepth + 1);
this.fData[this.fDepth++] = value;
}
public int peek() {
return this.fData[this.fDepth - 1];
}
public int pop() {
return this.fData[--this.fDepth];
}
public void clear() {
this.fDepth = 0;
}
public void print() {
System.out.print('(');
System.out.print(this.fDepth);
System.out.print(") {");
for (int i = 0; i < this.fDepth; i++) {
if (i == 3) {
System.out.print(" ...");
break;
}
System.out.print(' ');
System.out.print(this.fData[i]);
if (i < this.fDepth - 1)
System.out.print(',');
}
System.out.print(" }");
System.out.println();
}
private void ensureCapacity(int size) {
if (this.fData == null) {
this.fData = new int[32];
} else if (this.fData.length <= size) {
int[] newdata = new int[this.fData.length * 2];
System.arraycopy(this.fData, 0, newdata, 0, this.fData.length);
this.fData = newdata;
}
}
}

View file

@ -0,0 +1,8 @@
package com.sun.xml.stream.xerces.util;
import java.util.Locale;
import java.util.MissingResourceException;
public interface MessageFormatter {
String formatMessage(Locale paramLocale, String paramString, Object[] paramArrayOfObject) throws MissingResourceException;
}

View file

@ -0,0 +1,36 @@
package com.sun.xml.stream.xerces.util;
import java.util.Iterator;
import java.util.Vector;
import javax.xml.namespace.NamespaceContext;
public class NamespaceContextWrapper implements NamespaceContext {
private com.sun.xml.stream.xerces.xni.NamespaceContext fNamespaceContext;
public NamespaceContextWrapper(com.sun.xml.stream.xerces.xni.NamespaceContext namespaceContext) {
this.fNamespaceContext = namespaceContext;
}
public String getNamespaceURI(String prefix) {
if (prefix == null)
throw new IllegalArgumentException("Prefix can't be null");
return this.fNamespaceContext.getURI(prefix);
}
public String getPrefix(String namespaceURI) {
if (namespaceURI == null || namespaceURI.trim().length() == 0)
throw new IllegalArgumentException("URI can't be null or empty String");
return this.fNamespaceContext.getPrefix(namespaceURI);
}
public Iterator getPrefixes(String namespaceURI) {
if (namespaceURI == null || namespaceURI.trim().length() == 0)
throw new IllegalArgumentException("URI can't be null or empty String");
Vector vector = this.fNamespaceContext.getPrefixes(namespaceURI);
return vector.iterator();
}
public com.sun.xml.stream.xerces.xni.NamespaceContext getNamespaceContext() {
return this.fNamespaceContext;
}
}

View file

@ -0,0 +1,225 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.NamespaceContext;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Vector;
public class NamespaceSupport implements NamespaceContext {
protected String[] fNamespace = new String[32];
protected int fNamespaceSize;
protected int[] fContext = new int[8];
protected int fCurrentContext;
protected String[] fPrefixes = new String[16];
public NamespaceSupport() {}
public NamespaceSupport(NamespaceContext context) {
pushContext();
Enumeration<String> prefixes = context.getAllPrefixes();
while (prefixes.hasMoreElements()) {
String prefix = prefixes.nextElement();
String uri = context.getURI(prefix);
declarePrefix(prefix, uri);
}
}
public void reset() {
this.fNamespaceSize = 0;
this.fCurrentContext = 0;
this.fNamespace[this.fNamespaceSize++] = XMLSymbols.PREFIX_XML;
this.fNamespace[this.fNamespaceSize++] = NamespaceContext.XML_URI;
this.fNamespace[this.fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS;
this.fNamespace[this.fNamespaceSize++] = NamespaceContext.XMLNS_URI;
this.fContext[this.fCurrentContext] = this.fNamespaceSize;
}
public void pushContext() {
if (this.fCurrentContext + 1 == this.fContext.length) {
int[] contextarray = new int[this.fContext.length * 2];
System.arraycopy(this.fContext, 0, contextarray, 0, this.fContext.length);
this.fContext = contextarray;
}
this.fContext[++this.fCurrentContext] = this.fNamespaceSize;
}
public void popContext() {
this.fNamespaceSize = this.fContext[this.fCurrentContext--];
}
public boolean declarePrefix(String prefix, String uri) {
if (prefix == XMLSymbols.PREFIX_XML || prefix == XMLSymbols.PREFIX_XMLNS)
return false;
for (int i = this.fNamespaceSize; i > this.fContext[this.fCurrentContext]; i -= 2) {
if (this.fNamespace[i - 2] == prefix) {
this.fNamespace[i - 1] = uri;
return true;
}
}
if (this.fNamespaceSize == this.fNamespace.length) {
String[] namespacearray = new String[this.fNamespaceSize * 2];
System.arraycopy(this.fNamespace, 0, namespacearray, 0, this.fNamespaceSize);
this.fNamespace = namespacearray;
}
this.fNamespace[this.fNamespaceSize++] = prefix;
this.fNamespace[this.fNamespaceSize++] = uri;
return true;
}
public String getURI(String prefix) {
for (int i = this.fNamespaceSize; i > 0; i -= 2) {
if (this.fNamespace[i - 2] == prefix)
return this.fNamespace[i - 1];
}
return null;
}
public String getPrefix(String uri) {
for (int i = this.fNamespaceSize; i > 0; i -= 2) {
if (this.fNamespace[i - 1] == uri &&
getURI(this.fNamespace[i - 2]) == uri)
return this.fNamespace[i - 2];
}
return null;
}
public int getDeclaredPrefixCount() {
return (this.fNamespaceSize - this.fContext[this.fCurrentContext]) / 2;
}
public String getDeclaredPrefixAt(int index) {
return this.fNamespace[this.fContext[this.fCurrentContext] + index * 2];
}
public Iterator getPrefixes() {
int count = 0;
if (this.fPrefixes.length < this.fNamespace.length / 2) {
String[] prefixes = new String[this.fNamespaceSize];
this.fPrefixes = prefixes;
}
String prefix = null;
boolean unique = true;
for (int i = 2; i < this.fNamespaceSize - 2; i += 2) {
prefix = this.fNamespace[i + 2];
for (int k = 0; k < count; k++) {
if (this.fPrefixes[k] == prefix) {
unique = false;
break;
}
}
if (unique)
this.fPrefixes[count++] = prefix;
unique = true;
}
return new IteratorPrefixes(this.fPrefixes, count);
}
public Enumeration getAllPrefixes() {
int count = 0;
if (this.fPrefixes.length < this.fNamespace.length / 2) {
String[] prefixes = new String[this.fNamespaceSize];
this.fPrefixes = prefixes;
}
String prefix = null;
boolean unique = true;
for (int i = 2; i < this.fNamespaceSize - 2; i += 2) {
prefix = this.fNamespace[i + 2];
for (int k = 0; k < count; k++) {
if (this.fPrefixes[k] == prefix) {
unique = false;
break;
}
}
if (unique)
this.fPrefixes[count++] = prefix;
unique = true;
}
return new Prefixes(this.fPrefixes, count);
}
public Vector getPrefixes(String uri) {
int count = 0;
String prefix = null;
boolean unique = true;
Vector<String> prefixList = new Vector();
for (int i = this.fNamespaceSize; i > 0; i -= 2) {
if (this.fNamespace[i - 1] == uri &&
!prefixList.contains(this.fNamespace[i - 2]))
prefixList.add(this.fNamespace[i - 2]);
}
return prefixList;
}
protected final class IteratorPrefixes implements Iterator {
private String[] prefixes;
private int counter = 0;
private int size = 0;
public IteratorPrefixes(String[] prefixes, int size) {
this.prefixes = prefixes;
this.size = size;
}
public boolean hasNext() {
return (this.counter < this.size);
}
public Object next() {
if (this.counter < this.size)
return NamespaceSupport.this.fPrefixes[this.counter++];
throw new NoSuchElementException("Illegal access to Namespace prefixes enumeration.");
}
public String toString() {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < this.size; i++) {
buf.append(this.prefixes[i]);
buf.append(" ");
}
return buf.toString();
}
public void remove() {
throw new UnsupportedOperationException();
}
}
protected final class Prefixes implements Enumeration {
private String[] prefixes;
private int counter = 0;
private int size = 0;
public Prefixes(String[] prefixes, int size) {
this.prefixes = prefixes;
this.size = size;
}
public boolean hasMoreElements() {
return (this.counter < this.size);
}
public Object nextElement() {
if (this.counter < this.size)
return NamespaceSupport.this.fPrefixes[this.counter++];
throw new NoSuchElementException("Illegal access to Namespace prefixes enumeration.");
}
public String toString() {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < this.size; i++) {
buf.append(this.prefixes[i]);
buf.append(" ");
}
return buf.toString();
}
}
}

View file

@ -0,0 +1,147 @@
package com.sun.xml.stream.xerces.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
public class ObjectFactory {
private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties";
private static final boolean DEBUG = false;
public static Object createObject(String factoryId, String fallbackClassName) throws ConfigurationError {
return createObject(factoryId, null, fallbackClassName);
}
public static Object createObject(String factoryId, String propertiesFilename, String fallbackClassName) throws ConfigurationError {
debugPrintln("debug is on");
SecuritySupport ss = SecuritySupport.getInstance();
ClassLoader cl = findClassLoader();
try {
String systemProp = ss.getSystemProperty(factoryId);
if (systemProp != null) {
debugPrintln("found system property, value=" + systemProp);
return newInstance(systemProp, cl, true);
}
} catch (SecurityException se) {}
try {
if (propertiesFilename == null) {
String javah = ss.getSystemProperty("java.home");
propertiesFilename = javah + File.separator + "lib" + File.separator + "xerces.properties";
}
FileInputStream fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
String factoryClassName = props.getProperty(factoryId);
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName);
return newInstance(factoryClassName, cl, true);
}
} catch (Exception x) {}
Object provider = findJarServiceProvider(factoryId);
if (provider != null)
return provider;
if (fallbackClassName == null)
throw new ConfigurationError("Provider for " + factoryId + " cannot be found", null);
debugPrintln("using fallback, value=" + fallbackClassName);
return newInstance(fallbackClassName, cl, true);
}
private static void debugPrintln(String msg) {}
public static ClassLoader findClassLoader() throws ConfigurationError {
SecuritySupport ss = SecuritySupport.getInstance();
ClassLoader cl = ss.getContextClassLoader();
if (cl == null)
cl = ObjectFactory.class.getClassLoader();
return cl;
}
public static Object newInstance(String className, ClassLoader cl, boolean doFallback) throws ConfigurationError {
try {
Class providerClass = findProviderClass(className, cl, doFallback);
Object instance = providerClass.newInstance();
debugPrintln("created new instance of " + providerClass + " using ClassLoader: " + cl);
return instance;
} catch (ClassNotFoundException x) {
throw new ConfigurationError("Provider " + className + " not found", x);
} catch (Exception x) {
throw new ConfigurationError("Provider " + className + " could not be instantiated: " + x, x);
}
}
public static Class findProviderClass(String className, ClassLoader cl, boolean doFallback) throws ClassNotFoundException, ConfigurationError {
Class<?> clazz;
if (cl == null) {
clazz = Class.forName(className);
} else {
try {
clazz = cl.loadClass(className);
} catch (ClassNotFoundException x) {
if (doFallback) {
cl = ObjectFactory.class.getClassLoader();
clazz = cl.loadClass(className);
} else {
throw x;
}
}
}
return clazz;
}
private static Object findJarServiceProvider(String factoryId) throws ConfigurationError {
BufferedReader bufferedReader;
SecuritySupport ss = SecuritySupport.getInstance();
String serviceId = "META-INF/services/" + factoryId;
InputStream is = null;
ClassLoader cl = ss.getContextClassLoader();
if (cl != null) {
is = ss.getResourceAsStream(cl, serviceId);
if (is == null) {
cl = ObjectFactory.class.getClassLoader();
is = ss.getResourceAsStream(cl, serviceId);
}
} else {
cl = ObjectFactory.class.getClassLoader();
is = ss.getResourceAsStream(cl, serviceId);
}
if (is == null)
return null;
debugPrintln("found jar resource=" + serviceId + " using ClassLoader: " + cl);
try {
bufferedReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} catch (UnsupportedEncodingException e) {
bufferedReader = new BufferedReader(new InputStreamReader(is));
}
String factoryClassName = null;
try {
factoryClassName = bufferedReader.readLine();
bufferedReader.close();
} catch (IOException x) {
return null;
}
if (factoryClassName != null && !"".equals(factoryClassName)) {
debugPrintln("found in resource, value=" + factoryClassName);
return newInstance(factoryClassName, cl, false);
}
return null;
}
public static class ConfigurationError extends Error {
private Exception exception;
public ConfigurationError(String msg, Exception x) {
super(msg);
this.exception = x;
}
public Exception getException() {
return this.exception;
}
}
}

View file

@ -0,0 +1,96 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.parser.XMLComponentManager;
import com.sun.xml.stream.xerces.xni.parser.XMLConfigurationException;
import java.util.Hashtable;
import java.util.Vector;
public class ParserConfigurationSettings implements XMLComponentManager {
protected Vector fRecognizedProperties;
protected Hashtable fProperties;
protected Vector fRecognizedFeatures;
protected Hashtable fFeatures;
protected XMLComponentManager fParentSettings;
public ParserConfigurationSettings() {
this(null);
}
public ParserConfigurationSettings(XMLComponentManager parent) {
this.fRecognizedFeatures = new Vector();
this.fRecognizedProperties = new Vector();
this.fFeatures = new Hashtable();
this.fProperties = new Hashtable();
this.fParentSettings = parent;
}
public void addRecognizedFeatures(String[] featureIds) {
int featureIdsCount = (featureIds != null) ? featureIds.length : 0;
for (int i = 0; i < featureIdsCount; i++) {
String featureId = featureIds[i];
if (!this.fRecognizedFeatures.contains(featureId))
this.fRecognizedFeatures.addElement(featureId);
}
}
static int counter = 1;
public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
checkFeature(featureId);
this.fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
}
public void addRecognizedProperties(String[] propertyIds) {
int propertyIdsCount = (propertyIds != null) ? propertyIds.length : 0;
for (int i = 0; i < propertyIdsCount; i++) {
String propertyId = propertyIds[i];
if (!this.fRecognizedProperties.contains(propertyId))
this.fRecognizedProperties.addElement(propertyId);
}
}
public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
checkProperty(propertyId);
this.fProperties.put(propertyId, value);
}
public boolean getFeature(String featureId) throws XMLConfigurationException {
Boolean state = (Boolean)this.fFeatures.get(featureId);
if (state == null) {
checkFeature(featureId);
return false;
}
return state;
}
public Object getProperty(String propertyId) throws XMLConfigurationException {
Object propertyValue = this.fProperties.get(propertyId);
if (propertyValue == null)
checkProperty(propertyId);
return propertyValue;
}
protected void checkFeature(String featureId) throws XMLConfigurationException {
if (!this.fRecognizedFeatures.contains(featureId))
if (this.fParentSettings != null) {
this.fParentSettings.getFeature(featureId);
} else {
short type = 0;
throw new XMLConfigurationException(type, featureId);
}
}
protected void checkProperty(String propertyId) throws XMLConfigurationException {
if (!this.fRecognizedProperties.contains(propertyId))
if (this.fParentSettings != null) {
this.fParentSettings.getProperty(propertyId);
} else {
short type = 0;
throw new XMLConfigurationException(type, propertyId);
}
}
}

View file

@ -0,0 +1,353 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.Augmentations;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLAttributes;
import java.util.ArrayList;
import java.util.HashMap;
public class STAXAttributesImpl implements XMLAttributes {
int attr_index = 0;
int MAGIC_NUMBER = 2;
protected boolean fNamespaces = true;
protected ArrayList attrList = null;
protected ArrayList dupList = null;
private boolean init = false;
protected HashMap attrMap = null;
public STAXAttributesImpl() {
this.attrList = new ArrayList(2);
for (int i = 0; i < 2; i++) {
Attribute attr = new Attribute();
attr.name = new QName();
this.attrList.add(i, attr);
}
}
public STAXAttributesImpl(int tableSize) {
this.attrList = new ArrayList(tableSize);
this.attrMap = new HashMap();
}
public void setNamespaces(boolean namespaces) {
this.fNamespaces = namespaces;
}
public int addAttribute(QName name, String type, String value) {
Attribute attr = null;
if (this.attr_index >= this.attrList.size()) {
attr = new Attribute();
attr.name = new QName();
this.attrList.add(attr);
attr.next = null;
} else {
attr = this.attrList.get(this.attr_index);
attr.next = null;
}
attr.name.setValues(name);
attr.type = type;
attr.value = value;
if (this.attr_index < 5) {
Attribute tmp = null;
for (int i = 0; i < this.attr_index; i++) {
tmp = this.attrList.get(i);
if (tmp.name.rawname == name.rawname) {
tmp.value = value;
return i;
}
}
} else {
Attribute tmp = null;
if (!this.init) {
if (this.attrMap == null)
this.attrMap = new HashMap(2, 2.0F);
for (int i = 0; i < this.attr_index; i++) {
tmp = this.attrList.get(i);
this.attrMap.put(tmp.name.rawname, tmp);
}
this.init = true;
}
if (this.attrMap.containsKey(name.rawname))
return getLength();
this.attrMap.put(name.rawname, attr);
}
this.attr_index++;
return getLength() - 1;
}
public void removeAllAttributes() {
this.attr_index = 0;
if (this.attrMap != null)
this.attrMap.clear();
if (this.dupList != null)
this.dupList.clear();
this.init = false;
}
public void removeAttributeAt(int attrIndex) {
Attribute attr = (Attribute)this.attrList.remove(attrIndex);
}
public void setName(int attrIndex, QName attrName) {
((Attribute)this.attrList.get(attrIndex)).name.setValues(attrName);
}
public void getName(int attrIndex, QName attrName) {
attrName.setValues(((Attribute)this.attrList.get(attrIndex)).name);
}
public void setType(int attrIndex, String attrType) {
((Attribute)this.attrList.get(attrIndex)).type = attrType;
}
public void setValue(int attrIndex, String attrValue) {
if (attrIndex > this.attr_index)
return;
Attribute attribute = this.attrList.get(attrIndex);
attribute.value = attrValue;
attribute.nonNormalizedValue = attrValue;
}
public void setNonNormalizedValue(int attrIndex, String attrValue) {
Attribute attribute = this.attrList.get(attrIndex);
attribute.nonNormalizedValue = attrValue;
}
public String getNonNormalizedValue(int attrIndex) {
Attribute attribute = this.attrList.get(attrIndex);
return attribute.nonNormalizedValue;
}
public void setSpecified(int attrIndex, boolean specified) {
((Attribute)this.attrList.get(attrIndex)).specified = specified;
}
public boolean isSpecified(int attrIndex) {
return ((Attribute)this.attrList.get(attrIndex)).specified;
}
public int getLength() {
return this.attr_index;
}
public String getType(int index) {
if (index < 0 || index >= this.attrList.size())
return null;
return getReportableType(((Attribute)this.attrList.get(index)).type);
}
public String getType(String qname) {
return null;
}
public String getValue(int index) {
return ((Attribute)this.attrList.get(index)).value;
}
public String getValue(String qname) {
return null;
}
public String getName(int index) {
if (index < 0 || index >= this.attrList.size())
return null;
return ((Attribute)this.attrList.get(index)).name.rawname;
}
public int getIndex(String qName) {
for (int i = 0; i < this.attr_index; i++) {
Attribute attribute = this.attrList.get(i);
if (attribute.name.rawname != null && attribute.name.rawname.equals(qName))
return i;
}
return -1;
}
public int getIndex(String uri, String localPart) {
for (int i = 0; i < this.attr_index; i++) {
Attribute attribute = this.attrList.get(i);
if (attribute.name.localpart != null && attribute.name.localpart.equals(localPart) && (uri == attribute.name.uri || (uri != null && attribute.name.uri != null && attribute.name.uri.equals(uri))))
return i;
}
return -1;
}
public String getLocalName(int index) {
if (!this.fNamespaces)
return "";
return ((Attribute)this.attrList.get(index)).name.localpart;
}
public String getQName(int index) {
return ((Attribute)this.attrList.get(index)).name.rawname;
}
public QName getQualifiedName(int index) {
return ((Attribute)this.attrList.get(index)).name;
}
public String getType(String uri, String localName) {
if (!this.fNamespaces)
return null;
int index = getIndex(uri, localName);
return (index != -1) ? getReportableType(((Attribute)this.attrList.get(index)).type) : null;
}
public String getPrefix(int index) {
return ((Attribute)this.attrList.get(index)).name.prefix;
}
public String getURI(int index) {
return ((Attribute)this.attrList.get(index)).name.uri;
}
public String getValue(String uri, String localName) {
int index = getIndex(uri, localName);
return (index != -1) ? getValue(index) : null;
}
public Augmentations getAugmentations(String uri, String localName) {
return null;
}
public Augmentations getAugmentations(String qName) {
return null;
}
public Augmentations getAugmentations(int attributeIndex) {
return null;
}
public void setAugmentations(int attrIndex, Augmentations augs) {}
public void setURI(int attrIndex, String uri) {
Attribute attribute = this.attrList.get(attrIndex);
attribute.name.uri = uri;
}
public void setSchemaId(int attrIndex, boolean schemaId) {}
public boolean getSchemaId(int index) {
return false;
}
public boolean getSchemaId(String qname) {
return false;
}
public boolean getSchemaId(String uri, String localName) {
return false;
}
public void addAttributeNS(QName name, String type, String value) {
Attribute attr = null;
if (this.attr_index >= this.attrList.size()) {
attr = new Attribute();
attr.name = new QName();
this.attrList.add(attr);
attr.next = null;
} else {
attr = this.attrList.get(this.attr_index);
attr.next = null;
}
attr.name.setValues(name);
attr.type = type;
attr.value = value;
if (this.attr_index > this.MAGIC_NUMBER) {
if (!this.init) {
if (this.attrMap == null)
this.attrMap = new HashMap(2, 2.0F);
for (int i = 0; i < this.attr_index; i++) {
Attribute tmp = this.attrList.get(i);
this.attrMap.put(tmp.name.localpart, tmp);
}
this.init = true;
}
if (this.attrMap.containsKey(name.localpart)) {
Attribute obj = (Attribute)this.attrMap.get(name.localpart);
attr.next = obj.next;
obj.next = attr;
this.attr_index++;
if (!obj.dup) {
if (this.dupList == null)
this.dupList = new ArrayList();
this.dupList.add(attr);
obj.dup = true;
}
} else {
this.attrMap.put(name.localpart, attr);
this.attr_index++;
}
} else {
this.attr_index++;
}
}
public QName checkDuplicatesNS() {
if (this.attr_index <= this.MAGIC_NUMBER) {
for (int i = 0; i < this.attr_index - 1; i++) {
Attribute att1 = this.attrList.get(i);
for (int j = i + 1; j < this.attr_index; j++) {
Attribute att2 = this.attrList.get(j);
if (att1.name.localpart == att2.name.localpart && att1.name.uri == att2.name.uri)
return att2.name;
}
}
} else {
if (this.dupList == null)
return null;
for (int i = 0; i < this.dupList.size(); i++) {
Attribute att1 = this.dupList.get(i);
Attribute att2 = att1.next;
while (att2 != null) {
if (att1.name.localpart == att2.name.localpart && att1.name.uri == att2.name.uri)
return att2.name;
att2 = att1.next;
}
}
}
return null;
}
protected String getReportableType(String type) {
if (type.indexOf('(') == 0 && type.lastIndexOf(')') == type.length() - 1)
return "NMTOKEN";
return type;
}
protected Attribute getDuplicate(Attribute attr1, QName qname) {
Attribute att1 = attr1;
if (att1.name.prefix == qname.prefix && attr1.next == null)
return att1;
while (att1 != null) {
if (att1.name.rawname == qname.rawname)
return att1;
att1 = att1.next;
}
return null;
}
class Attribute {
public QName name = new QName();
public String type;
public String value;
public String nonNormalizedValue;
public boolean specified;
public boolean schemaId;
public boolean dup = false;
Attribute next;
}
}

View file

@ -0,0 +1,50 @@
package com.sun.xml.stream.xerces.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
class SecuritySupport {
private static final Object securitySupport;
static {
SecuritySupport ss = null;
try {
Class<?> c = Class.forName("java.security.AccessController");
ss = new SecuritySupport12();
} catch (Exception ex) {
} finally {
if (ss == null)
ss = new SecuritySupport();
securitySupport = ss;
}
}
public static SecuritySupport getInstance() {
return (SecuritySupport)securitySupport;
}
public ClassLoader getContextClassLoader() {
return null;
}
public String getSystemProperty(String propName) {
return System.getProperty(propName);
}
public FileInputStream getFileInputStream(File file) throws FileNotFoundException {
return new FileInputStream(file);
}
public InputStream getResourceAsStream(ClassLoader cl, String name) {
InputStream ris;
if (cl == null) {
ris = ClassLoader.getSystemResourceAsStream(name);
} else {
ris = cl.getResourceAsStream(name);
}
return ris;
}
}

View file

@ -0,0 +1,58 @@
package com.sun.xml.stream.xerces.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
class SecuritySupport12 extends SecuritySupport {
public ClassLoader getContextClassLoader() {
return AccessController.<ClassLoader>doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) {}
return cl;
}
});
}
public String getSystemProperty(final String propName) {
return AccessController.<String>doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty(propName);
}
});
}
public FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
try {
return AccessController.<FileInputStream>doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws FileNotFoundException {
return new FileInputStream(file);
}
});
} catch (PrivilegedActionException e) {
throw (FileNotFoundException)e.getException();
}
}
public InputStream getResourceAsStream(final ClassLoader cl, final String name) {
return AccessController.<InputStream>doPrivileged(new PrivilegedAction() {
public Object run() {
InputStream ris;
if (cl == null) {
ris = ClassLoader.getSystemResourceAsStream(name);
} else {
ris = cl.getResourceAsStream(name);
}
return ris;
}
});
}
}

View file

@ -0,0 +1,29 @@
package com.sun.xml.stream.xerces.util;
public final class ShadowedSymbolTable extends SymbolTable {
protected SymbolTable fSymbolTable;
public ShadowedSymbolTable(SymbolTable symbolTable) {
this.fSymbolTable = symbolTable;
}
public String addSymbol(String symbol) {
if (this.fSymbolTable.containsSymbol(symbol))
return this.fSymbolTable.addSymbol(symbol);
return super.addSymbol(symbol);
}
public String addSymbol(char[] buffer, int offset, int length) {
if (this.fSymbolTable.containsSymbol(buffer, offset, length))
return this.fSymbolTable.addSymbol(buffer, offset, length);
return super.addSymbol(buffer, offset, length);
}
public int hash(String symbol) {
return this.fSymbolTable.hash(symbol);
}
public int hash(char[] buffer, int offset, int length) {
return this.fSymbolTable.hash(buffer, offset, length);
}
}

View file

@ -0,0 +1,105 @@
package com.sun.xml.stream.xerces.util;
public class SymbolHash {
protected int fTableSize = 101;
protected Entry[] fBuckets;
protected int fNum = 0;
public SymbolHash() {
this.fBuckets = new Entry[this.fTableSize];
}
public SymbolHash(int size) {
this.fTableSize = size;
this.fBuckets = new Entry[this.fTableSize];
}
public void put(Object key, Object value) {
int bucket = (key.hashCode() & Integer.MAX_VALUE) % this.fTableSize;
Entry entry = search(key, bucket);
if (entry != null) {
entry.value = value;
} else {
entry = new Entry(key, value, this.fBuckets[bucket]);
this.fBuckets[bucket] = entry;
this.fNum++;
}
}
public Object get(Object key) {
int bucket = (key.hashCode() & Integer.MAX_VALUE) % this.fTableSize;
Entry entry = search(key, bucket);
if (entry != null)
return entry.value;
return null;
}
public int getLength() {
return this.fNum;
}
public int getValues(Object[] elements, int from) {
for (int i = 0, j = 0; i < this.fTableSize && j < this.fNum; i++) {
for (Entry entry = this.fBuckets[i]; entry != null; entry = entry.next) {
elements[from + j] = entry.value;
j++;
}
}
return this.fNum;
}
public SymbolHash makeClone() {
SymbolHash newTable = new SymbolHash(this.fTableSize);
newTable.fNum = this.fNum;
for (int i = 0; i < this.fTableSize; i++) {
if (this.fBuckets[i] != null)
newTable.fBuckets[i] = this.fBuckets[i].makeClone();
}
return newTable;
}
public void clear() {
for (int i = 0; i < this.fTableSize; i++)
this.fBuckets[i] = null;
this.fNum = 0;
}
protected Entry search(Object key, int bucket) {
for (Entry entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (key.equals(entry.key))
return entry;
}
return null;
}
protected static final class Entry {
public Object key;
public Object value;
public Entry next;
public Entry() {
this.key = null;
this.value = null;
this.next = null;
}
public Entry(Object key, Object value, Entry next) {
this.key = key;
this.value = value;
this.next = next;
}
public Entry makeClone() {
Entry entry = new Entry();
entry.key = this.key;
entry.value = this.value;
if (this.next != null)
entry.next = this.next.makeClone();
return entry;
}
}
}

View file

@ -0,0 +1,140 @@
package com.sun.xml.stream.xerces.util;
public class SymbolTable {
protected static final int TABLE_SIZE = 173;
protected char[] symbolAsArray = null;
protected Entry[] fBuckets = null;
protected int fTableSize;
public SymbolTable() {
this(173);
}
public SymbolTable(int tableSize) {
this.fTableSize = tableSize;
this.fBuckets = new Entry[this.fTableSize];
}
public String addSymbol(String symbol) {
int hash = hash(symbol);
int bucket = hash % this.fTableSize;
int length = symbol.length();
Entry entry;
for (entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length && hash == entry.hashCode &&
symbol.regionMatches(0, entry.symbol, 0, length)) {
this.symbolAsArray = entry.characters;
return entry.symbol;
}
}
entry = new Entry(symbol, this.fBuckets[bucket]);
entry.hashCode = hash;
this.symbolAsArray = entry.characters;
this.fBuckets[bucket] = entry;
return entry.symbol;
}
public String addSymbol(char[] buffer, int offset, int length) {
int hash = hash(buffer, offset, length);
int bucket = hash % this.fTableSize;
Entry entry;
for (entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length && hash == entry.hashCode) {
int i = 0;
while (true) {
if (i < length) {
if (buffer[offset + i] != entry.characters[i])
break;
i++;
continue;
}
this.symbolAsArray = entry.characters;
return entry.symbol;
}
}
}
entry = new Entry(buffer, offset, length, this.fBuckets[bucket]);
this.fBuckets[bucket] = entry;
entry.hashCode = hash;
this.symbolAsArray = entry.characters;
return entry.symbol;
}
public int hash(String symbol) {
int code = 0;
int length = symbol.length();
for (int i = 0; i < length; i++)
code = code * 37 + symbol.charAt(i);
return code & 0x7FFFFFF;
}
public int hash(char[] buffer, int offset, int length) {
int code = 0;
for (int i = 0; i < length; i++)
code = code * 37 + buffer[offset + i];
return code & 0x7FFFFFF;
}
public boolean containsSymbol(String symbol) {
int hash = hash(symbol);
int bucket = hash % this.fTableSize;
int length = symbol.length();
for (Entry entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length && hash == entry.hashCode &&
symbol.regionMatches(0, entry.symbol, 0, length))
return true;
}
return false;
}
public boolean containsSymbol(char[] buffer, int offset, int length) {
int hash = hash(buffer, offset, length);
int bucket = hash % this.fTableSize;
for (Entry entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length && hash == entry.hashCode) {
int i = 0;
while (true) {
if (i < length) {
if (buffer[offset + i] != entry.characters[i])
break;
i++;
continue;
}
return true;
}
}
}
return false;
}
public char[] getCharArray() {
return this.symbolAsArray;
}
protected static final class Entry {
public String symbol;
int hashCode = 0;
public char[] characters;
public Entry next;
public Entry(String symbol, Entry next) {
this.symbol = symbol.intern();
this.characters = new char[symbol.length()];
symbol.getChars(0, this.characters.length, this.characters, 0);
this.next = next;
}
public Entry(char[] ch, int offset, int length, Entry next) {
this.characters = new char[length];
System.arraycopy(ch, offset, this.characters, 0, length);
this.symbol = new String(this.characters).intern();
this.next = next;
}
}
}

View file

@ -0,0 +1,41 @@
package com.sun.xml.stream.xerces.util;
public final class SynchronizedSymbolTable extends SymbolTable {
protected SymbolTable fSymbolTable;
public SynchronizedSymbolTable(SymbolTable symbolTable) {
this.fSymbolTable = symbolTable;
}
public SynchronizedSymbolTable() {
this.fSymbolTable = new SymbolTable();
}
public SynchronizedSymbolTable(int size) {
this.fSymbolTable = new SymbolTable(size);
}
public String addSymbol(String symbol) {
synchronized (this.fSymbolTable) {
return this.fSymbolTable.addSymbol(symbol);
}
}
public String addSymbol(char[] buffer, int offset, int length) {
synchronized (this.fSymbolTable) {
return this.fSymbolTable.addSymbol(buffer, offset, length);
}
}
public boolean containsSymbol(String symbol) {
synchronized (this.fSymbolTable) {
return this.fSymbolTable.containsSymbol(symbol);
}
}
public boolean containsSymbol(char[] buffer, int offset, int length) {
synchronized (this.fSymbolTable) {
return this.fSymbolTable.containsSymbol(buffer, offset, length);
}
}
}

View file

@ -0,0 +1,620 @@
package com.sun.xml.stream.xerces.util;
import java.io.IOException;
import java.io.Serializable;
public class URI implements Serializable {
private static final String RESERVED_CHARACTERS = ";/?:@&=+$,[]";
private static final String MARK_CHARACTERS = "-_.!~*'()";
private static final String SCHEME_CHARACTERS = "+-.";
private static final String USERINFO_CHARACTERS = ";:&=+$,";
public static class MalformedURIException extends IOException {
public MalformedURIException() {}
public MalformedURIException(String p_msg) {
super(p_msg);
}
}
private String m_scheme = null;
private String m_userinfo = null;
private String m_host = null;
private int m_port = -1;
private String m_path = null;
private String m_queryString = null;
private String m_fragment = null;
private static boolean DEBUG = false;
public URI() {}
public URI(URI p_other) {
initialize(p_other);
}
public URI(String p_uriSpec) throws MalformedURIException {
this((URI)null, p_uriSpec);
}
public URI(URI p_base, String p_uriSpec) throws MalformedURIException {
initialize(p_base, p_uriSpec);
}
public URI(String p_scheme, String p_schemeSpecificPart) throws MalformedURIException {
if (p_scheme == null || p_scheme.trim().length() == 0)
throw new MalformedURIException("Cannot construct URI with null/empty scheme!");
if (p_schemeSpecificPart == null || p_schemeSpecificPart.trim().length() == 0)
throw new MalformedURIException("Cannot construct URI with null/empty scheme-specific part!");
setScheme(p_scheme);
setPath(p_schemeSpecificPart);
}
public URI(String p_scheme, String p_host, String p_path, String p_queryString, String p_fragment) throws MalformedURIException {
this(p_scheme, null, p_host, -1, p_path, p_queryString, p_fragment);
}
public URI(String p_scheme, String p_userinfo, String p_host, int p_port, String p_path, String p_queryString, String p_fragment) throws MalformedURIException {
if (p_scheme == null || p_scheme.trim().length() == 0)
throw new MalformedURIException("Scheme is required!");
if (p_host == null) {
if (p_userinfo != null)
throw new MalformedURIException("Userinfo may not be specified if host is not specified!");
if (p_port != -1)
throw new MalformedURIException("Port may not be specified if host is not specified!");
}
if (p_path != null) {
if (p_path.indexOf('?') != -1 && p_queryString != null)
throw new MalformedURIException("Query string cannot be specified in path and query string!");
if (p_path.indexOf('#') != -1 && p_fragment != null)
throw new MalformedURIException("Fragment cannot be specified in both the path and fragment!");
}
setScheme(p_scheme);
setHost(p_host);
setPort(p_port);
setUserinfo(p_userinfo);
setPath(p_path);
setQueryString(p_queryString);
setFragment(p_fragment);
}
private void initialize(URI p_other) {
this.m_scheme = p_other.getScheme();
this.m_userinfo = p_other.getUserinfo();
this.m_host = p_other.getHost();
this.m_port = p_other.getPort();
this.m_path = p_other.getPath();
this.m_queryString = p_other.getQueryString();
this.m_fragment = p_other.getFragment();
}
private void initialize(URI p_base, String p_uriSpec) throws MalformedURIException {
if (p_base == null && (p_uriSpec == null || p_uriSpec.trim().length() == 0))
throw new MalformedURIException("Cannot initialize URI with empty parameters.");
if (p_uriSpec == null || p_uriSpec.trim().length() == 0) {
initialize(p_base);
return;
}
String uriSpec = p_uriSpec.trim();
int uriSpecLen = uriSpec.length();
int index = 0;
int colonIdx = uriSpec.indexOf(':');
int slashIdx = uriSpec.indexOf('/');
int queryIdx = uriSpec.indexOf('?');
int fragmentIdx = uriSpec.indexOf('#');
if (colonIdx < 2 || (colonIdx > slashIdx && slashIdx != -1) || (colonIdx > queryIdx && queryIdx != -1) || (colonIdx > fragmentIdx && fragmentIdx != -1)) {
if (p_base == null && fragmentIdx != 0)
throw new MalformedURIException("No scheme found in URI.");
} else {
initializeScheme(uriSpec);
index = this.m_scheme.length() + 1;
}
if (index + 1 < uriSpecLen && uriSpec.substring(index).startsWith("//")) {
index += 2;
int startPos = index;
char testChar = '\000';
while (index < uriSpecLen) {
testChar = uriSpec.charAt(index);
if (testChar == '/' || testChar == '?' || testChar == '#')
break;
index++;
}
if (index > startPos) {
initializeAuthority(uriSpec.substring(startPos, index));
} else {
this.m_host = "";
}
}
initializePath(uriSpec.substring(index));
if (p_base != null) {
if (this.m_path.length() == 0 && this.m_scheme == null && this.m_host == null) {
this.m_scheme = p_base.getScheme();
this.m_userinfo = p_base.getUserinfo();
this.m_host = p_base.getHost();
this.m_port = p_base.getPort();
this.m_path = p_base.getPath();
if (this.m_queryString == null)
this.m_queryString = p_base.getQueryString();
return;
}
if (this.m_scheme == null) {
this.m_scheme = p_base.getScheme();
} else {
return;
}
if (this.m_host == null) {
this.m_userinfo = p_base.getUserinfo();
this.m_host = p_base.getHost();
this.m_port = p_base.getPort();
} else {
return;
}
if (this.m_path.length() > 0 && this.m_path.startsWith("/"))
return;
String path = new String();
String basePath = p_base.getPath();
if (basePath != null) {
int lastSlash = basePath.lastIndexOf('/');
if (lastSlash != -1)
path = basePath.substring(0, lastSlash + 1);
}
path = path.concat(this.m_path);
index = -1;
while ((index = path.indexOf("/./")) != -1)
path = path.substring(0, index + 1).concat(path.substring(index + 3));
if (path.endsWith("/."))
path = path.substring(0, path.length() - 1);
index = 1;
int segIndex = -1;
String tempString = null;
while ((index = path.indexOf("/../", index)) > 0) {
tempString = path.substring(0, path.indexOf("/../"));
segIndex = tempString.lastIndexOf('/');
if (segIndex != -1) {
if (!tempString.substring(segIndex).equals("..")) {
path = path.substring(0, segIndex + 1).concat(path.substring(index + 4));
index = segIndex;
continue;
}
index += 4;
continue;
}
index += 4;
}
if (path.endsWith("/..")) {
tempString = path.substring(0, path.length() - 3);
segIndex = tempString.lastIndexOf('/');
if (segIndex != -1)
path = path.substring(0, segIndex + 1);
}
this.m_path = path;
}
}
private void initializeScheme(String p_uriSpec) throws MalformedURIException {
int uriSpecLen = p_uriSpec.length();
int index = 0;
String scheme = null;
char testChar = '\000';
while (index < uriSpecLen) {
testChar = p_uriSpec.charAt(index);
if (testChar == ':' || testChar == '/' || testChar == '?' || testChar == '#')
break;
index++;
}
scheme = p_uriSpec.substring(0, index);
if (scheme.length() == 0)
throw new MalformedURIException("No scheme found in URI.");
setScheme(scheme);
}
private void initializeAuthority(String p_uriSpec) throws MalformedURIException {
int index = 0;
int start = 0;
int end = p_uriSpec.length();
char testChar = '\000';
String userinfo = null;
if (p_uriSpec.indexOf('@', start) != -1) {
while (index < end) {
testChar = p_uriSpec.charAt(index);
if (testChar == '@')
break;
index++;
}
userinfo = p_uriSpec.substring(start, index);
index++;
}
String host = null;
start = index;
while (index < end) {
testChar = p_uriSpec.charAt(index);
if (testChar == ':')
break;
index++;
}
host = p_uriSpec.substring(start, index);
int port = -1;
if (host.length() > 0)
if (testChar == ':') {
start = ++index;
while (index < end)
index++;
String portStr = p_uriSpec.substring(start, index);
if (portStr.length() > 0) {
for (int i = 0; i < portStr.length(); i++) {
if (!isDigit(portStr.charAt(i)))
throw new MalformedURIException(portStr + " is invalid. Port should only contain digits!");
}
try {
port = Integer.parseInt(portStr);
} catch (NumberFormatException nfe) {}
}
}
setHost(host);
setPort(port);
setUserinfo(userinfo);
}
private void initializePath(String p_uriSpec) throws MalformedURIException {
if (p_uriSpec == null)
throw new MalformedURIException("Cannot initialize path from null string!");
int index = 0;
int start = 0;
int end = p_uriSpec.length();
char testChar = '\000';
while (index < end) {
testChar = p_uriSpec.charAt(index);
if (testChar == '?' || testChar == '#')
break;
if (testChar == '%') {
if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
throw new MalformedURIException("Path contains invalid escape sequence!");
} else if (!isReservedCharacter(testChar) && !isUnreservedCharacter(testChar)) {
throw new MalformedURIException("Path contains invalid character: " + testChar);
}
index++;
}
this.m_path = p_uriSpec.substring(start, index);
if (testChar == '?') {
start = ++index;
while (index < end) {
testChar = p_uriSpec.charAt(index);
if (testChar == '#')
break;
if (testChar == '%') {
if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
throw new MalformedURIException("Query string contains invalid escape sequence!");
} else if (!isReservedCharacter(testChar) && !isUnreservedCharacter(testChar)) {
throw new MalformedURIException("Query string contains invalid character:" + testChar);
}
index++;
}
this.m_queryString = p_uriSpec.substring(start, index);
}
if (testChar == '#') {
start = ++index;
while (index < end) {
testChar = p_uriSpec.charAt(index);
if (testChar == '%') {
if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
throw new MalformedURIException("Fragment contains invalid escape sequence!");
} else if (!isReservedCharacter(testChar) && !isUnreservedCharacter(testChar)) {
throw new MalformedURIException("Fragment contains invalid character:" + testChar);
}
index++;
}
this.m_fragment = p_uriSpec.substring(start, index);
}
}
public String getScheme() {
return this.m_scheme;
}
public String getSchemeSpecificPart() {
StringBuffer schemespec = new StringBuffer();
if (this.m_userinfo != null || this.m_host != null || this.m_port != -1)
schemespec.append("//");
if (this.m_userinfo != null) {
schemespec.append(this.m_userinfo);
schemespec.append('@');
}
if (this.m_host != null)
schemespec.append(this.m_host);
if (this.m_port != -1) {
schemespec.append(':');
schemespec.append(this.m_port);
}
if (this.m_path != null)
schemespec.append(this.m_path);
if (this.m_queryString != null) {
schemespec.append('?');
schemespec.append(this.m_queryString);
}
if (this.m_fragment != null) {
schemespec.append('#');
schemespec.append(this.m_fragment);
}
return schemespec.toString();
}
public String getUserinfo() {
return this.m_userinfo;
}
public String getHost() {
return this.m_host;
}
public int getPort() {
return this.m_port;
}
public String getPath(boolean p_includeQueryString, boolean p_includeFragment) {
StringBuffer pathString = new StringBuffer(this.m_path);
if (p_includeQueryString && this.m_queryString != null) {
pathString.append('?');
pathString.append(this.m_queryString);
}
if (p_includeFragment && this.m_fragment != null) {
pathString.append('#');
pathString.append(this.m_fragment);
}
return pathString.toString();
}
public String getPath() {
return this.m_path;
}
public String getQueryString() {
return this.m_queryString;
}
public String getFragment() {
return this.m_fragment;
}
public void setScheme(String p_scheme) throws MalformedURIException {
if (p_scheme == null)
throw new MalformedURIException("Cannot set scheme from null string!");
if (!isConformantSchemeName(p_scheme))
throw new MalformedURIException("The scheme is not conformant.");
this.m_scheme = p_scheme.toLowerCase();
}
public void setUserinfo(String p_userinfo) throws MalformedURIException {
if (p_userinfo == null) {
this.m_userinfo = null;
} else {
if (this.m_host == null)
throw new MalformedURIException("Userinfo cannot be set when host is null!");
int index = 0;
int end = p_userinfo.length();
char testChar = '\000';
while (index < end) {
testChar = p_userinfo.charAt(index);
if (testChar == '%') {
if (index + 2 >= end || !isHex(p_userinfo.charAt(index + 1)) || !isHex(p_userinfo.charAt(index + 2)))
throw new MalformedURIException("Userinfo contains invalid escape sequence!");
} else if (!isUnreservedCharacter(testChar) && ";:&=+$,".indexOf(testChar) == -1) {
throw new MalformedURIException("Userinfo contains invalid character:" + testChar);
}
index++;
}
}
this.m_userinfo = p_userinfo;
}
public void setHost(String p_host) throws MalformedURIException {
if (p_host == null || p_host.trim().length() == 0) {
this.m_host = p_host;
this.m_userinfo = null;
this.m_port = -1;
} else if (!isWellFormedAddress(p_host)) {
throw new MalformedURIException("Host is not a well formed address!");
}
this.m_host = p_host;
}
public void setPort(int p_port) throws MalformedURIException {
if (p_port >= 0 && p_port <= 65535) {
if (this.m_host == null)
throw new MalformedURIException("Port cannot be set when host is null!");
} else if (p_port != -1) {
throw new MalformedURIException("Invalid port number!");
}
this.m_port = p_port;
}
public void setPath(String p_path) throws MalformedURIException {
if (p_path == null) {
this.m_path = null;
this.m_queryString = null;
this.m_fragment = null;
} else {
initializePath(p_path);
}
}
public void appendPath(String p_addToPath) throws MalformedURIException {
if (p_addToPath == null || p_addToPath.trim().length() == 0)
return;
if (!isURIString(p_addToPath))
throw new MalformedURIException("Path contains invalid character!");
if (this.m_path == null || this.m_path.trim().length() == 0) {
if (p_addToPath.startsWith("/")) {
this.m_path = p_addToPath;
} else {
this.m_path = "/" + p_addToPath;
}
} else if (this.m_path.endsWith("/")) {
if (p_addToPath.startsWith("/")) {
this.m_path = this.m_path.concat(p_addToPath.substring(1));
} else {
this.m_path = this.m_path.concat(p_addToPath);
}
} else if (p_addToPath.startsWith("/")) {
this.m_path = this.m_path.concat(p_addToPath);
} else {
this.m_path = this.m_path.concat("/" + p_addToPath);
}
}
public void setQueryString(String p_queryString) throws MalformedURIException {
if (p_queryString == null) {
this.m_queryString = null;
} else {
if (!isGenericURI())
throw new MalformedURIException("Query string can only be set for a generic URI!");
if (getPath() == null)
throw new MalformedURIException("Query string cannot be set when path is null!");
if (!isURIString(p_queryString))
throw new MalformedURIException("Query string contains invalid character!");
this.m_queryString = p_queryString;
}
}
public void setFragment(String p_fragment) throws MalformedURIException {
if (p_fragment == null) {
this.m_fragment = null;
} else {
if (!isGenericURI())
throw new MalformedURIException("Fragment can only be set for a generic URI!");
if (getPath() == null)
throw new MalformedURIException("Fragment cannot be set when path is null!");
if (!isURIString(p_fragment))
throw new MalformedURIException("Fragment contains invalid character!");
this.m_fragment = p_fragment;
}
}
public boolean equals(Object p_test) {
if (p_test instanceof URI) {
URI testURI = (URI)p_test;
if (((this.m_scheme == null && testURI.m_scheme == null) || (this.m_scheme != null && testURI.m_scheme != null && this.m_scheme.equals(testURI.m_scheme))) && ((this.m_userinfo == null && testURI.m_userinfo == null) || (this.m_userinfo != null && testURI.m_userinfo != null && this.m_userinfo.equals(testURI.m_userinfo))) && ((this.m_host == null && testURI.m_host == null) || (this.m_host != null && testURI.m_host != null && this.m_host.equals(testURI.m_host))) && this.m_port == testURI.m_port && ((this.m_path == null && testURI.m_path == null) || (this.m_path != null && testURI.m_path != null && this.m_path.equals(testURI.m_path))) && ((this.m_queryString == null && testURI.m_queryString == null) || (this.m_queryString != null && testURI.m_queryString != null && this.m_queryString.equals(testURI.m_queryString))) && ((this.m_fragment == null && testURI.m_fragment == null) || (this.m_fragment != null && testURI.m_fragment != null && this.m_fragment.equals(testURI.m_fragment))))
return true;
}
return false;
}
public String toString() {
StringBuffer uriSpecString = new StringBuffer();
if (this.m_scheme != null) {
uriSpecString.append(this.m_scheme);
uriSpecString.append(':');
}
uriSpecString.append(getSchemeSpecificPart());
return uriSpecString.toString();
}
public boolean isGenericURI() {
return (this.m_host != null);
}
public static boolean isConformantSchemeName(String p_scheme) {
if (p_scheme == null || p_scheme.trim().length() == 0)
return false;
if (!isAlpha(p_scheme.charAt(0)))
return false;
for (int i = 1; i < p_scheme.length(); i++) {
char testChar = p_scheme.charAt(i);
if (!isAlphanum(testChar) && "+-.".indexOf(testChar) == -1)
return false;
}
return true;
}
public static boolean isWellFormedAddress(String p_address) {
if (p_address == null)
return false;
String address = p_address.trim();
int addrLength = address.length();
if (addrLength == 0 || addrLength > 255)
return false;
if (address.startsWith(".") || address.startsWith("-"))
return false;
int index = address.lastIndexOf('.');
if (address.endsWith("."))
index = address.substring(0, index).lastIndexOf('.');
if (index + 1 < addrLength && isDigit(p_address.charAt(index + 1))) {
int numDots = 0;
for (int i = 0; i < addrLength; i++) {
char testChar = address.charAt(i);
if (testChar == '.') {
if (!isDigit(address.charAt(i - 1)) || (i + 1 < addrLength && !isDigit(address.charAt(i + 1))))
return false;
numDots++;
} else if (!isDigit(testChar)) {
return false;
}
}
if (numDots != 3)
return false;
} else {
for (int i = 0; i < addrLength; i++) {
char testChar = address.charAt(i);
if (testChar == '.') {
if (!isAlphanum(address.charAt(i - 1)))
return false;
if (i + 1 < addrLength && !isAlphanum(address.charAt(i + 1)))
return false;
} else if (!isAlphanum(testChar) && testChar != '-') {
return false;
}
}
}
return true;
}
private static boolean isDigit(char p_char) {
return (p_char >= '0' && p_char <= '9');
}
private static boolean isHex(char p_char) {
return (isDigit(p_char) || (p_char >= 'a' && p_char <= 'f') || (p_char >= 'A' && p_char <= 'F'));
}
private static boolean isAlpha(char p_char) {
return ((p_char >= 'a' && p_char <= 'z') || (p_char >= 'A' && p_char <= 'Z'));
}
private static boolean isAlphanum(char p_char) {
return (isAlpha(p_char) || isDigit(p_char));
}
private static boolean isReservedCharacter(char p_char) {
return (";/?:@&=+$,[]".indexOf(p_char) != -1);
}
private static boolean isUnreservedCharacter(char p_char) {
return (isAlphanum(p_char) || "-_.!~*'()".indexOf(p_char) != -1);
}
private static boolean isURIString(String p_uric) {
if (p_uric == null)
return false;
int end = p_uric.length();
char testChar = '\000';
for (int i = 0; i < end; i++) {
testChar = p_uric.charAt(i);
if (testChar == '%') {
if (i + 2 >= end || !isHex(p_uric.charAt(i + 1)) || !isHex(p_uric.charAt(i + 2)))
return false;
i += 2;
} else if (!isReservedCharacter(testChar) && !isUnreservedCharacter(testChar)) {
return false;
}
}
return true;
}
}

View file

@ -0,0 +1,470 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.XMLBufferListener;
import com.sun.xml.stream.xerces.xni.Augmentations;
import com.sun.xml.stream.xerces.xni.QName;
import com.sun.xml.stream.xerces.xni.XMLAttributes;
import com.sun.xml.stream.xerces.xni.XMLString;
public class XMLAttributesImpl implements XMLAttributes, XMLBufferListener {
protected static final int TABLE_SIZE = 101;
protected static final int SIZE_LIMIT = 20;
protected boolean fNamespaces = true;
protected int fLargeCount = 1;
protected int fLength;
protected Attribute[] fAttributes = new Attribute[4];
protected Attribute[] fAttributeTableView;
protected int[] fAttributeTableViewChainState;
protected int fTableViewBuckets;
protected boolean fIsTableViewConsistent;
public XMLAttributesImpl() {
this(101);
}
public XMLAttributesImpl(int tableSize) {
this.fTableViewBuckets = tableSize;
for (int i = 0; i < this.fAttributes.length; i++)
this.fAttributes[i] = new Attribute();
}
public void setNamespaces(boolean namespaces) {
this.fNamespaces = namespaces;
}
public int addAttribute(QName name, String type, String value) {
return addAttribute(name, type, value, null);
}
public int addAttribute(QName name, String type, String value, XMLString valueCache) {
int index;
if (this.fLength < 20) {
index = (name.uri != null && !name.uri.equals("")) ? getIndexFast(name.uri, name.localpart) : getIndexFast(name.rawname);
index = this.fLength;
if (index == -1 && this.fLength++ == this.fAttributes.length) {
Attribute[] attributes = new Attribute[this.fAttributes.length + 4];
System.arraycopy(this.fAttributes, 0, attributes, 0, this.fAttributes.length);
for (int i = this.fAttributes.length; i < attributes.length; i++)
attributes[i] = new Attribute();
this.fAttributes = attributes;
}
} else if (name.uri == null || name.uri.length() == 0 || (index = getIndexFast(name.uri, name.localpart)) == -1) {
if (!this.fIsTableViewConsistent || this.fLength == 20) {
prepareAndPopulateTableView();
this.fIsTableViewConsistent = true;
}
int bucket = getTableViewBucket(name.rawname);
if (this.fAttributeTableViewChainState[bucket] != this.fLargeCount) {
index = this.fLength;
if (this.fLength++ == this.fAttributes.length) {
Attribute[] attributes = new Attribute[this.fAttributes.length << 1];
System.arraycopy(this.fAttributes, 0, attributes, 0, this.fAttributes.length);
for (int i = this.fAttributes.length; i < attributes.length; i++)
attributes[i] = new Attribute();
this.fAttributes = attributes;
}
this.fAttributeTableViewChainState[bucket] = this.fLargeCount;
(this.fAttributes[index]).next = null;
this.fAttributeTableView[bucket] = this.fAttributes[index];
} else {
Attribute found = this.fAttributeTableView[bucket];
while (found != null &&
found.name.rawname != name.rawname)
found = found.next;
if (found == null) {
index = this.fLength;
if (this.fLength++ == this.fAttributes.length) {
Attribute[] attributes = new Attribute[this.fAttributes.length << 1];
System.arraycopy(this.fAttributes, 0, attributes, 0, this.fAttributes.length);
for (int i = this.fAttributes.length; i < attributes.length; i++)
attributes[i] = new Attribute();
this.fAttributes = attributes;
}
(this.fAttributes[index]).next = this.fAttributeTableView[bucket];
this.fAttributeTableView[bucket] = this.fAttributes[index];
} else {
index = getIndexFast(name.rawname);
}
}
}
Attribute attribute = this.fAttributes[index];
attribute.name.setValues(name);
attribute.type = type;
attribute.value = value;
attribute.xmlValue = valueCache;
attribute.nonNormalizedValue = value;
attribute.specified = false;
if (attribute.augs != null)
attribute.augs.removeAllItems();
return index;
}
public void removeAllAttributes() {
this.fLength = 0;
}
public void removeAttributeAt(int attrIndex) {
this.fIsTableViewConsistent = false;
if (attrIndex < this.fLength - 1) {
Attribute removedAttr = this.fAttributes[attrIndex];
System.arraycopy(this.fAttributes, attrIndex + 1, this.fAttributes, attrIndex, this.fLength - attrIndex - 1);
this.fAttributes[this.fLength - 1] = removedAttr;
}
this.fLength--;
}
public void setName(int attrIndex, QName attrName) {
(this.fAttributes[attrIndex]).name.setValues(attrName);
}
public void getName(int attrIndex, QName attrName) {
attrName.setValues((this.fAttributes[attrIndex]).name);
}
public void setType(int attrIndex, String attrType) {
(this.fAttributes[attrIndex]).type = attrType;
}
public void setValue(int attrIndex, String attrValue) {
setValue(attrIndex, attrValue, null);
}
public void setValue(int attrIndex, String attrValue, XMLString value) {
Attribute attribute = this.fAttributes[attrIndex];
attribute.value = attrValue;
attribute.nonNormalizedValue = attrValue;
attribute.xmlValue = value;
}
public void setNonNormalizedValue(int attrIndex, String attrValue) {
if (attrValue == null)
attrValue = (this.fAttributes[attrIndex]).value;
(this.fAttributes[attrIndex]).nonNormalizedValue = attrValue;
}
public String getNonNormalizedValue(int attrIndex) {
String value = (this.fAttributes[attrIndex]).nonNormalizedValue;
return value;
}
public void setSpecified(int attrIndex, boolean specified) {
(this.fAttributes[attrIndex]).specified = specified;
}
public boolean isSpecified(int attrIndex) {
return (this.fAttributes[attrIndex]).specified;
}
public int getLength() {
return this.fLength;
}
public String getType(int index) {
if (index < 0 || index >= this.fLength)
return null;
return getReportableType((this.fAttributes[index]).type);
}
public String getType(String qname) {
int index = getIndex(qname);
return (index != -1) ? getReportableType((this.fAttributes[index]).type) : null;
}
public String getValue(int index) {
if (index < 0 || index >= this.fLength)
return null;
if ((this.fAttributes[index]).value == null && (this.fAttributes[index]).xmlValue != null)
(this.fAttributes[index]).value = (this.fAttributes[index]).xmlValue.toString();
return (this.fAttributes[index]).value;
}
public String getValue(String qname) {
int index = getIndex(qname);
if (index == -1)
return null;
if ((this.fAttributes[index]).value == null)
(this.fAttributes[index]).value = (this.fAttributes[index]).xmlValue.toString();
return (this.fAttributes[index]).value;
}
public String getName(int index) {
if (index < 0 || index >= this.fLength)
return null;
return (this.fAttributes[index]).name.rawname;
}
public int getIndex(String qName) {
for (int i = 0; i < this.fLength; i++) {
Attribute attribute = this.fAttributes[i];
if (attribute.name.rawname != null && attribute.name.rawname.equals(qName))
return i;
}
return -1;
}
public int getIndex(String uri, String localPart) {
for (int i = 0; i < this.fLength; i++) {
Attribute attribute = this.fAttributes[i];
if (attribute.name.localpart != null && attribute.name.localpart.equals(localPart) && (uri == attribute.name.uri || (uri != null && attribute.name.uri != null && attribute.name.uri.equals(uri))))
return i;
}
return -1;
}
public String getLocalName(int index) {
if (!this.fNamespaces)
return "";
if (index < 0 || index >= this.fLength)
return null;
return (this.fAttributes[index]).name.localpart;
}
public String getQName(int index) {
if (index < 0 || index >= this.fLength)
return null;
String rawname = (this.fAttributes[index]).name.rawname;
return (rawname != null) ? rawname : "";
}
public QName getQualifiedName(int index) {
if (index < 0 || index >= this.fLength)
return null;
return (this.fAttributes[index]).name;
}
public String getType(String uri, String localName) {
if (!this.fNamespaces)
return null;
int index = getIndex(uri, localName);
return (index != -1) ? getReportableType((this.fAttributes[index]).type) : null;
}
public String getPrefix(int index) {
if (index < 0 || index >= this.fLength)
return null;
String prefix = (this.fAttributes[index]).name.prefix;
return (prefix != null) ? prefix : "";
}
public String getURI(int index) {
if (index < 0 || index >= this.fLength)
return null;
String uri = (this.fAttributes[index]).name.uri;
return uri;
}
public String getValue(String uri, String localName) {
int index = getIndex(uri, localName);
return (index != -1) ? getValue(index) : null;
}
public Augmentations getAugmentations(String uri, String localName) {
int index = getIndex(uri, localName);
return (index != -1) ? (this.fAttributes[index]).augs : null;
}
public Augmentations getAugmentations(String qName) {
int index = getIndex(qName);
return (index != -1) ? (this.fAttributes[index]).augs : null;
}
public Augmentations getAugmentations(int attributeIndex) {
if (attributeIndex < 0 || attributeIndex >= this.fLength)
return null;
return (this.fAttributes[attributeIndex]).augs;
}
public void setAugmentations(int attrIndex, Augmentations augs) {
(this.fAttributes[attrIndex]).augs = augs;
}
public void setURI(int attrIndex, String uri) {
(this.fAttributes[attrIndex]).name.uri = uri;
}
public void setSchemaId(int attrIndex, boolean schemaId) {
(this.fAttributes[attrIndex]).schemaId = schemaId;
}
public boolean getSchemaId(int index) {
if (index < 0 || index >= this.fLength)
return false;
return (this.fAttributes[index]).schemaId;
}
public boolean getSchemaId(String qname) {
int index = getIndex(qname);
return (index != -1) ? (this.fAttributes[index]).schemaId : false;
}
public boolean getSchemaId(String uri, String localName) {
if (!this.fNamespaces)
return false;
int index = getIndex(uri, localName);
return (index != -1) ? (this.fAttributes[index]).schemaId : false;
}
public int getIndexFast(String qName) {
for (int i = 0; i < this.fLength; i++) {
Attribute attribute = this.fAttributes[i];
if (attribute.name.rawname == qName)
return i;
}
return -1;
}
public void addAttributeNS(QName name, String type, String value) {
int index = this.fLength;
if (this.fLength++ == this.fAttributes.length) {
Attribute[] attributes;
if (this.fLength < 20) {
attributes = new Attribute[this.fAttributes.length + 4];
} else {
attributes = new Attribute[this.fAttributes.length << 1];
}
System.arraycopy(this.fAttributes, 0, attributes, 0, this.fAttributes.length);
for (int i = this.fAttributes.length; i < attributes.length; i++)
attributes[i] = new Attribute();
this.fAttributes = attributes;
}
Attribute attribute = this.fAttributes[index];
attribute.name.setValues(name);
attribute.type = type;
attribute.value = value;
attribute.nonNormalizedValue = value;
attribute.specified = false;
if (attribute.augs != null)
attribute.augs.removeAllItems();
}
public QName checkDuplicatesNS() {
if (this.fLength <= 20) {
for (int i = 0; i < this.fLength - 1; i++) {
Attribute att1 = this.fAttributes[i];
for (int j = i + 1; j < this.fLength; j++) {
Attribute att2 = this.fAttributes[j];
if (att1.name.localpart == att2.name.localpart && att1.name.uri == att2.name.uri)
return att2.name;
}
}
} else {
this.fIsTableViewConsistent = false;
prepareTableView();
for (int i = this.fLength - 1; i >= 0; i--) {
Attribute attr = this.fAttributes[i];
int bucket = getTableViewBucket(attr.name.localpart, attr.name.uri);
if (this.fAttributeTableViewChainState[bucket] != this.fLargeCount) {
this.fAttributeTableViewChainState[bucket] = this.fLargeCount;
attr.next = null;
this.fAttributeTableView[bucket] = attr;
} else {
Attribute found = this.fAttributeTableView[bucket];
while (found != null) {
if (found.name.localpart == attr.name.localpart && found.name.uri == attr.name.uri)
return attr.name;
found = found.next;
}
attr.next = this.fAttributeTableView[bucket];
this.fAttributeTableView[bucket] = attr;
}
}
}
return null;
}
public int getIndexFast(String uri, String localPart) {
for (int i = 0; i < this.fLength; i++) {
Attribute attribute = this.fAttributes[i];
if (attribute.name.localpart == localPart && attribute.name.uri == uri)
return i;
}
return -1;
}
protected String getReportableType(String type) {
if (type.indexOf('(') == 0 && type.lastIndexOf(')') == type.length() - 1)
return "NMTOKEN";
return type;
}
protected int getTableViewBucket(String qname) {
return (qname.hashCode() & Integer.MAX_VALUE) % this.fTableViewBuckets;
}
protected int getTableViewBucket(String localpart, String uri) {
if (uri == null)
return (localpart.hashCode() & Integer.MAX_VALUE) % this.fTableViewBuckets;
return (localpart.hashCode() + uri.hashCode() & Integer.MAX_VALUE) % this.fTableViewBuckets;
}
protected void cleanTableView() {
if (++this.fLargeCount < 0) {
if (this.fAttributeTableViewChainState != null)
for (int i = this.fTableViewBuckets - 1; i >= 0; i--)
this.fAttributeTableViewChainState[i] = 0;
this.fLargeCount = 1;
}
}
protected void prepareTableView() {
if (this.fAttributeTableView == null) {
this.fAttributeTableView = new Attribute[this.fTableViewBuckets];
this.fAttributeTableViewChainState = new int[this.fTableViewBuckets];
} else {
cleanTableView();
}
}
protected void prepareAndPopulateTableView() {
prepareTableView();
for (int i = 0; i < this.fLength; i++) {
Attribute attr = this.fAttributes[i];
int bucket = getTableViewBucket(attr.name.rawname);
if (this.fAttributeTableViewChainState[bucket] != this.fLargeCount) {
this.fAttributeTableViewChainState[bucket] = this.fLargeCount;
attr.next = null;
this.fAttributeTableView[bucket] = attr;
} else {
attr.next = this.fAttributeTableView[bucket];
this.fAttributeTableView[bucket] = attr;
}
}
}
public void refresh() {
if (this.fLength > 0)
for (int i = 0; i < this.fLength; i++)
getValue(i);
}
public void refresh(int pos) {}
static class Attribute {
public QName name = new QName();
public String type;
public String value;
public XMLString xmlValue;
public String nonNormalizedValue;
public boolean specified;
public boolean schemaId;
public Augmentations augs = null;
public Attribute next;
}
}

View file

@ -0,0 +1,33 @@
package com.sun.xml.stream.xerces.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class XMLAttributesIteratorImpl extends XMLAttributesImpl implements Iterator {
protected int fCurrent = 0;
protected XMLAttributesImpl.Attribute fLastReturnedItem;
public boolean hasNext() {
return (this.fCurrent < getLength());
}
public Object next() {
if (hasNext())
return this.fLastReturnedItem = this.fAttributes[this.fCurrent++];
throw new NoSuchElementException();
}
public void remove() {
if (this.fLastReturnedItem == this.fAttributes[this.fCurrent - 1]) {
removeAttributeAt(this.fCurrent--);
} else {
throw new IllegalStateException();
}
}
public void removeAllAttributes() {
super.removeAllAttributes();
this.fCurrent = 0;
}
}

View file

@ -0,0 +1,781 @@
package com.sun.xml.stream.xerces.util;
import java.util.Arrays;
public class XMLChar {
private static final byte[] CHARS = new byte[65536];
public static final int MASK_VALID = 1;
public static final int MASK_SPACE = 2;
public static final int MASK_NAME_START = 4;
public static final int MASK_NAME = 8;
public static final int MASK_PUBID = 16;
public static final int MASK_CONTENT = 32;
public static final int MASK_NCNAME_START = 64;
public static final int MASK_NCNAME = 128;
static {
CHARS[9] = 35;
CHARS[10] = 19;
CHARS[13] = 19;
CHARS[32] = 51;
CHARS[33] = 49;
CHARS[34] = 33;
Arrays.fill(CHARS, 35, 38, (byte)49);
CHARS[38] = 1;
Arrays.fill(CHARS, 39, 45, (byte)49);
Arrays.fill(CHARS, 45, 47, (byte)-71);
CHARS[47] = 49;
Arrays.fill(CHARS, 48, 58, (byte)-71);
CHARS[58] = 61;
CHARS[59] = 49;
CHARS[60] = 1;
CHARS[61] = 49;
CHARS[62] = 33;
Arrays.fill(CHARS, 63, 65, (byte)49);
Arrays.fill(CHARS, 65, 91, (byte)-3);
Arrays.fill(CHARS, 91, 93, (byte)33);
CHARS[93] = 1;
CHARS[94] = 33;
CHARS[95] = -3;
CHARS[96] = 33;
Arrays.fill(CHARS, 97, 123, (byte)-3);
Arrays.fill(CHARS, 123, 183, (byte)33);
CHARS[183] = -87;
Arrays.fill(CHARS, 184, 192, (byte)33);
Arrays.fill(CHARS, 192, 215, (byte)-19);
CHARS[215] = 33;
Arrays.fill(CHARS, 216, 247, (byte)-19);
CHARS[247] = 33;
Arrays.fill(CHARS, 248, 306, (byte)-19);
Arrays.fill(CHARS, 306, 308, (byte)33);
Arrays.fill(CHARS, 308, 319, (byte)-19);
Arrays.fill(CHARS, 319, 321, (byte)33);
Arrays.fill(CHARS, 321, 329, (byte)-19);
CHARS[329] = 33;
Arrays.fill(CHARS, 330, 383, (byte)-19);
CHARS[383] = 33;
Arrays.fill(CHARS, 384, 452, (byte)-19);
Arrays.fill(CHARS, 452, 461, (byte)33);
Arrays.fill(CHARS, 461, 497, (byte)-19);
Arrays.fill(CHARS, 497, 500, (byte)33);
Arrays.fill(CHARS, 500, 502, (byte)-19);
Arrays.fill(CHARS, 502, 506, (byte)33);
Arrays.fill(CHARS, 506, 536, (byte)-19);
Arrays.fill(CHARS, 536, 592, (byte)33);
Arrays.fill(CHARS, 592, 681, (byte)-19);
Arrays.fill(CHARS, 681, 699, (byte)33);
Arrays.fill(CHARS, 699, 706, (byte)-19);
Arrays.fill(CHARS, 706, 720, (byte)33);
Arrays.fill(CHARS, 720, 722, (byte)-87);
Arrays.fill(CHARS, 722, 768, (byte)33);
Arrays.fill(CHARS, 768, 838, (byte)-87);
Arrays.fill(CHARS, 838, 864, (byte)33);
Arrays.fill(CHARS, 864, 866, (byte)-87);
Arrays.fill(CHARS, 866, 902, (byte)33);
CHARS[902] = -19;
CHARS[903] = -87;
Arrays.fill(CHARS, 904, 907, (byte)-19);
CHARS[907] = 33;
CHARS[908] = -19;
CHARS[909] = 33;
Arrays.fill(CHARS, 910, 930, (byte)-19);
CHARS[930] = 33;
Arrays.fill(CHARS, 931, 975, (byte)-19);
CHARS[975] = 33;
Arrays.fill(CHARS, 976, 983, (byte)-19);
Arrays.fill(CHARS, 983, 986, (byte)33);
CHARS[986] = -19;
CHARS[987] = 33;
CHARS[988] = -19;
CHARS[989] = 33;
CHARS[990] = -19;
CHARS[991] = 33;
CHARS[992] = -19;
CHARS[993] = 33;
Arrays.fill(CHARS, 994, 1012, (byte)-19);
Arrays.fill(CHARS, 1012, 1025, (byte)33);
Arrays.fill(CHARS, 1025, 1037, (byte)-19);
CHARS[1037] = 33;
Arrays.fill(CHARS, 1038, 1104, (byte)-19);
CHARS[1104] = 33;
Arrays.fill(CHARS, 1105, 1117, (byte)-19);
CHARS[1117] = 33;
Arrays.fill(CHARS, 1118, 1154, (byte)-19);
CHARS[1154] = 33;
Arrays.fill(CHARS, 1155, 1159, (byte)-87);
Arrays.fill(CHARS, 1159, 1168, (byte)33);
Arrays.fill(CHARS, 1168, 1221, (byte)-19);
Arrays.fill(CHARS, 1221, 1223, (byte)33);
Arrays.fill(CHARS, 1223, 1225, (byte)-19);
Arrays.fill(CHARS, 1225, 1227, (byte)33);
Arrays.fill(CHARS, 1227, 1229, (byte)-19);
Arrays.fill(CHARS, 1229, 1232, (byte)33);
Arrays.fill(CHARS, 1232, 1260, (byte)-19);
Arrays.fill(CHARS, 1260, 1262, (byte)33);
Arrays.fill(CHARS, 1262, 1270, (byte)-19);
Arrays.fill(CHARS, 1270, 1272, (byte)33);
Arrays.fill(CHARS, 1272, 1274, (byte)-19);
Arrays.fill(CHARS, 1274, 1329, (byte)33);
Arrays.fill(CHARS, 1329, 1367, (byte)-19);
Arrays.fill(CHARS, 1367, 1369, (byte)33);
CHARS[1369] = -19;
Arrays.fill(CHARS, 1370, 1377, (byte)33);
Arrays.fill(CHARS, 1377, 1415, (byte)-19);
Arrays.fill(CHARS, 1415, 1425, (byte)33);
Arrays.fill(CHARS, 1425, 1442, (byte)-87);
CHARS[1442] = 33;
Arrays.fill(CHARS, 1443, 1466, (byte)-87);
CHARS[1466] = 33;
Arrays.fill(CHARS, 1467, 1470, (byte)-87);
CHARS[1470] = 33;
CHARS[1471] = -87;
CHARS[1472] = 33;
Arrays.fill(CHARS, 1473, 1475, (byte)-87);
CHARS[1475] = 33;
CHARS[1476] = -87;
Arrays.fill(CHARS, 1477, 1488, (byte)33);
Arrays.fill(CHARS, 1488, 1515, (byte)-19);
Arrays.fill(CHARS, 1515, 1520, (byte)33);
Arrays.fill(CHARS, 1520, 1523, (byte)-19);
Arrays.fill(CHARS, 1523, 1569, (byte)33);
Arrays.fill(CHARS, 1569, 1595, (byte)-19);
Arrays.fill(CHARS, 1595, 1600, (byte)33);
CHARS[1600] = -87;
Arrays.fill(CHARS, 1601, 1611, (byte)-19);
Arrays.fill(CHARS, 1611, 1619, (byte)-87);
Arrays.fill(CHARS, 1619, 1632, (byte)33);
Arrays.fill(CHARS, 1632, 1642, (byte)-87);
Arrays.fill(CHARS, 1642, 1648, (byte)33);
CHARS[1648] = -87;
Arrays.fill(CHARS, 1649, 1720, (byte)-19);
Arrays.fill(CHARS, 1720, 1722, (byte)33);
Arrays.fill(CHARS, 1722, 1727, (byte)-19);
CHARS[1727] = 33;
Arrays.fill(CHARS, 1728, 1743, (byte)-19);
CHARS[1743] = 33;
Arrays.fill(CHARS, 1744, 1748, (byte)-19);
CHARS[1748] = 33;
CHARS[1749] = -19;
Arrays.fill(CHARS, 1750, 1765, (byte)-87);
Arrays.fill(CHARS, 1765, 1767, (byte)-19);
Arrays.fill(CHARS, 1767, 1769, (byte)-87);
CHARS[1769] = 33;
Arrays.fill(CHARS, 1770, 1774, (byte)-87);
Arrays.fill(CHARS, 1774, 1776, (byte)33);
Arrays.fill(CHARS, 1776, 1786, (byte)-87);
Arrays.fill(CHARS, 1786, 2305, (byte)33);
Arrays.fill(CHARS, 2305, 2308, (byte)-87);
CHARS[2308] = 33;
Arrays.fill(CHARS, 2309, 2362, (byte)-19);
Arrays.fill(CHARS, 2362, 2364, (byte)33);
CHARS[2364] = -87;
CHARS[2365] = -19;
Arrays.fill(CHARS, 2366, 2382, (byte)-87);
Arrays.fill(CHARS, 2382, 2385, (byte)33);
Arrays.fill(CHARS, 2385, 2389, (byte)-87);
Arrays.fill(CHARS, 2389, 2392, (byte)33);
Arrays.fill(CHARS, 2392, 2402, (byte)-19);
Arrays.fill(CHARS, 2402, 2404, (byte)-87);
Arrays.fill(CHARS, 2404, 2406, (byte)33);
Arrays.fill(CHARS, 2406, 2416, (byte)-87);
Arrays.fill(CHARS, 2416, 2433, (byte)33);
Arrays.fill(CHARS, 2433, 2436, (byte)-87);
CHARS[2436] = 33;
Arrays.fill(CHARS, 2437, 2445, (byte)-19);
Arrays.fill(CHARS, 2445, 2447, (byte)33);
Arrays.fill(CHARS, 2447, 2449, (byte)-19);
Arrays.fill(CHARS, 2449, 2451, (byte)33);
Arrays.fill(CHARS, 2451, 2473, (byte)-19);
CHARS[2473] = 33;
Arrays.fill(CHARS, 2474, 2481, (byte)-19);
CHARS[2481] = 33;
CHARS[2482] = -19;
Arrays.fill(CHARS, 2483, 2486, (byte)33);
Arrays.fill(CHARS, 2486, 2490, (byte)-19);
Arrays.fill(CHARS, 2490, 2492, (byte)33);
CHARS[2492] = -87;
CHARS[2493] = 33;
Arrays.fill(CHARS, 2494, 2501, (byte)-87);
Arrays.fill(CHARS, 2501, 2503, (byte)33);
Arrays.fill(CHARS, 2503, 2505, (byte)-87);
Arrays.fill(CHARS, 2505, 2507, (byte)33);
Arrays.fill(CHARS, 2507, 2510, (byte)-87);
Arrays.fill(CHARS, 2510, 2519, (byte)33);
CHARS[2519] = -87;
Arrays.fill(CHARS, 2520, 2524, (byte)33);
Arrays.fill(CHARS, 2524, 2526, (byte)-19);
CHARS[2526] = 33;
Arrays.fill(CHARS, 2527, 2530, (byte)-19);
Arrays.fill(CHARS, 2530, 2532, (byte)-87);
Arrays.fill(CHARS, 2532, 2534, (byte)33);
Arrays.fill(CHARS, 2534, 2544, (byte)-87);
Arrays.fill(CHARS, 2544, 2546, (byte)-19);
Arrays.fill(CHARS, 2546, 2562, (byte)33);
CHARS[2562] = -87;
Arrays.fill(CHARS, 2563, 2565, (byte)33);
Arrays.fill(CHARS, 2565, 2571, (byte)-19);
Arrays.fill(CHARS, 2571, 2575, (byte)33);
Arrays.fill(CHARS, 2575, 2577, (byte)-19);
Arrays.fill(CHARS, 2577, 2579, (byte)33);
Arrays.fill(CHARS, 2579, 2601, (byte)-19);
CHARS[2601] = 33;
Arrays.fill(CHARS, 2602, 2609, (byte)-19);
CHARS[2609] = 33;
Arrays.fill(CHARS, 2610, 2612, (byte)-19);
CHARS[2612] = 33;
Arrays.fill(CHARS, 2613, 2615, (byte)-19);
CHARS[2615] = 33;
Arrays.fill(CHARS, 2616, 2618, (byte)-19);
Arrays.fill(CHARS, 2618, 2620, (byte)33);
CHARS[2620] = -87;
CHARS[2621] = 33;
Arrays.fill(CHARS, 2622, 2627, (byte)-87);
Arrays.fill(CHARS, 2627, 2631, (byte)33);
Arrays.fill(CHARS, 2631, 2633, (byte)-87);
Arrays.fill(CHARS, 2633, 2635, (byte)33);
Arrays.fill(CHARS, 2635, 2638, (byte)-87);
Arrays.fill(CHARS, 2638, 2649, (byte)33);
Arrays.fill(CHARS, 2649, 2653, (byte)-19);
CHARS[2653] = 33;
CHARS[2654] = -19;
Arrays.fill(CHARS, 2655, 2662, (byte)33);
Arrays.fill(CHARS, 2662, 2674, (byte)-87);
Arrays.fill(CHARS, 2674, 2677, (byte)-19);
Arrays.fill(CHARS, 2677, 2689, (byte)33);
Arrays.fill(CHARS, 2689, 2692, (byte)-87);
CHARS[2692] = 33;
Arrays.fill(CHARS, 2693, 2700, (byte)-19);
CHARS[2700] = 33;
CHARS[2701] = -19;
CHARS[2702] = 33;
Arrays.fill(CHARS, 2703, 2706, (byte)-19);
CHARS[2706] = 33;
Arrays.fill(CHARS, 2707, 2729, (byte)-19);
CHARS[2729] = 33;
Arrays.fill(CHARS, 2730, 2737, (byte)-19);
CHARS[2737] = 33;
Arrays.fill(CHARS, 2738, 2740, (byte)-19);
CHARS[2740] = 33;
Arrays.fill(CHARS, 2741, 2746, (byte)-19);
Arrays.fill(CHARS, 2746, 2748, (byte)33);
CHARS[2748] = -87;
CHARS[2749] = -19;
Arrays.fill(CHARS, 2750, 2758, (byte)-87);
CHARS[2758] = 33;
Arrays.fill(CHARS, 2759, 2762, (byte)-87);
CHARS[2762] = 33;
Arrays.fill(CHARS, 2763, 2766, (byte)-87);
Arrays.fill(CHARS, 2766, 2784, (byte)33);
CHARS[2784] = -19;
Arrays.fill(CHARS, 2785, 2790, (byte)33);
Arrays.fill(CHARS, 2790, 2800, (byte)-87);
Arrays.fill(CHARS, 2800, 2817, (byte)33);
Arrays.fill(CHARS, 2817, 2820, (byte)-87);
CHARS[2820] = 33;
Arrays.fill(CHARS, 2821, 2829, (byte)-19);
Arrays.fill(CHARS, 2829, 2831, (byte)33);
Arrays.fill(CHARS, 2831, 2833, (byte)-19);
Arrays.fill(CHARS, 2833, 2835, (byte)33);
Arrays.fill(CHARS, 2835, 2857, (byte)-19);
CHARS[2857] = 33;
Arrays.fill(CHARS, 2858, 2865, (byte)-19);
CHARS[2865] = 33;
Arrays.fill(CHARS, 2866, 2868, (byte)-19);
Arrays.fill(CHARS, 2868, 2870, (byte)33);
Arrays.fill(CHARS, 2870, 2874, (byte)-19);
Arrays.fill(CHARS, 2874, 2876, (byte)33);
CHARS[2876] = -87;
CHARS[2877] = -19;
Arrays.fill(CHARS, 2878, 2884, (byte)-87);
Arrays.fill(CHARS, 2884, 2887, (byte)33);
Arrays.fill(CHARS, 2887, 2889, (byte)-87);
Arrays.fill(CHARS, 2889, 2891, (byte)33);
Arrays.fill(CHARS, 2891, 2894, (byte)-87);
Arrays.fill(CHARS, 2894, 2902, (byte)33);
Arrays.fill(CHARS, 2902, 2904, (byte)-87);
Arrays.fill(CHARS, 2904, 2908, (byte)33);
Arrays.fill(CHARS, 2908, 2910, (byte)-19);
CHARS[2910] = 33;
Arrays.fill(CHARS, 2911, 2914, (byte)-19);
Arrays.fill(CHARS, 2914, 2918, (byte)33);
Arrays.fill(CHARS, 2918, 2928, (byte)-87);
Arrays.fill(CHARS, 2928, 2946, (byte)33);
Arrays.fill(CHARS, 2946, 2948, (byte)-87);
CHARS[2948] = 33;
Arrays.fill(CHARS, 2949, 2955, (byte)-19);
Arrays.fill(CHARS, 2955, 2958, (byte)33);
Arrays.fill(CHARS, 2958, 2961, (byte)-19);
CHARS[2961] = 33;
Arrays.fill(CHARS, 2962, 2966, (byte)-19);
Arrays.fill(CHARS, 2966, 2969, (byte)33);
Arrays.fill(CHARS, 2969, 2971, (byte)-19);
CHARS[2971] = 33;
CHARS[2972] = -19;
CHARS[2973] = 33;
Arrays.fill(CHARS, 2974, 2976, (byte)-19);
Arrays.fill(CHARS, 2976, 2979, (byte)33);
Arrays.fill(CHARS, 2979, 2981, (byte)-19);
Arrays.fill(CHARS, 2981, 2984, (byte)33);
Arrays.fill(CHARS, 2984, 2987, (byte)-19);
Arrays.fill(CHARS, 2987, 2990, (byte)33);
Arrays.fill(CHARS, 2990, 2998, (byte)-19);
CHARS[2998] = 33;
Arrays.fill(CHARS, 2999, 3002, (byte)-19);
Arrays.fill(CHARS, 3002, 3006, (byte)33);
Arrays.fill(CHARS, 3006, 3011, (byte)-87);
Arrays.fill(CHARS, 3011, 3014, (byte)33);
Arrays.fill(CHARS, 3014, 3017, (byte)-87);
CHARS[3017] = 33;
Arrays.fill(CHARS, 3018, 3022, (byte)-87);
Arrays.fill(CHARS, 3022, 3031, (byte)33);
CHARS[3031] = -87;
Arrays.fill(CHARS, 3032, 3047, (byte)33);
Arrays.fill(CHARS, 3047, 3056, (byte)-87);
Arrays.fill(CHARS, 3056, 3073, (byte)33);
Arrays.fill(CHARS, 3073, 3076, (byte)-87);
CHARS[3076] = 33;
Arrays.fill(CHARS, 3077, 3085, (byte)-19);
CHARS[3085] = 33;
Arrays.fill(CHARS, 3086, 3089, (byte)-19);
CHARS[3089] = 33;
Arrays.fill(CHARS, 3090, 3113, (byte)-19);
CHARS[3113] = 33;
Arrays.fill(CHARS, 3114, 3124, (byte)-19);
CHARS[3124] = 33;
Arrays.fill(CHARS, 3125, 3130, (byte)-19);
Arrays.fill(CHARS, 3130, 3134, (byte)33);
Arrays.fill(CHARS, 3134, 3141, (byte)-87);
CHARS[3141] = 33;
Arrays.fill(CHARS, 3142, 3145, (byte)-87);
CHARS[3145] = 33;
Arrays.fill(CHARS, 3146, 3150, (byte)-87);
Arrays.fill(CHARS, 3150, 3157, (byte)33);
Arrays.fill(CHARS, 3157, 3159, (byte)-87);
Arrays.fill(CHARS, 3159, 3168, (byte)33);
Arrays.fill(CHARS, 3168, 3170, (byte)-19);
Arrays.fill(CHARS, 3170, 3174, (byte)33);
Arrays.fill(CHARS, 3174, 3184, (byte)-87);
Arrays.fill(CHARS, 3184, 3202, (byte)33);
Arrays.fill(CHARS, 3202, 3204, (byte)-87);
CHARS[3204] = 33;
Arrays.fill(CHARS, 3205, 3213, (byte)-19);
CHARS[3213] = 33;
Arrays.fill(CHARS, 3214, 3217, (byte)-19);
CHARS[3217] = 33;
Arrays.fill(CHARS, 3218, 3241, (byte)-19);
CHARS[3241] = 33;
Arrays.fill(CHARS, 3242, 3252, (byte)-19);
CHARS[3252] = 33;
Arrays.fill(CHARS, 3253, 3258, (byte)-19);
Arrays.fill(CHARS, 3258, 3262, (byte)33);
Arrays.fill(CHARS, 3262, 3269, (byte)-87);
CHARS[3269] = 33;
Arrays.fill(CHARS, 3270, 3273, (byte)-87);
CHARS[3273] = 33;
Arrays.fill(CHARS, 3274, 3278, (byte)-87);
Arrays.fill(CHARS, 3278, 3285, (byte)33);
Arrays.fill(CHARS, 3285, 3287, (byte)-87);
Arrays.fill(CHARS, 3287, 3294, (byte)33);
CHARS[3294] = -19;
CHARS[3295] = 33;
Arrays.fill(CHARS, 3296, 3298, (byte)-19);
Arrays.fill(CHARS, 3298, 3302, (byte)33);
Arrays.fill(CHARS, 3302, 3312, (byte)-87);
Arrays.fill(CHARS, 3312, 3330, (byte)33);
Arrays.fill(CHARS, 3330, 3332, (byte)-87);
CHARS[3332] = 33;
Arrays.fill(CHARS, 3333, 3341, (byte)-19);
CHARS[3341] = 33;
Arrays.fill(CHARS, 3342, 3345, (byte)-19);
CHARS[3345] = 33;
Arrays.fill(CHARS, 3346, 3369, (byte)-19);
CHARS[3369] = 33;
Arrays.fill(CHARS, 3370, 3386, (byte)-19);
Arrays.fill(CHARS, 3386, 3390, (byte)33);
Arrays.fill(CHARS, 3390, 3396, (byte)-87);
Arrays.fill(CHARS, 3396, 3398, (byte)33);
Arrays.fill(CHARS, 3398, 3401, (byte)-87);
CHARS[3401] = 33;
Arrays.fill(CHARS, 3402, 3406, (byte)-87);
Arrays.fill(CHARS, 3406, 3415, (byte)33);
CHARS[3415] = -87;
Arrays.fill(CHARS, 3416, 3424, (byte)33);
Arrays.fill(CHARS, 3424, 3426, (byte)-19);
Arrays.fill(CHARS, 3426, 3430, (byte)33);
Arrays.fill(CHARS, 3430, 3440, (byte)-87);
Arrays.fill(CHARS, 3440, 3585, (byte)33);
Arrays.fill(CHARS, 3585, 3631, (byte)-19);
CHARS[3631] = 33;
CHARS[3632] = -19;
CHARS[3633] = -87;
Arrays.fill(CHARS, 3634, 3636, (byte)-19);
Arrays.fill(CHARS, 3636, 3643, (byte)-87);
Arrays.fill(CHARS, 3643, 3648, (byte)33);
Arrays.fill(CHARS, 3648, 3654, (byte)-19);
Arrays.fill(CHARS, 3654, 3663, (byte)-87);
CHARS[3663] = 33;
Arrays.fill(CHARS, 3664, 3674, (byte)-87);
Arrays.fill(CHARS, 3674, 3713, (byte)33);
Arrays.fill(CHARS, 3713, 3715, (byte)-19);
CHARS[3715] = 33;
CHARS[3716] = -19;
Arrays.fill(CHARS, 3717, 3719, (byte)33);
Arrays.fill(CHARS, 3719, 3721, (byte)-19);
CHARS[3721] = 33;
CHARS[3722] = -19;
Arrays.fill(CHARS, 3723, 3725, (byte)33);
CHARS[3725] = -19;
Arrays.fill(CHARS, 3726, 3732, (byte)33);
Arrays.fill(CHARS, 3732, 3736, (byte)-19);
CHARS[3736] = 33;
Arrays.fill(CHARS, 3737, 3744, (byte)-19);
CHARS[3744] = 33;
Arrays.fill(CHARS, 3745, 3748, (byte)-19);
CHARS[3748] = 33;
CHARS[3749] = -19;
CHARS[3750] = 33;
CHARS[3751] = -19;
Arrays.fill(CHARS, 3752, 3754, (byte)33);
Arrays.fill(CHARS, 3754, 3756, (byte)-19);
CHARS[3756] = 33;
Arrays.fill(CHARS, 3757, 3759, (byte)-19);
CHARS[3759] = 33;
CHARS[3760] = -19;
CHARS[3761] = -87;
Arrays.fill(CHARS, 3762, 3764, (byte)-19);
Arrays.fill(CHARS, 3764, 3770, (byte)-87);
CHARS[3770] = 33;
Arrays.fill(CHARS, 3771, 3773, (byte)-87);
CHARS[3773] = -19;
Arrays.fill(CHARS, 3774, 3776, (byte)33);
Arrays.fill(CHARS, 3776, 3781, (byte)-19);
CHARS[3781] = 33;
CHARS[3782] = -87;
CHARS[3783] = 33;
Arrays.fill(CHARS, 3784, 3790, (byte)-87);
Arrays.fill(CHARS, 3790, 3792, (byte)33);
Arrays.fill(CHARS, 3792, 3802, (byte)-87);
Arrays.fill(CHARS, 3802, 3864, (byte)33);
Arrays.fill(CHARS, 3864, 3866, (byte)-87);
Arrays.fill(CHARS, 3866, 3872, (byte)33);
Arrays.fill(CHARS, 3872, 3882, (byte)-87);
Arrays.fill(CHARS, 3882, 3893, (byte)33);
CHARS[3893] = -87;
CHARS[3894] = 33;
CHARS[3895] = -87;
CHARS[3896] = 33;
CHARS[3897] = -87;
Arrays.fill(CHARS, 3898, 3902, (byte)33);
Arrays.fill(CHARS, 3902, 3904, (byte)-87);
Arrays.fill(CHARS, 3904, 3912, (byte)-19);
CHARS[3912] = 33;
Arrays.fill(CHARS, 3913, 3946, (byte)-19);
Arrays.fill(CHARS, 3946, 3953, (byte)33);
Arrays.fill(CHARS, 3953, 3973, (byte)-87);
CHARS[3973] = 33;
Arrays.fill(CHARS, 3974, 3980, (byte)-87);
Arrays.fill(CHARS, 3980, 3984, (byte)33);
Arrays.fill(CHARS, 3984, 3990, (byte)-87);
CHARS[3990] = 33;
CHARS[3991] = -87;
CHARS[3992] = 33;
Arrays.fill(CHARS, 3993, 4014, (byte)-87);
Arrays.fill(CHARS, 4014, 4017, (byte)33);
Arrays.fill(CHARS, 4017, 4024, (byte)-87);
CHARS[4024] = 33;
CHARS[4025] = -87;
Arrays.fill(CHARS, 4026, 4256, (byte)33);
Arrays.fill(CHARS, 4256, 4294, (byte)-19);
Arrays.fill(CHARS, 4294, 4304, (byte)33);
Arrays.fill(CHARS, 4304, 4343, (byte)-19);
Arrays.fill(CHARS, 4343, 4352, (byte)33);
CHARS[4352] = -19;
CHARS[4353] = 33;
Arrays.fill(CHARS, 4354, 4356, (byte)-19);
CHARS[4356] = 33;
Arrays.fill(CHARS, 4357, 4360, (byte)-19);
CHARS[4360] = 33;
CHARS[4361] = -19;
CHARS[4362] = 33;
Arrays.fill(CHARS, 4363, 4365, (byte)-19);
CHARS[4365] = 33;
Arrays.fill(CHARS, 4366, 4371, (byte)-19);
Arrays.fill(CHARS, 4371, 4412, (byte)33);
CHARS[4412] = -19;
CHARS[4413] = 33;
CHARS[4414] = -19;
CHARS[4415] = 33;
CHARS[4416] = -19;
Arrays.fill(CHARS, 4417, 4428, (byte)33);
CHARS[4428] = -19;
CHARS[4429] = 33;
CHARS[4430] = -19;
CHARS[4431] = 33;
CHARS[4432] = -19;
Arrays.fill(CHARS, 4433, 4436, (byte)33);
Arrays.fill(CHARS, 4436, 4438, (byte)-19);
Arrays.fill(CHARS, 4438, 4441, (byte)33);
CHARS[4441] = -19;
Arrays.fill(CHARS, 4442, 4447, (byte)33);
Arrays.fill(CHARS, 4447, 4450, (byte)-19);
CHARS[4450] = 33;
CHARS[4451] = -19;
CHARS[4452] = 33;
CHARS[4453] = -19;
CHARS[4454] = 33;
CHARS[4455] = -19;
CHARS[4456] = 33;
CHARS[4457] = -19;
Arrays.fill(CHARS, 4458, 4461, (byte)33);
Arrays.fill(CHARS, 4461, 4463, (byte)-19);
Arrays.fill(CHARS, 4463, 4466, (byte)33);
Arrays.fill(CHARS, 4466, 4468, (byte)-19);
CHARS[4468] = 33;
CHARS[4469] = -19;
Arrays.fill(CHARS, 4470, 4510, (byte)33);
CHARS[4510] = -19;
Arrays.fill(CHARS, 4511, 4520, (byte)33);
CHARS[4520] = -19;
Arrays.fill(CHARS, 4521, 4523, (byte)33);
CHARS[4523] = -19;
Arrays.fill(CHARS, 4524, 4526, (byte)33);
Arrays.fill(CHARS, 4526, 4528, (byte)-19);
Arrays.fill(CHARS, 4528, 4535, (byte)33);
Arrays.fill(CHARS, 4535, 4537, (byte)-19);
CHARS[4537] = 33;
CHARS[4538] = -19;
CHARS[4539] = 33;
Arrays.fill(CHARS, 4540, 4547, (byte)-19);
Arrays.fill(CHARS, 4547, 4587, (byte)33);
CHARS[4587] = -19;
Arrays.fill(CHARS, 4588, 4592, (byte)33);
CHARS[4592] = -19;
Arrays.fill(CHARS, 4593, 4601, (byte)33);
CHARS[4601] = -19;
Arrays.fill(CHARS, 4602, 7680, (byte)33);
Arrays.fill(CHARS, 7680, 7836, (byte)-19);
Arrays.fill(CHARS, 7836, 7840, (byte)33);
Arrays.fill(CHARS, 7840, 7930, (byte)-19);
Arrays.fill(CHARS, 7930, 7936, (byte)33);
Arrays.fill(CHARS, 7936, 7958, (byte)-19);
Arrays.fill(CHARS, 7958, 7960, (byte)33);
Arrays.fill(CHARS, 7960, 7966, (byte)-19);
Arrays.fill(CHARS, 7966, 7968, (byte)33);
Arrays.fill(CHARS, 7968, 8006, (byte)-19);
Arrays.fill(CHARS, 8006, 8008, (byte)33);
Arrays.fill(CHARS, 8008, 8014, (byte)-19);
Arrays.fill(CHARS, 8014, 8016, (byte)33);
Arrays.fill(CHARS, 8016, 8024, (byte)-19);
CHARS[8024] = 33;
CHARS[8025] = -19;
CHARS[8026] = 33;
CHARS[8027] = -19;
CHARS[8028] = 33;
CHARS[8029] = -19;
CHARS[8030] = 33;
Arrays.fill(CHARS, 8031, 8062, (byte)-19);
Arrays.fill(CHARS, 8062, 8064, (byte)33);
Arrays.fill(CHARS, 8064, 8117, (byte)-19);
CHARS[8117] = 33;
Arrays.fill(CHARS, 8118, 8125, (byte)-19);
CHARS[8125] = 33;
CHARS[8126] = -19;
Arrays.fill(CHARS, 8127, 8130, (byte)33);
Arrays.fill(CHARS, 8130, 8133, (byte)-19);
CHARS[8133] = 33;
Arrays.fill(CHARS, 8134, 8141, (byte)-19);
Arrays.fill(CHARS, 8141, 8144, (byte)33);
Arrays.fill(CHARS, 8144, 8148, (byte)-19);
Arrays.fill(CHARS, 8148, 8150, (byte)33);
Arrays.fill(CHARS, 8150, 8156, (byte)-19);
Arrays.fill(CHARS, 8156, 8160, (byte)33);
Arrays.fill(CHARS, 8160, 8173, (byte)-19);
Arrays.fill(CHARS, 8173, 8178, (byte)33);
Arrays.fill(CHARS, 8178, 8181, (byte)-19);
CHARS[8181] = 33;
Arrays.fill(CHARS, 8182, 8189, (byte)-19);
Arrays.fill(CHARS, 8189, 8400, (byte)33);
Arrays.fill(CHARS, 8400, 8413, (byte)-87);
Arrays.fill(CHARS, 8413, 8417, (byte)33);
CHARS[8417] = -87;
Arrays.fill(CHARS, 8418, 8486, (byte)33);
CHARS[8486] = -19;
Arrays.fill(CHARS, 8487, 8490, (byte)33);
Arrays.fill(CHARS, 8490, 8492, (byte)-19);
Arrays.fill(CHARS, 8492, 8494, (byte)33);
CHARS[8494] = -19;
Arrays.fill(CHARS, 8495, 8576, (byte)33);
Arrays.fill(CHARS, 8576, 8579, (byte)-19);
Arrays.fill(CHARS, 8579, 12293, (byte)33);
CHARS[12293] = -87;
CHARS[12294] = 33;
CHARS[12295] = -19;
Arrays.fill(CHARS, 12296, 12321, (byte)33);
Arrays.fill(CHARS, 12321, 12330, (byte)-19);
Arrays.fill(CHARS, 12330, 12336, (byte)-87);
CHARS[12336] = 33;
Arrays.fill(CHARS, 12337, 12342, (byte)-87);
Arrays.fill(CHARS, 12342, 12353, (byte)33);
Arrays.fill(CHARS, 12353, 12437, (byte)-19);
Arrays.fill(CHARS, 12437, 12441, (byte)33);
Arrays.fill(CHARS, 12441, 12443, (byte)-87);
Arrays.fill(CHARS, 12443, 12445, (byte)33);
Arrays.fill(CHARS, 12445, 12447, (byte)-87);
Arrays.fill(CHARS, 12447, 12449, (byte)33);
Arrays.fill(CHARS, 12449, 12539, (byte)-19);
CHARS[12539] = 33;
Arrays.fill(CHARS, 12540, 12543, (byte)-87);
Arrays.fill(CHARS, 12543, 12549, (byte)33);
Arrays.fill(CHARS, 12549, 12589, (byte)-19);
Arrays.fill(CHARS, 12589, 19968, (byte)33);
Arrays.fill(CHARS, 19968, 40870, (byte)-19);
Arrays.fill(CHARS, 40870, 44032, (byte)33);
Arrays.fill(CHARS, 44032, 55204, (byte)-19);
Arrays.fill(CHARS, 55204, 55296, (byte)33);
Arrays.fill(CHARS, 57344, 65534, (byte)33);
}
public static boolean isSupplemental(int c) {
return (c >= 65536 && c <= 1114111);
}
public static int supplemental(char h, char l) {
return (h - 55296) * 1024 + l - 56320 + 65536;
}
public static char highSurrogate(int c) {
return (char)((c - 65536 >> 10) + 55296);
}
public static char lowSurrogate(int c) {
return (char)((c - 65536 & 0x3FF) + 56320);
}
public static boolean isHighSurrogate(int c) {
return (55296 <= c && c <= 56319);
}
public static boolean isLowSurrogate(int c) {
return (56320 <= c && c <= 57343);
}
public static boolean isValid(int c) {
return ((c < 65536 && (CHARS[c] & 0x1) != 0) || (65536 <= c && c <= 1114111));
}
public static boolean isInvalid(int c) {
return !isValid(c);
}
public static boolean isContent(int c) {
return ((c < 65536 && (CHARS[c] & 0x20) != 0) || (65536 <= c && c <= 1114111));
}
public static boolean isMarkup(int c) {
return (c == 60 || c == 38 || c == 37);
}
public static boolean isSpace(int c) {
return (c <= 32 && (CHARS[c] & 0x2) != 0);
}
public static boolean isNameStart(int c) {
return (c < 65536 && (CHARS[c] & 0x4) != 0);
}
public static boolean isName(int c) {
return (c < 65536 && (CHARS[c] & 0x8) != 0);
}
public static boolean isNCNameStart(int c) {
return (c < 65536 && (CHARS[c] & 0x40) != 0);
}
public static boolean isNCName(int c) {
return (c < 65536 && (CHARS[c] & 0x80) != 0);
}
public static boolean isPubid(int c) {
return (c < 65536 && (CHARS[c] & 0x10) != 0);
}
public static boolean isValidName(String name) {
if (name.length() == 0)
return false;
char ch = name.charAt(0);
if (!isNameStart(ch))
return false;
for (int i = 1; i < name.length(); i++) {
ch = name.charAt(i);
if (!isName(ch))
return false;
}
return true;
}
public static boolean isValidNCName(String ncName) {
if (ncName.length() == 0)
return false;
char ch = ncName.charAt(0);
if (!isNCNameStart(ch))
return false;
for (int i = 1; i < ncName.length(); i++) {
ch = ncName.charAt(i);
if (!isNCName(ch))
return false;
}
return true;
}
public static boolean isValidNmtoken(String nmtoken) {
if (nmtoken.length() == 0)
return false;
for (int i = 0; i < nmtoken.length(); i++) {
char ch = nmtoken.charAt(i);
if (!isName(ch))
return false;
}
return true;
}
public static boolean isValidIANAEncoding(String ianaEncoding) {
if (ianaEncoding != null) {
int length = ianaEncoding.length();
if (length > 0) {
char c = ianaEncoding.charAt(0);
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
for (int i = 1; i < length; i++) {
c = ianaEncoding.charAt(i);
if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '.' && c != '_' && c != '-')
return false;
}
return true;
}
}
}
return false;
}
public static boolean isValidJavaEncoding(String javaEncoding) {
if (javaEncoding != null) {
int length = javaEncoding.length();
if (length > 0) {
for (int i = 1; i < length; i++) {
char c = javaEncoding.charAt(i);
if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '.' && c != '_' && c != '-')
return false;
}
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,94 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
public class XMLResourceIdentifierImpl implements XMLResourceIdentifier {
protected String fPublicId;
protected String fLiteralSystemId;
protected String fBaseSystemId;
protected String fExpandedSystemId;
public XMLResourceIdentifierImpl() {}
public XMLResourceIdentifierImpl(String publicId, String literalSystemId, String baseSystemId, String expandedSystemId) {
setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
}
public void setValues(String publicId, String literalSystemId, String baseSystemId, String expandedSystemId) {
this.fPublicId = publicId;
this.fLiteralSystemId = literalSystemId;
this.fBaseSystemId = baseSystemId;
this.fExpandedSystemId = expandedSystemId;
}
public void clear() {
this.fPublicId = null;
this.fLiteralSystemId = null;
this.fBaseSystemId = null;
this.fExpandedSystemId = null;
}
public void setPublicId(String publicId) {
this.fPublicId = publicId;
}
public void setLiteralSystemId(String literalSystemId) {
this.fLiteralSystemId = literalSystemId;
}
public void setBaseSystemId(String baseSystemId) {
this.fBaseSystemId = baseSystemId;
}
public void setExpandedSystemId(String expandedSystemId) {
this.fExpandedSystemId = expandedSystemId;
}
public String getPublicId() {
return this.fPublicId;
}
public String getLiteralSystemId() {
return this.fLiteralSystemId;
}
public String getBaseSystemId() {
return this.fBaseSystemId;
}
public String getExpandedSystemId() {
return this.fExpandedSystemId;
}
public int hashCode() {
int code = 0;
if (this.fPublicId != null)
code += this.fPublicId.hashCode();
if (this.fLiteralSystemId != null)
code += this.fLiteralSystemId.hashCode();
if (this.fBaseSystemId != null)
code += this.fBaseSystemId.hashCode();
if (this.fExpandedSystemId != null)
code += this.fExpandedSystemId.hashCode();
return code;
}
public String toString() {
StringBuffer str = new StringBuffer();
if (this.fPublicId != null)
str.append(this.fPublicId);
str.append(':');
if (this.fLiteralSystemId != null)
str.append(this.fLiteralSystemId);
str.append(':');
if (this.fBaseSystemId != null)
str.append(this.fBaseSystemId);
str.append(':');
if (this.fExpandedSystemId != null)
str.append(this.fExpandedSystemId);
return str.toString();
}
}

View file

@ -0,0 +1,86 @@
package com.sun.xml.stream.xerces.util;
import com.sun.xml.stream.xerces.xni.XMLString;
public class XMLStringBuffer extends XMLString {
public static final int DEFAULT_SIZE = 32;
public XMLStringBuffer() {
this(32);
}
public XMLStringBuffer(int size) {
this.ch = new char[size];
}
public XMLStringBuffer(char c) {
this(1);
append(c);
}
public XMLStringBuffer(String s) {
this(s.length());
append(s);
}
public XMLStringBuffer(char[] ch, int offset, int length) {
this(length);
append(ch, offset, length);
}
public XMLStringBuffer(XMLString s) {
this(s.length);
append(s);
}
public void clear() {
this.offset = 0;
this.length = 0;
}
public void append(char c) {
if (this.length + 1 > this.ch.length) {
int newLength = this.ch.length * 2;
if (newLength < this.ch.length + 32)
newLength = this.ch.length + 32;
char[] tmp = new char[newLength];
System.arraycopy(this.ch, 0, tmp, 0, this.length);
this.ch = tmp;
}
this.ch[this.length] = c;
this.length++;
}
public void append(String s) {
int length = s.length();
if (this.length + length > this.ch.length) {
int newLength = this.ch.length * 2;
if (newLength < this.ch.length + length + 32)
newLength = this.ch.length + length + 32;
char[] newch = new char[newLength];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
s.getChars(0, length, this.ch, this.length);
this.length += length;
}
public void append(char[] ch, int offset, int length) {
if (this.length + length > this.ch.length) {
int newLength = this.ch.length * 2;
if (newLength < this.ch.length + length + 32)
newLength = this.ch.length + length + 32;
char[] newch = new char[newLength];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
if (ch != null && length > 0) {
System.arraycopy(ch, offset, this.ch, this.length, length);
this.length += length;
}
}
public void append(XMLString s) {
append(s.ch, s.offset, s.length);
}
}

View file

@ -0,0 +1,37 @@
package com.sun.xml.stream.xerces.util;
public class XMLSymbols {
public static final String EMPTY_STRING = "".intern();
public static final String PREFIX_XML = "xml".intern();
public static final String PREFIX_XMLNS = "xmlns".intern();
public static final String fANYSymbol = "ANY".intern();
public static final String fCDATASymbol = "CDATA".intern();
public static final String fIDSymbol = "ID".intern();
public static final String fIDREFSymbol = "IDREF".intern();
public static final String fIDREFSSymbol = "IDREFS".intern();
public static final String fENTITYSymbol = "ENTITY".intern();
public static final String fENTITIESSymbol = "ENTITIES".intern();
public static final String fNMTOKENSymbol = "NMTOKEN".intern();
public static final String fNMTOKENSSymbol = "NMTOKENS".intern();
public static final String fNOTATIONSymbol = "NOTATION".intern();
public static final String fENUMERATIONSymbol = "ENUMERATION".intern();
public static final String fIMPLIEDSymbol = "#IMPLIED".intern();
public static final String fREQUIREDSymbol = "#REQUIRED".intern();
public static final String fFIXEDSymbol = "#FIXED".intern();
}

View file

@ -0,0 +1,15 @@
package com.sun.xml.stream.xerces.xni;
import java.util.Enumeration;
public interface Augmentations {
Object putItem(String paramString, Object paramObject);
Object getItem(String paramString);
Object removeItem(String paramString);
Enumeration keys();
void removeAllItems();
}

View file

@ -0,0 +1,30 @@
package com.sun.xml.stream.xerces.xni;
import java.util.Enumeration;
import java.util.Vector;
public interface NamespaceContext {
public static final String XML_URI = "http://www.w3.org/XML/1998/namespace".intern();
public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/".intern();
void pushContext();
void popContext();
boolean declarePrefix(String paramString1, String paramString2);
String getURI(String paramString);
String getPrefix(String paramString);
int getDeclaredPrefixCount();
String getDeclaredPrefixAt(int paramInt);
Enumeration getAllPrefixes();
Vector getPrefixes(String paramString);
void reset();
}

View file

@ -0,0 +1,95 @@
package com.sun.xml.stream.xerces.xni;
public class QName implements Cloneable {
public char[] characters = null;
public String prefix;
public String localpart;
public String rawname;
public String uri;
public QName() {
clear();
}
public QName(String prefix, String localpart, String rawname, String uri) {
setValues(prefix, localpart, rawname, uri);
}
public QName(QName qname) {
setValues(qname);
}
public void setValues(QName qname) {
this.prefix = qname.prefix;
this.localpart = qname.localpart;
this.rawname = qname.rawname;
this.uri = qname.uri;
this.characters = qname.characters;
}
public void setValues(String prefix, String localpart, String rawname, String uri) {
this.prefix = prefix;
this.localpart = localpart;
this.rawname = rawname;
this.uri = uri;
}
public void clear() {
this.prefix = null;
this.localpart = null;
this.rawname = null;
this.uri = null;
}
public Object clone() {
return new QName(this);
}
public int hashCode() {
if (this.uri != null)
return this.uri.hashCode() + this.localpart.hashCode();
return this.rawname.hashCode();
}
public boolean equals(Object object) {
if (object instanceof QName) {
QName qname = (QName)object;
if (qname.uri != null)
return (this.uri == qname.uri && this.localpart == qname.localpart);
if (this.uri == null)
return (this.rawname == qname.rawname);
}
return false;
}
public String toString() {
StringBuffer str = new StringBuffer();
boolean comma = false;
if (this.prefix != null) {
str.append("prefix=\"" + this.prefix + '"');
comma = true;
}
if (this.localpart != null) {
if (comma)
str.append(',');
str.append("localpart=\"" + this.localpart + '"');
comma = true;
}
if (this.rawname != null) {
if (comma)
str.append(',');
str.append("rawname=\"" + this.rawname + '"');
comma = true;
}
if (this.uri != null) {
if (comma)
str.append(',');
str.append("uri=\"" + this.uri + '"');
}
return str.toString();
}
}

View file

@ -0,0 +1,59 @@
package com.sun.xml.stream.xerces.xni;
public interface XMLAttributes {
int addAttribute(QName paramQName, String paramString1, String paramString2);
void removeAllAttributes();
void removeAttributeAt(int paramInt);
int getLength();
int getIndex(String paramString);
int getIndex(String paramString1, String paramString2);
void setName(int paramInt, QName paramQName);
void getName(int paramInt, QName paramQName);
String getPrefix(int paramInt);
String getURI(int paramInt);
String getLocalName(int paramInt);
String getQName(int paramInt);
QName getQualifiedName(int paramInt);
void setType(int paramInt, String paramString);
String getType(int paramInt);
String getType(String paramString);
String getType(String paramString1, String paramString2);
void setValue(int paramInt, String paramString);
String getValue(int paramInt);
String getValue(String paramString);
String getValue(String paramString1, String paramString2);
void setNonNormalizedValue(int paramInt, String paramString);
String getNonNormalizedValue(int paramInt);
void setSpecified(int paramInt, boolean paramBoolean);
boolean isSpecified(int paramInt);
Augmentations getAugmentations(int paramInt);
Augmentations getAugmentations(String paramString1, String paramString2);
Augmentations getAugmentations(String paramString);
}

View file

@ -0,0 +1,33 @@
package com.sun.xml.stream.xerces.xni;
public interface XMLDTDContentModelHandler {
public static final short SEPARATOR_CHOICE = 0;
public static final short SEPARATOR_SEQUENCE = 1;
public static final short OCCURS_ZERO_OR_ONE = 2;
public static final short OCCURS_ZERO_OR_MORE = 3;
public static final short OCCURS_ONE_OR_MORE = 4;
void startContentModel(String paramString, Augmentations paramAugmentations) throws XNIException;
void any(Augmentations paramAugmentations) throws XNIException;
void empty(Augmentations paramAugmentations) throws XNIException;
void startGroup(Augmentations paramAugmentations) throws XNIException;
void pcdata(Augmentations paramAugmentations) throws XNIException;
void element(String paramString, Augmentations paramAugmentations) throws XNIException;
void separator(short paramShort, Augmentations paramAugmentations) throws XNIException;
void occurrence(short paramShort, Augmentations paramAugmentations) throws XNIException;
void endGroup(Augmentations paramAugmentations) throws XNIException;
void endContentModel(Augmentations paramAugmentations) throws XNIException;
}

View file

@ -0,0 +1,47 @@
package com.sun.xml.stream.xerces.xni;
public interface XMLDTDHandler {
public static final short CONDITIONAL_INCLUDE = 0;
public static final short CONDITIONAL_IGNORE = 1;
void startDTD(XMLLocator paramXMLLocator, Augmentations paramAugmentations) throws XNIException;
void startParameterEntity(String paramString1, XMLResourceIdentifier paramXMLResourceIdentifier, String paramString2, Augmentations paramAugmentations) throws XNIException;
void textDecl(String paramString1, String paramString2, Augmentations paramAugmentations) throws XNIException;
void endParameterEntity(String paramString, Augmentations paramAugmentations) throws XNIException;
void startExternalSubset(XMLResourceIdentifier paramXMLResourceIdentifier, Augmentations paramAugmentations) throws XNIException;
void endExternalSubset(Augmentations paramAugmentations) throws XNIException;
void comment(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void processingInstruction(String paramString, XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void elementDecl(String paramString1, String paramString2, Augmentations paramAugmentations) throws XNIException;
void startAttlist(String paramString, Augmentations paramAugmentations) throws XNIException;
void attributeDecl(String paramString1, String paramString2, String paramString3, String[] paramArrayOfString, String paramString4, XMLString paramXMLString1, XMLString paramXMLString2, Augmentations paramAugmentations) throws XNIException;
void endAttlist(Augmentations paramAugmentations) throws XNIException;
void internalEntityDecl(String paramString, XMLString paramXMLString1, XMLString paramXMLString2, Augmentations paramAugmentations) throws XNIException;
void externalEntityDecl(String paramString, XMLResourceIdentifier paramXMLResourceIdentifier, Augmentations paramAugmentations) throws XNIException;
void unparsedEntityDecl(String paramString1, XMLResourceIdentifier paramXMLResourceIdentifier, String paramString2, Augmentations paramAugmentations) throws XNIException;
void notationDecl(String paramString, XMLResourceIdentifier paramXMLResourceIdentifier, Augmentations paramAugmentations) throws XNIException;
void startConditional(short paramShort, Augmentations paramAugmentations) throws XNIException;
void ignoredCharacters(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void endConditional(Augmentations paramAugmentations) throws XNIException;
void endDTD(Augmentations paramAugmentations) throws XNIException;
}

View file

@ -0,0 +1,35 @@
package com.sun.xml.stream.xerces.xni;
public interface XMLDocumentFragmentHandler {
void startDocumentFragment(XMLLocator paramXMLLocator, NamespaceContext paramNamespaceContext, Augmentations paramAugmentations) throws XNIException;
void startGeneralEntity(String paramString1, XMLResourceIdentifier paramXMLResourceIdentifier, String paramString2, Augmentations paramAugmentations) throws XNIException;
void textDecl(String paramString1, String paramString2, Augmentations paramAugmentations) throws XNIException;
void endGeneralEntity(String paramString, Augmentations paramAugmentations) throws XNIException;
void comment(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void processingInstruction(String paramString, XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void startPrefixMapping(String paramString1, String paramString2, Augmentations paramAugmentations) throws XNIException;
void startElement(QName paramQName, XMLAttributes paramXMLAttributes, Augmentations paramAugmentations) throws XNIException;
void emptyElement(QName paramQName, XMLAttributes paramXMLAttributes, Augmentations paramAugmentations) throws XNIException;
void characters(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void ignorableWhitespace(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void endElement(QName paramQName, Augmentations paramAugmentations) throws XNIException;
void endPrefixMapping(String paramString, Augmentations paramAugmentations) throws XNIException;
void startCDATA(Augmentations paramAugmentations) throws XNIException;
void endCDATA(Augmentations paramAugmentations) throws XNIException;
void endDocumentFragment(Augmentations paramAugmentations) throws XNIException;
}

Some files were not shown because too many files have changed in this diff Show more