first commit

This commit is contained in:
2025-07-28 13:56:49 +05:30
commit e9eb805edb
3438 changed files with 520990 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package org.apache.xerces.impl.xs.psvi;
import org.apache.xerces.xni.psvi.AttributePSVI;
import org.apache.xerces.xni.psvi.ElementPSVI;
public interface PSVIProvider {
AttributePSVI getAttributePSVI(int paramInt);
ElementPSVI getElementPSVI();
AttributePSVI getAttributePSVIByName(String paramString1, String paramString2);
}

View File

@@ -0,0 +1,7 @@
package org.apache.xerces.impl.xs.psvi;
public interface StringList {
int getLength();
String item(int paramInt);
}

View File

@@ -0,0 +1,13 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSAnnotation extends XSObject {
public static final short W3C_DOM_ELEMENT = 1;
public static final short SAX_CONTENTHANDLER = 2;
public static final short W3C_DOM_DOCUMENT = 3;
boolean writeAnnotation(Object paramObject, short paramShort);
String getAnnotationString();
}

View File

@@ -0,0 +1,15 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSAttributeDeclaration extends XSObject {
short getConstraintType();
short getScope();
String getConstraintValue();
XSAnnotation getAnnotation();
XSComplexTypeDefinition getEnclosingCTDefinition();
XSSimpleTypeDefinition getTypeDefinition();
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSAttributeGroupDefinition extends XSObject {
XSAnnotation getAnnotation();
XSObjectList getAttributeUses();
XSWildcard getAttributeWildcard();
}

View File

@@ -0,0 +1,31 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSComplexTypeDefinition extends XSTypeDefinition {
public static final short CONTENTTYPE_EMPTY = 0;
public static final short CONTENTTYPE_SIMPLE = 1;
public static final short CONTENTTYPE_ELEMENT = 2;
public static final short CONTENTTYPE_MIXED = 3;
short getContentType();
short getDerivationMethod();
short getProhibitedSubstitutions();
boolean getAbstract();
boolean isProhibitedSubstitution(short paramShort);
XSObjectList getAnnotations();
XSObjectList getAttributeUses();
XSParticle getParticle();
XSSimpleTypeDefinition getSimpleType();
XSWildcard getAttributeWildcard();
}

View File

@@ -0,0 +1,31 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSElementDeclaration extends XSTerm {
short getConstraintType();
short getDisallowedSubstitutions();
short getScope();
short getSubstitutionGroupExclusions();
boolean getAbstract();
boolean getNillable();
boolean isDisallowedSubstitution(short paramShort);
boolean isSubstitutionGroupExclusion(short paramShort);
String getConstraintValue();
XSAnnotation getAnnotation();
XSComplexTypeDefinition getEnclosingCTDefinition();
XSElementDeclaration getSubstitutionGroupAffiliation();
XSNamedMap getIdentityConstraints();
XSTypeDefinition getTypeDefinition();
}

View File

@@ -0,0 +1,25 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSModel {
StringList getNamespaces();
XSNamedMap getComponents(short paramShort);
XSNamespaceItemList getNamespaceItems();
XSObjectList getAnnotations();
XSNamedMap getComponentsByNamespace(short paramShort, String paramString);
XSAttributeDeclaration getAttributeDeclaration(String paramString1, String paramString2);
XSAttributeGroupDefinition getAttributeGroup(String paramString1, String paramString2);
XSElementDeclaration getElementDeclaration(String paramString1, String paramString2);
XSModelGroupDefinition getModelGroupDefinition(String paramString1, String paramString2);
XSNotationDeclaration getNotationDeclaration(String paramString1, String paramString2);
XSTypeDefinition getTypeDefinition(String paramString1, String paramString2);
}

View File

@@ -0,0 +1,15 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSModelGroup extends XSTerm {
public static final short COMPOSITOR_SEQUENCE = 1;
public static final short COMPOSITOR_CHOICE = 2;
public static final short COMPOSITOR_ALL = 3;
short getCompositor();
XSAnnotation getAnnotation();
XSObjectList getParticles();
}

View File

@@ -0,0 +1,7 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSModelGroupDefinition extends XSObject {
XSAnnotation getAnnotation();
XSModelGroup getModelGroup();
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSNamedMap {
int getLength();
XSObject item(int paramInt);
XSObject itemByName(String paramString1, String paramString2);
}

View File

@@ -0,0 +1,23 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSNamespaceItem {
String getSchemaNamespace();
StringList getDocumentLocations();
XSNamedMap getComponents(short paramShort);
XSObjectList getAnnotations();
XSAttributeDeclaration getAttributeDeclaration(String paramString);
XSAttributeGroupDefinition getAttributeGroup(String paramString);
XSElementDeclaration getElementDeclaration(String paramString);
XSModelGroupDefinition getModelGroupDefinition(String paramString);
XSNotationDeclaration getNotationDeclaration(String paramString);
XSTypeDefinition getTypeDefinition(String paramString);
}

View File

@@ -0,0 +1,7 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSNamespaceItemList {
int getLength();
XSNamespaceItem item(int paramInt);
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSNotationDeclaration extends XSObject {
String getPublicId();
String getSystemId();
XSAnnotation getAnnotation();
}

View File

@@ -0,0 +1,11 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSObject {
short getType();
String getName();
String getNamespace();
XSNamespaceItem getNamespaceItem();
}

View File

@@ -0,0 +1,7 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSObjectList {
int getLength();
XSObject item(int paramInt);
}

View File

@@ -0,0 +1,11 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSParticle extends XSObject {
int getMaxOccurs();
int getMinOccurs();
boolean getMaxOccursUnbounded();
XSTerm getTerm();
}

View File

@@ -0,0 +1,75 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSSimpleTypeDefinition extends XSTypeDefinition {
public static final short VARIETY_ABSENT = 0;
public static final short VARIETY_ATOMIC = 1;
public static final short VARIETY_LIST = 2;
public static final short VARIETY_UNION = 3;
public static final short FACET_NONE = 0;
public static final short FACET_LENGTH = 1;
public static final short FACET_MINLENGTH = 2;
public static final short FACET_MAXLENGTH = 4;
public static final short FACET_PATTERN = 8;
public static final short FACET_WHITESPACE = 16;
public static final short FACET_MAXINCLUSIVE = 32;
public static final short FACET_MAXEXCLUSIVE = 64;
public static final short FACET_MINEXCLUSIVE = 128;
public static final short FACET_MININCLUSIVE = 256;
public static final short FACET_TOTALDIGITS = 512;
public static final short FACET_FRACTIONDIGITS = 1024;
public static final short FACET_ENUMERATION = 2048;
public static final short ORDERED_FALSE = 0;
public static final short ORDERED_PARTIAL = 1;
public static final short ORDERED_TOTAL = 2;
short getDefinedFacets();
short getFixedFacets();
short getOrdered();
short getVariety();
boolean getBounded();
boolean getFinite();
boolean getNumeric();
boolean isDefinedFacet(short paramShort);
boolean isFixedFacet(short paramShort);
String getLexicalFacetValue(short paramShort);
StringList getLexicalEnumeration();
StringList getLexicalPattern();
XSAnnotation getAnnotation();
XSObjectList getMemberTypes();
XSSimpleTypeDefinition getItemType();
XSSimpleTypeDefinition getPrimitiveType();
}

View File

@@ -0,0 +1,3 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSTerm extends XSObject {}

View File

@@ -0,0 +1,21 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSTypeDefinition extends XSObject {
public static final short COMPLEX_TYPE = 13;
public static final short SIMPLE_TYPE = 14;
short getFinal();
short getTypeCategory();
boolean getAnonymous();
boolean isFinal(short paramShort);
XSTypeDefinition getBaseType();
boolean derivedFromType(XSTypeDefinition paramXSTypeDefinition, short paramShort);
boolean derivedFrom(String paramString1, String paramString2, short paramShort);
}

View File

@@ -0,0 +1,23 @@
package org.apache.xerces.impl.xs.psvi;
public interface XSWildcard extends XSTerm {
public static final short NSCONSTRAINT_ANY = 1;
public static final short NSCONSTRAINT_NOT = 2;
public static final short NSCONSTRAINT_LIST = 3;
public static final short PC_STRICT = 1;
public static final short PC_SKIP = 2;
public static final short PC_LAX = 3;
short getConstraintType();
short getProcessContents();
StringList getNsConstraintList();
XSAnnotation getAnnotation();
}

View File

@@ -0,0 +1,752 @@
package org.apache.xerces.parsers;
import java.io.IOException;
import java.util.Locale;
import org.apache.xerces.impl.xs.psvi.PSVIProvider;
import org.apache.xerces.util.EntityResolverWrapper;
import org.apache.xerces.util.ErrorHandlerWrapper;
import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.NamespaceContext;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLLocator;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLConfigurationException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xni.parser.XMLParseException;
import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.apache.xerces.xni.psvi.AttributePSVI;
import org.apache.xerces.xni.psvi.ElementPSVI;
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.DocumentHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.LocatorImpl;
public abstract class AbstractSAXParser extends AbstractXMLDocumentParser implements PSVIProvider, Parser, XMLReader {
protected static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
protected static final String NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
protected static final String STRING_INTERNING = "http://xml.org/sax/features/string-interning";
private static final String[] RECOGNIZED_FEATURES = new String[] { "http://xml.org/sax/features/namespaces", "http://xml.org/sax/features/namespace-prefixes", "http://xml.org/sax/features/string-interning" };
protected static final String LEXICAL_HANDLER = "http://xml.org/sax/properties/lexical-handler";
protected static final String DECLARATION_HANDLER = "http://xml.org/sax/properties/declaration-handler";
protected static final String DOM_NODE = "http://xml.org/sax/properties/dom-node";
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://xml.org/sax/properties/lexical-handler", "http://xml.org/sax/properties/declaration-handler", "http://xml.org/sax/properties/dom-node" };
protected boolean fNamespaces;
protected boolean fNamespacePrefixes = false;
protected ContentHandler fContentHandler;
protected DocumentHandler fDocumentHandler;
protected NamespaceContext fNamespaceContext;
protected DTDHandler fDTDHandler;
protected DeclHandler fDeclHandler;
protected LexicalHandler fLexicalHandler;
protected QName fQName = new QName();
protected boolean fParseInProgress = false;
private final AttributesProxy fAttributesProxy = new AttributesProxy();
private Augmentations fAugmentations = null;
private static final int BUFFER_SIZE = 20;
private char[] fCharBuffer = new char[20];
protected SymbolHash fDeclaredAttrs = null;
protected AbstractSAXParser(XMLParserConfiguration config) {
super(config);
config.addRecognizedFeatures(RECOGNIZED_FEATURES);
config.addRecognizedProperties(RECOGNIZED_PROPERTIES);
}
public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
this.fNamespaceContext = namespaceContext;
try {
if (this.fDocumentHandler != null) {
if (locator != null)
this.fDocumentHandler.setDocumentLocator(new LocatorProxy(locator));
this.fDocumentHandler.startDocument();
}
if (this.fContentHandler != null) {
if (locator != null)
this.fContentHandler.setDocumentLocator(new LocatorProxy(locator));
this.fContentHandler.startDocument();
}
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException {
this.fInDTD = true;
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.startDTD(rootElement, publicId, systemId);
} catch (SAXException e) {
throw new XNIException(e);
}
if (this.fDeclHandler != null)
this.fDeclaredAttrs = new SymbolHash();
}
public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {
startParameterEntity(name, identifier, encoding, augs);
}
public void endGeneralEntity(String name, Augmentations augs) throws XNIException {
endParameterEntity(name, augs);
}
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
try {
if (this.fDocumentHandler != null) {
this.fAttributesProxy.setAttributes(attributes);
this.fDocumentHandler.startElement(element.rawname, this.fAttributesProxy);
}
if (this.fContentHandler != null) {
startNamespaceMapping();
this.fAugmentations = augs;
int len = attributes.getLength();
for (int i = len - 1; i >= 0; i--) {
attributes.getName(i, this.fQName);
if ((this.fQName.prefix != null && this.fQName.prefix.equals("xmlns")) || this.fQName.rawname.equals("xmlns")) {
if (!this.fNamespacePrefixes)
attributes.removeAttributeAt(i);
if (this.fNamespaces && this.fNamespacePrefixes) {
this.fQName.prefix = "";
this.fQName.uri = "";
this.fQName.localpart = "";
attributes.setName(i, this.fQName);
}
}
}
String uri = (element.uri != null) ? element.uri : "";
String localpart = this.fNamespaces ? element.localpart : "";
this.fAttributesProxy.setAttributes(attributes);
this.fContentHandler.startElement(uri, localpart, element.rawname, this.fAttributesProxy);
}
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void characters(XMLString text, Augmentations augs) throws XNIException {
if (text.length == 0)
return;
try {
if (this.fDocumentHandler != null)
this.fDocumentHandler.characters(text.ch, text.offset, text.length);
if (this.fContentHandler != null)
this.fContentHandler.characters(text.ch, text.offset, text.length);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
try {
if (this.fDocumentHandler != null)
this.fDocumentHandler.ignorableWhitespace(text.ch, text.offset, text.length);
if (this.fContentHandler != null)
this.fContentHandler.ignorableWhitespace(text.ch, text.offset, text.length);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void endElement(QName element, Augmentations augs) throws XNIException {
try {
if (this.fDocumentHandler != null)
this.fDocumentHandler.endElement(element.rawname);
if (this.fContentHandler != null) {
this.fAugmentations = augs;
String uri = (element.uri != null) ? element.uri : "";
String localpart = this.fNamespaces ? element.localpart : "";
this.fContentHandler.endElement(uri, localpart, element.rawname);
endNamespaceMapping();
}
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void startCDATA(Augmentations augs) throws XNIException {
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.startCDATA();
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void endCDATA(Augmentations augs) throws XNIException {
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.endCDATA();
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void comment(XMLString text, Augmentations augs) throws XNIException {
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.comment(text.ch, 0, text.length);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {
try {
if (this.fDocumentHandler != null)
this.fDocumentHandler.processingInstruction(target, data.toString());
if (this.fContentHandler != null)
this.fContentHandler.processingInstruction(target, data.toString());
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void endDocument(Augmentations augs) throws XNIException {
try {
if (this.fDocumentHandler != null)
this.fDocumentHandler.endDocument();
if (this.fContentHandler != null)
this.fContentHandler.endDocument();
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void startExternalSubset(XMLResourceIdentifier identifier, Augmentations augs) throws XNIException {
startParameterEntity("[dtd]", (XMLResourceIdentifier)null, (String)null, augs);
}
public void endExternalSubset(Augmentations augs) throws XNIException {
endParameterEntity("[dtd]", augs);
}
public void startParameterEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.startEntity(name);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void endParameterEntity(String name, Augmentations augs) throws XNIException {
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.endEntity(name);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void elementDecl(String name, String contentModel, Augmentations augs) throws XNIException {
try {
if (this.fDeclHandler != null)
this.fDeclHandler.elementDecl(name, contentModel);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {
try {
if (this.fDeclHandler != null) {
String elemAttr = elementName + "<" + attributeName;
if (this.fDeclaredAttrs.get(elemAttr) != null)
return;
this.fDeclaredAttrs.put(elemAttr, Boolean.TRUE);
if (type.equals("NOTATION") || type.equals("ENUMERATION")) {
StringBuffer str = new StringBuffer();
if (type.equals("NOTATION")) {
str.append(type);
str.append(" (");
} else {
str.append("(");
}
for (int i = 0; i < enumeration.length; i++) {
str.append(enumeration[i]);
if (i < enumeration.length - 1)
str.append('|');
}
str.append(')');
type = str.toString();
}
String value = (defaultValue == null) ? null : defaultValue.toString();
this.fDeclHandler.attributeDecl(elementName, attributeName, type, defaultType, value);
}
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void internalEntityDecl(String name, XMLString text, XMLString nonNormalizedText, Augmentations augs) throws XNIException {
try {
if (this.fDeclHandler != null)
this.fDeclHandler.internalEntityDecl(name, text.toString());
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException {
String publicId = identifier.getPublicId();
String literalSystemId = identifier.getLiteralSystemId();
try {
if (this.fDeclHandler != null)
this.fDeclHandler.externalEntityDecl(name, publicId, literalSystemId);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augs) throws XNIException {
String publicId = identifier.getPublicId();
String expandedSystemId = identifier.getExpandedSystemId();
try {
if (this.fDTDHandler != null)
this.fDTDHandler.unparsedEntityDecl(name, publicId, expandedSystemId, notation);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException {
String publicId = identifier.getPublicId();
String expandedSystemId = identifier.getExpandedSystemId();
try {
if (this.fDTDHandler != null)
this.fDTDHandler.notationDecl(name, publicId, expandedSystemId);
} catch (SAXException e) {
throw new XNIException(e);
}
}
public void endDTD(Augmentations augs) throws XNIException {
this.fInDTD = false;
try {
if (this.fLexicalHandler != null)
this.fLexicalHandler.endDTD();
} catch (SAXException e) {
throw new XNIException(e);
}
if (this.fDeclaredAttrs != null)
this.fDeclaredAttrs.clear();
}
public void parse(String systemId) throws SAXException, IOException {
XMLInputSource source = new XMLInputSource(null, systemId, null);
try {
parse(source);
} catch (XMLParseException e) {
Exception ex = e.getException();
if (ex == null) {
LocatorImpl locatorImpl = new LocatorImpl();
locatorImpl.setPublicId(e.getPublicId());
locatorImpl.setSystemId(e.getExpandedSystemId());
locatorImpl.setLineNumber(e.getLineNumber());
locatorImpl.setColumnNumber(e.getColumnNumber());
throw new SAXParseException(e.getMessage(), locatorImpl);
}
if (ex instanceof SAXException)
throw (SAXException)ex;
if (ex instanceof IOException)
throw (IOException)ex;
throw new SAXException(ex);
} catch (XNIException e) {
Exception ex = e.getException();
if (ex == null)
throw new SAXException(e.getMessage());
if (ex instanceof SAXException)
throw (SAXException)ex;
if (ex instanceof IOException)
throw (IOException)ex;
throw new SAXException(ex);
}
}
public void parse(InputSource inputSource) throws SAXException, IOException {
try {
XMLInputSource xmlInputSource = new XMLInputSource(inputSource.getPublicId(), inputSource.getSystemId(), null);
xmlInputSource.setByteStream(inputSource.getByteStream());
xmlInputSource.setCharacterStream(inputSource.getCharacterStream());
xmlInputSource.setEncoding(inputSource.getEncoding());
parse(xmlInputSource);
} catch (XMLParseException e) {
Exception ex = e.getException();
if (ex == null) {
LocatorImpl locatorImpl = new LocatorImpl();
locatorImpl.setPublicId(e.getPublicId());
locatorImpl.setSystemId(e.getExpandedSystemId());
locatorImpl.setLineNumber(e.getLineNumber());
locatorImpl.setColumnNumber(e.getColumnNumber());
throw new SAXParseException(e.getMessage(), locatorImpl);
}
if (ex instanceof SAXException)
throw (SAXException)ex;
if (ex instanceof IOException)
throw (IOException)ex;
throw new SAXException(ex);
} catch (XNIException e) {
Exception ex = e.getException();
if (ex == null)
throw new SAXException(e.getMessage());
if (ex instanceof SAXException)
throw (SAXException)ex;
if (ex instanceof IOException)
throw (IOException)ex;
throw new SAXException(ex);
}
}
public void setEntityResolver(EntityResolver resolver) {
if (resolver == null)
throw new NullPointerException();
try {
this.fConfiguration.setProperty("http://apache.org/xml/properties/internal/entity-resolver", new EntityResolverWrapper(resolver));
} catch (XMLConfigurationException e) {}
}
public EntityResolver getEntityResolver() {
EntityResolver entityResolver = null;
try {
XMLEntityResolver xmlEntityResolver = (XMLEntityResolver)this.fConfiguration.getProperty("http://apache.org/xml/properties/internal/entity-resolver");
if (xmlEntityResolver != null && xmlEntityResolver instanceof EntityResolverWrapper)
entityResolver = ((EntityResolverWrapper)xmlEntityResolver).getEntityResolver();
} catch (XMLConfigurationException e) {}
return entityResolver;
}
public void setErrorHandler(ErrorHandler errorHandler) {
if (errorHandler == null)
throw new NullPointerException();
try {
this.fConfiguration.setProperty("http://apache.org/xml/properties/internal/error-handler", new ErrorHandlerWrapper(errorHandler));
} catch (XMLConfigurationException e) {}
}
public ErrorHandler getErrorHandler() {
ErrorHandler errorHandler = null;
try {
XMLErrorHandler xmlErrorHandler = (XMLErrorHandler)this.fConfiguration.getProperty("http://apache.org/xml/properties/internal/error-handler");
if (xmlErrorHandler != null && xmlErrorHandler instanceof ErrorHandlerWrapper)
errorHandler = ((ErrorHandlerWrapper)xmlErrorHandler).getErrorHandler();
} catch (XMLConfigurationException e) {}
return errorHandler;
}
public void setLocale(Locale locale) throws SAXException {
this.fConfiguration.setLocale(locale);
}
public void setDTDHandler(DTDHandler dtdHandler) {
if (dtdHandler == null)
throw new NullPointerException();
this.fDTDHandler = dtdHandler;
}
public void setDocumentHandler(DocumentHandler documentHandler) {
this.fDocumentHandler = documentHandler;
}
public void setContentHandler(ContentHandler contentHandler) {
if (contentHandler == null)
throw new NullPointerException();
this.fContentHandler = contentHandler;
}
public ContentHandler getContentHandler() {
return this.fContentHandler;
}
public DTDHandler getDTDHandler() {
return this.fDTDHandler;
}
public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException {
try {
if (featureId.startsWith("http://xml.org/sax/features/")) {
String feature = featureId.substring("http://xml.org/sax/features/".length());
if (feature.equals("namespaces")) {
this.fConfiguration.setFeature(featureId, state);
this.fNamespaces = state;
return;
}
if (feature.equals("namespace-prefixes")) {
this.fConfiguration.setFeature(featureId, state);
this.fNamespacePrefixes = state;
return;
}
if (feature.equals("string-interning")) {
if (!state)
throw new SAXNotSupportedException("PAR018 " + state + " state for feature \"" + featureId + "\" is not supported.\n" + state + '\t' + featureId);
return;
}
}
this.fConfiguration.setFeature(featureId, state);
} catch (XMLConfigurationException e) {
String message = e.getMessage();
if (e.getType() == 0)
throw new SAXNotRecognizedException(message);
throw new SAXNotSupportedException(message);
}
}
public boolean getFeature(String featureId) throws SAXNotRecognizedException, SAXNotSupportedException {
try {
if (featureId.startsWith("http://xml.org/sax/features/")) {
String feature = featureId.substring("http://xml.org/sax/features/".length());
if (feature.equals("namespace-prefixes")) {
boolean state = this.fConfiguration.getFeature(featureId);
return state;
}
if (feature.equals("string-interning"))
return true;
}
return this.fConfiguration.getFeature(featureId);
} catch (XMLConfigurationException e) {
String message = e.getMessage();
if (e.getType() == 0)
throw new SAXNotRecognizedException(message);
throw new SAXNotSupportedException(message);
}
}
public void setProperty(String propertyId, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
try {
if (propertyId.startsWith("http://xml.org/sax/properties/")) {
String property = propertyId.substring("http://xml.org/sax/properties/".length());
if (property.equals("lexical-handler")) {
try {
setLexicalHandler((LexicalHandler)value);
} catch (ClassCastException e) {
throw new SAXNotSupportedException("PAR012 For propertyID \"" + propertyId + "\", the value \"" + value + "\" cannot be cast to LexicalHandler." + '\n' + propertyId + '\t' + value + "\tLexicalHandler");
}
return;
}
if (property.equals("declaration-handler")) {
try {
setDeclHandler((DeclHandler)value);
} catch (ClassCastException e) {
throw new SAXNotSupportedException("PAR012 For propertyID \"" + propertyId + "\", the value \"" + value + "\" cannot be cast to DeclHandler." + '\n' + propertyId + '\t' + value + "\tDeclHandler");
}
return;
}
if (property.equals("dom-node"))
throw new SAXNotSupportedException("PAR013 Property \"" + propertyId + "\" is read only." + '\n' + propertyId);
}
this.fConfiguration.setProperty(propertyId, value);
} catch (XMLConfigurationException e) {
String message = e.getMessage();
if (e.getType() == 0)
throw new SAXNotRecognizedException(message);
throw new SAXNotSupportedException(message);
}
}
public Object getProperty(String propertyId) throws SAXNotRecognizedException, SAXNotSupportedException {
try {
if (propertyId.startsWith("http://xml.org/sax/properties/")) {
String property = propertyId.substring("http://xml.org/sax/properties/".length());
if (property.equals("lexical-handler"))
return getLexicalHandler();
if (property.equals("declaration-handler"))
return getDeclHandler();
if (property.equals("dom-node"))
throw new SAXNotSupportedException("PAR014 Cannot getProperty(\"" + propertyId + "\". No DOM Tree exists.\n" + propertyId);
}
return this.fConfiguration.getProperty(propertyId);
} catch (XMLConfigurationException e) {
String message = e.getMessage();
if (e.getType() == 0)
throw new SAXNotRecognizedException(message);
throw new SAXNotSupportedException(message);
}
}
protected void setDeclHandler(DeclHandler handler) throws SAXNotRecognizedException, SAXNotSupportedException {
if (this.fParseInProgress)
throw new SAXNotSupportedException("PAR011 Feature: http://xml.org/sax/properties/declaration-handler is not supported during parse.\nhttp://xml.org/sax/properties/declaration-handler");
this.fDeclHandler = handler;
}
protected DeclHandler getDeclHandler() throws SAXNotRecognizedException, SAXNotSupportedException {
return this.fDeclHandler;
}
protected void setLexicalHandler(LexicalHandler handler) throws SAXNotRecognizedException, SAXNotSupportedException {
if (this.fParseInProgress)
throw new SAXNotSupportedException("PAR011 Feature: http://xml.org/sax/properties/lexical-handler is not supported during parse.\nhttp://xml.org/sax/properties/lexical-handler");
this.fLexicalHandler = handler;
}
protected LexicalHandler getLexicalHandler() throws SAXNotRecognizedException, SAXNotSupportedException {
return this.fLexicalHandler;
}
protected final void startNamespaceMapping() throws SAXException {
int count = this.fNamespaceContext.getDeclaredPrefixCount();
if (count > 0) {
String prefix = null;
String uri = null;
for (int i = 0; i < count; i++) {
prefix = this.fNamespaceContext.getDeclaredPrefixAt(i);
uri = this.fNamespaceContext.getURI(prefix);
this.fContentHandler.startPrefixMapping(prefix, (uri == null) ? "" : uri);
}
}
}
protected final void endNamespaceMapping() throws SAXException {
int count = this.fNamespaceContext.getDeclaredPrefixCount();
if (count > 0)
for (int i = 0; i < count; i++)
this.fContentHandler.endPrefixMapping(this.fNamespaceContext.getDeclaredPrefixAt(i));
}
public void reset() throws XNIException {
super.reset();
this.fInDTD = false;
this.fNamespaces = this.fConfiguration.getFeature("http://xml.org/sax/features/namespaces");
this.fNamespacePrefixes = this.fConfiguration.getFeature("http://xml.org/sax/features/namespace-prefixes");
this.fAugmentations = null;
this.fDeclaredAttrs = null;
}
protected static class LocatorProxy implements Locator {
protected XMLLocator fLocator;
public LocatorProxy(XMLLocator locator) {
this.fLocator = locator;
}
public String getPublicId() {
return this.fLocator.getPublicId();
}
public String getSystemId() {
return this.fLocator.getExpandedSystemId();
}
public int getLineNumber() {
return this.fLocator.getLineNumber();
}
public int getColumnNumber() {
return this.fLocator.getColumnNumber();
}
}
protected static final class AttributesProxy implements AttributeList, Attributes {
protected XMLAttributes fAttributes;
public void setAttributes(XMLAttributes attributes) {
this.fAttributes = attributes;
}
public int getLength() {
return this.fAttributes.getLength();
}
public String getName(int i) {
return this.fAttributes.getQName(i);
}
public String getQName(int index) {
return this.fAttributes.getQName(index);
}
public String getURI(int index) {
String uri = this.fAttributes.getURI(index);
return (uri != null) ? uri : "";
}
public String getLocalName(int index) {
return this.fAttributes.getLocalName(index);
}
public String getType(int i) {
return this.fAttributes.getType(i);
}
public String getType(String name) {
return this.fAttributes.getType(name);
}
public String getType(String uri, String localName) {
return uri.equals("") ? this.fAttributes.getType(null, localName) : this.fAttributes.getType(uri, localName);
}
public String getValue(int i) {
return this.fAttributes.getValue(i);
}
public String getValue(String name) {
return this.fAttributes.getValue(name);
}
public String getValue(String uri, String localName) {
return uri.equals("") ? this.fAttributes.getValue(null, localName) : this.fAttributes.getValue(uri, localName);
}
public int getIndex(String qName) {
return this.fAttributes.getIndex(qName);
}
public int getIndex(String uri, String localPart) {
return uri.equals("") ? this.fAttributes.getIndex(null, localPart) : this.fAttributes.getIndex(uri, localPart);
}
}
public ElementPSVI getElementPSVI() {
return (this.fAugmentations != null) ? (ElementPSVI)this.fAugmentations.getItem("ELEMENT_PSVI") : null;
}
public AttributePSVI getAttributePSVI(int index) {
return (AttributePSVI)this.fAttributesProxy.fAttributes.getAugmentations(index).getItem("ATTRIBUTE_PSVI");
}
public AttributePSVI getAttributePSVIByName(String uri, String localname) {
return (AttributePSVI)this.fAttributesProxy.fAttributes.getAugmentations(uri, localname).getItem("ATTRIBUTE_PSVI");
}
}

View File

@@ -0,0 +1,156 @@
package org.apache.xerces.parsers;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.NamespaceContext;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLLocator;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLDTDContentModelSource;
import org.apache.xerces.xni.parser.XMLDTDSource;
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.apache.xerces.xni.parser.XMLParserConfiguration;
public abstract class AbstractXMLDocumentParser extends XMLParser implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
protected boolean fInDTD;
protected XMLDocumentSource fDocumentSource;
protected XMLDTDSource fDTDSource;
protected XMLDTDContentModelSource fDTDContentModelSource;
protected AbstractXMLDocumentParser(XMLParserConfiguration config) {
super(config);
config.setDocumentHandler(this);
config.setDTDHandler(this);
config.setDTDContentModelHandler(this);
}
public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {}
public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {}
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException {}
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {}
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
startElement(element, attributes, augs);
endElement(element, augs);
}
public void characters(XMLString text, Augmentations augs) throws XNIException {}
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {}
public void endElement(QName element, Augmentations augs) throws XNIException {}
public void startCDATA(Augmentations augs) throws XNIException {}
public void endCDATA(Augmentations augs) throws XNIException {}
public void endDocument(Augmentations augs) throws XNIException {}
public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {}
public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {}
public void endGeneralEntity(String name, Augmentations augs) throws XNIException {}
public void comment(XMLString text, Augmentations augs) throws XNIException {}
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {}
public void setDocumentSource(XMLDocumentSource source) {
this.fDocumentSource = source;
}
public XMLDocumentSource getDocumentSource() {
return this.fDocumentSource;
}
public void startDTD(XMLLocator locator, Augmentations augs) throws XNIException {
this.fInDTD = true;
}
public void startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {}
public void endExternalSubset(Augmentations augmentations) throws XNIException {}
public void startParameterEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {}
public void endParameterEntity(String name, Augmentations augs) throws XNIException {}
public void ignoredCharacters(XMLString text, Augmentations augs) throws XNIException {}
public void elementDecl(String name, String contentModel, Augmentations augs) throws XNIException {}
public void startAttlist(String elementName, Augmentations augs) throws XNIException {}
public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {}
public void endAttlist(Augmentations augs) throws XNIException {}
public void internalEntityDecl(String name, XMLString text, XMLString nonNormalizedText, Augmentations augs) throws XNIException {}
public void externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException {}
public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augs) throws XNIException {}
public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException {}
public void startConditional(short type, Augmentations augs) throws XNIException {}
public void endConditional(Augmentations augs) throws XNIException {}
public void endDTD(Augmentations augs) throws XNIException {
this.fInDTD = false;
}
public void setDTDSource(XMLDTDSource source) {
this.fDTDSource = source;
}
public XMLDTDSource getDTDSource() {
return this.fDTDSource;
}
public void startContentModel(String elementName, Augmentations augs) throws XNIException {}
public void any(Augmentations augs) throws XNIException {}
public void empty(Augmentations augs) throws XNIException {}
public void startGroup(Augmentations augs) throws XNIException {}
public void pcdata(Augmentations augs) throws XNIException {}
public void element(String elementName, Augmentations augs) throws XNIException {}
public void separator(short separator, Augmentations augs) throws XNIException {}
public void occurrence(short occurrence, Augmentations augs) throws XNIException {}
public void endGroup(Augmentations augs) throws XNIException {}
public void endContentModel(Augmentations augs) throws XNIException {}
public void setDTDContentModelSource(XMLDTDContentModelSource source) {
this.fDTDContentModelSource = source;
}
public XMLDTDContentModelSource getDTDContentModelSource() {
return this.fDTDContentModelSource;
}
protected void reset() throws XNIException {
super.reset();
this.fInDTD = false;
}
}

View File

@@ -0,0 +1,189 @@
package org.apache.xerces.parsers;
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;
class ObjectFactory {
private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties";
private static final boolean DEBUG = false;
private static Properties fXercesProperties = null;
private static long fLastModified = -1L;
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) {}
String factoryClassName = null;
if (propertiesFilename == null) {
String javah = ss.getSystemProperty("java.home");
propertiesFilename = javah + File.separator + "lib" + File.separator + "xerces.properties";
File propertiesFile = new File(propertiesFilename);
boolean propertiesFileExists = ss.getFileExists(propertiesFile);
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
if (fLastModified >= 0L) {
if (propertiesFileExists && fLastModified < (fLastModified = ss.getLastModified(propertiesFile))) {
loadProperties = true;
} else if (!propertiesFileExists) {
fLastModified = -1L;
fXercesProperties = null;
}
} else if (propertiesFileExists) {
loadProperties = true;
fLastModified = ss.getLastModified(propertiesFile);
}
if (loadProperties)
try {
fXercesProperties = new Properties();
FileInputStream fis = ss.getFileInputStream(propertiesFile);
fXercesProperties.load(fis);
fis.close();
} catch (Exception x) {
fXercesProperties = null;
fLastModified = -1L;
}
}
if (fXercesProperties != null)
factoryClassName = fXercesProperties.getProperty(factoryId);
} else {
try {
FileInputStream fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {}
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName);
return newInstance(factoryClassName, cl, true);
}
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) {}
static ClassLoader findClassLoader() throws ConfigurationError {
SecuritySupport ss = SecuritySupport.getInstance();
ClassLoader cl = ss.getContextClassLoader();
if (cl == null)
cl = ObjectFactory.class.getClassLoader();
return cl;
}
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);
}
}
static Class findProviderClass(String className, ClassLoader cl, boolean doFallback) throws ClassNotFoundException, ConfigurationError {
Class providerClass;
SecurityManager security = System.getSecurityManager();
try {
if (security != null)
security.checkPackageAccess(className);
} catch (SecurityException e) {
throw e;
}
if (cl == null) {
providerClass = Class.forName(className);
} else {
try {
providerClass = cl.loadClass(className);
} catch (ClassNotFoundException x) {
if (doFallback) {
cl = ObjectFactory.class.getClassLoader();
providerClass = cl.loadClass(className);
} else {
throw x;
}
}
}
return providerClass;
}
private static Object findJarServiceProvider(String factoryId) throws ConfigurationError {
BufferedReader rd;
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 {
rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} catch (UnsupportedEncodingException e) {
rd = new BufferedReader(new InputStreamReader(is));
}
String factoryClassName = null;
try {
factoryClassName = rd.readLine();
rd.close();
} catch (IOException x) {
return null;
}
if (factoryClassName != null && !"".equals(factoryClassName)) {
debugPrintln("found in resource, value=" + factoryClassName);
return newInstance(factoryClassName, cl, false);
}
return null;
}
static class ConfigurationError extends Error {
private Exception exception;
ConfigurationError(String msg, Exception x) {
super(msg);
this.exception = x;
}
Exception getException() {
return this.exception;
}
}
}

View File

@@ -0,0 +1,40 @@
package org.apache.xerces.parsers;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xni.grammars.XMLGrammarPool;
import org.apache.xerces.xni.parser.XMLParserConfiguration;
public class SAXParser extends AbstractSAXParser {
protected static final String NOTIFY_BUILTIN_REFS = "http://apache.org/xml/features/scanner/notify-builtin-refs";
private static final String[] RECOGNIZED_FEATURES = new String[] { "http://apache.org/xml/features/scanner/notify-builtin-refs" };
protected static final String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
protected static final String XMLGRAMMAR_POOL = "http://apache.org/xml/properties/internal/grammar-pool";
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://apache.org/xml/properties/internal/symbol-table", "http://apache.org/xml/properties/internal/grammar-pool" };
public SAXParser(XMLParserConfiguration config) {
super(config);
}
public SAXParser() {
this(null, null);
}
public SAXParser(SymbolTable symbolTable) {
this(symbolTable, null);
}
public SAXParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
super((XMLParserConfiguration)ObjectFactory.createObject("org.apache.xerces.xni.parser.XMLParserConfiguration", "org.apache.xerces.parsers.IntegratedParserConfiguration"));
this.fConfiguration.addRecognizedFeatures(RECOGNIZED_FEATURES);
this.fConfiguration.setFeature("http://apache.org/xml/features/scanner/notify-builtin-refs", true);
this.fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
if (symbolTable != null)
this.fConfiguration.setProperty("http://apache.org/xml/properties/internal/symbol-table", symbolTable);
if (grammarPool != null)
this.fConfiguration.setProperty("http://apache.org/xml/properties/internal/grammar-pool", grammarPool);
}
}

View File

@@ -0,0 +1,58 @@
package org.apache.xerces.parsers;
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;
}
}
static SecuritySupport getInstance() {
return (SecuritySupport)securitySupport;
}
ClassLoader getContextClassLoader() {
return null;
}
String getSystemProperty(String propName) {
return System.getProperty(propName);
}
FileInputStream getFileInputStream(File file) throws FileNotFoundException {
return new FileInputStream(file);
}
InputStream getResourceAsStream(ClassLoader cl, String name) {
InputStream ris;
if (cl == null) {
ris = ClassLoader.getSystemResourceAsStream(name);
} else {
ris = cl.getResourceAsStream(name);
}
return ris;
}
boolean getFileExists(File f) {
return f.exists();
}
long getLastModified(File f) {
return f.lastModified();
}
}

View File

@@ -0,0 +1,98 @@
package org.apache.xerces.parsers;
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 {
ClassLoader getContextClassLoader() {
return AccessController.<ClassLoader>doPrivileged(new PrivilegedAction(this) {
private final SecuritySupport12 this$0;
public Object run() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) {}
return cl;
}
});
}
String getSystemProperty(String propName) {
return AccessController.<String>doPrivileged(new PrivilegedAction(this, propName) {
private final String val$propName;
private final SecuritySupport12 this$0;
public Object run() {
return System.getProperty(this.val$propName);
}
});
}
FileInputStream getFileInputStream(File file) throws FileNotFoundException {
try {
return AccessController.<FileInputStream>doPrivileged(new PrivilegedExceptionAction(this, file) {
private final File val$file;
private final SecuritySupport12 this$0;
public Object run() throws FileNotFoundException {
return new FileInputStream(this.val$file);
}
});
} catch (PrivilegedActionException e) {
throw (FileNotFoundException)e.getException();
}
}
InputStream getResourceAsStream(ClassLoader cl, String name) {
return AccessController.<InputStream>doPrivileged(new PrivilegedAction(this, cl, name) {
private final ClassLoader val$cl;
private final String val$name;
private final SecuritySupport12 this$0;
public Object run() {
InputStream ris;
if (this.val$cl == null) {
ris = ClassLoader.getSystemResourceAsStream(this.val$name);
} else {
ris = this.val$cl.getResourceAsStream(this.val$name);
}
return ris;
}
});
}
boolean getFileExists(File f) {
return ((Boolean)AccessController.<Boolean>doPrivileged(new PrivilegedAction(this, f) {
private final File val$f;
private final SecuritySupport12 this$0;
public Object run() {
return new Boolean(this.val$f.exists());
}
})).booleanValue();
}
long getLastModified(File f) {
return ((Long)AccessController.<Long>doPrivileged(new PrivilegedAction(this, f) {
private final File val$f;
private final SecuritySupport12 this$0;
public Object run() {
return new Long(this.val$f.lastModified());
}
})).longValue();
}
}

View File

@@ -0,0 +1,28 @@
package org.apache.xerces.parsers;
import java.io.IOException;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xni.parser.XMLParserConfiguration;
public abstract class XMLParser {
protected static final String ENTITY_RESOLVER = "http://apache.org/xml/properties/internal/entity-resolver";
protected static final String ERROR_HANDLER = "http://apache.org/xml/properties/internal/error-handler";
private static final String[] RECOGNIZED_PROPERTIES = new String[] { "http://apache.org/xml/properties/internal/entity-resolver", "http://apache.org/xml/properties/internal/error-handler" };
protected XMLParserConfiguration fConfiguration;
protected XMLParser(XMLParserConfiguration config) {
this.fConfiguration = config;
this.fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
}
public void parse(XMLInputSource inputSource) throws XNIException, IOException {
reset();
this.fConfiguration.parse(inputSource);
}
protected void reset() throws XNIException {}
}

View File

@@ -0,0 +1,60 @@
package org.apache.xerces.util;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class EntityResolverWrapper implements XMLEntityResolver {
protected EntityResolver fEntityResolver;
public EntityResolverWrapper() {}
public EntityResolverWrapper(EntityResolver entityResolver) {
setEntityResolver(entityResolver);
}
public void setEntityResolver(EntityResolver entityResolver) {
this.fEntityResolver = entityResolver;
}
public EntityResolver getEntityResolver() {
return this.fEntityResolver;
}
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
String pubId = resourceIdentifier.getPublicId();
String sysId = resourceIdentifier.getExpandedSystemId();
if (pubId == null && sysId == null)
return null;
if (this.fEntityResolver != null && resourceIdentifier != null)
try {
InputSource inputSource = this.fEntityResolver.resolveEntity(pubId, sysId);
if (inputSource != null) {
String publicId = inputSource.getPublicId();
String systemId = inputSource.getSystemId();
String baseSystemId = resourceIdentifier.getBaseSystemId();
InputStream byteStream = inputSource.getByteStream();
Reader charStream = inputSource.getCharacterStream();
String encoding = inputSource.getEncoding();
XMLInputSource xmlInputSource = new XMLInputSource(publicId, systemId, baseSystemId);
xmlInputSource.setByteStream(byteStream);
xmlInputSource.setCharacterStream(charStream);
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
}
} catch (SAXException e) {
Exception ex = e.getException();
if (ex == null)
ex = e;
throw new XNIException(ex);
}
return null;
}
}

View File

@@ -0,0 +1,121 @@
package org.apache.xerces.util;
import org.apache.xerces.xni.XMLLocator;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLParseException;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class ErrorHandlerWrapper implements XMLErrorHandler {
protected ErrorHandler fErrorHandler;
public ErrorHandlerWrapper() {}
public ErrorHandlerWrapper(ErrorHandler errorHandler) {
setErrorHandler(errorHandler);
}
public void setErrorHandler(ErrorHandler errorHandler) {
this.fErrorHandler = errorHandler;
}
public ErrorHandler getErrorHandler() {
return this.fErrorHandler;
}
public void warning(String domain, String key, XMLParseException exception) throws XNIException {
SAXParseException saxException = createSAXParseException(exception);
try {
this.fErrorHandler.warning(saxException);
} catch (SAXParseException e) {
throw createXMLParseException(e);
} catch (SAXException e) {
throw createXNIException(e);
}
}
public void error(String domain, String key, XMLParseException exception) throws XNIException {
SAXParseException saxException = createSAXParseException(exception);
try {
this.fErrorHandler.error(saxException);
} catch (SAXParseException e) {
throw createXMLParseException(e);
} catch (SAXException e) {
throw createXNIException(e);
}
}
public void fatalError(String domain, String key, XMLParseException exception) throws XNIException {
SAXParseException saxException = createSAXParseException(exception);
try {
this.fErrorHandler.fatalError(saxException);
} catch (SAXParseException e) {
throw createXMLParseException(e);
} catch (SAXException e) {
throw createXNIException(e);
}
}
protected static SAXParseException createSAXParseException(XMLParseException exception) {
return new SAXParseException(exception.getMessage(), exception.getPublicId(), exception.getExpandedSystemId(), exception.getLineNumber(), exception.getColumnNumber(), exception.getException());
}
protected static XMLParseException createXMLParseException(SAXParseException exception) {
String fPublicId = exception.getPublicId();
String fExpandedSystemId = exception.getSystemId();
int fLineNumber = exception.getLineNumber();
int fColumnNumber = exception.getColumnNumber();
XMLLocator location = new XMLLocator(fPublicId, fExpandedSystemId, fColumnNumber, fLineNumber) {
private final String val$fPublicId;
private final String val$fExpandedSystemId;
private final int val$fColumnNumber;
private final int val$fLineNumber;
public void setPublicId(String id) {}
public String getPublicId() {
return this.val$fPublicId;
}
public void setExpandedSystemId(String id) {}
public String getExpandedSystemId() {
return this.val$fExpandedSystemId;
}
public void setBaseSystemId(String id) {}
public String getBaseSystemId() {
return null;
}
public void setLiteralSystemId(String id) {}
public String getLiteralSystemId() {
return null;
}
public int getColumnNumber() {
return this.val$fColumnNumber;
}
public void setColumnNumber(int col) {}
public int getLineNumber() {
return this.val$fLineNumber;
}
public void setLineNumber(int line) {}
};
return new XMLParseException(location, exception.getMessage(), exception.getException());
}
protected static XNIException createXNIException(SAXException exception) {
return new XNIException(exception.getMessage(), exception.getException());
}
}

View File

@@ -0,0 +1,105 @@
package org.apache.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,139 @@
package org.apache.xerces.util;
public class SymbolTable {
protected static final int TABLE_SIZE = 101;
protected Entry[] fBuckets = null;
protected int fTableSize;
public SymbolTable() {
this(101);
}
public SymbolTable(int tableSize) {
this.fTableSize = tableSize;
this.fBuckets = new Entry[this.fTableSize];
}
public String addSymbol(String symbol) {
int bucket = hash(symbol) % this.fTableSize;
int length = symbol.length();
Entry entry;
for (entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
int i = 0;
while (true) {
if (i < length) {
if (symbol.charAt(i) != entry.characters[i])
break;
i++;
continue;
}
return entry.symbol;
}
}
}
entry = new Entry(symbol, this.fBuckets[bucket]);
this.fBuckets[bucket] = entry;
return entry.symbol;
}
public String addSymbol(char[] buffer, int offset, int length) {
int bucket = hash(buffer, offset, length) % this.fTableSize;
Entry entry;
for (entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
int i = 0;
while (true) {
if (i < length) {
if (buffer[offset + i] != entry.characters[i])
break;
i++;
continue;
}
return entry.symbol;
}
}
}
entry = new Entry(buffer, offset, length, this.fBuckets[bucket]);
this.fBuckets[bucket] = entry;
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 bucket = hash(symbol) % this.fTableSize;
int length = symbol.length();
for (Entry entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
int i = 0;
while (true) {
if (i < length) {
if (symbol.charAt(i) != entry.characters[i])
break;
i++;
continue;
}
return true;
}
}
}
return false;
}
public boolean containsSymbol(char[] buffer, int offset, int length) {
int bucket = hash(buffer, offset, length) % this.fTableSize;
for (Entry entry = this.fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
int i = 0;
while (true) {
if (i < length) {
if (buffer[offset + i] != entry.characters[i])
break;
i++;
continue;
}
return true;
}
}
}
return false;
}
protected static final class Entry {
public String symbol;
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,15 @@
package org.apache.xerces.xni;
import java.util.Enumeration;
public interface Augmentations {
void removeAllItems();
Enumeration keys();
Object getItem(String paramString);
Object removeItem(String paramString);
Object putItem(String paramString, Object paramObject);
}

View File

@@ -0,0 +1,27 @@
package org.apache.xerces.xni;
import java.util.Enumeration;
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();
int getDeclaredPrefixCount();
void popContext();
void pushContext();
void reset();
String getDeclaredPrefixAt(int paramInt);
Enumeration getAllPrefixes();
String getPrefix(String paramString);
String getURI(String paramString);
boolean declarePrefix(String paramString1, String paramString2);
}

View File

@@ -0,0 +1,92 @@
package org.apache.xerces.xni;
public class QName implements Cloneable {
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;
}
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 org.apache.xerces.xni;
public interface XMLAttributes {
int getLength();
void removeAllAttributes();
void removeAttributeAt(int paramInt);
boolean isSpecified(int paramInt);
void setSpecified(int paramInt, boolean paramBoolean);
String getLocalName(int paramInt);
String getNonNormalizedValue(int paramInt);
String getPrefix(int paramInt);
String getQName(int paramInt);
String getType(int paramInt);
String getURI(int paramInt);
String getValue(int paramInt);
void setNonNormalizedValue(int paramInt, String paramString);
void setType(int paramInt, String paramString);
void setValue(int paramInt, String paramString);
int getIndex(String paramString);
Augmentations getAugmentations(int paramInt);
void setAugmentations(int paramInt, Augmentations paramAugmentations);
void getName(int paramInt, QName paramQName);
void setName(int paramInt, QName paramQName);
String getType(String paramString);
String getValue(String paramString);
int getIndex(String paramString1, String paramString2);
Augmentations getAugmentations(String paramString);
String getType(String paramString1, String paramString2);
String getValue(String paramString1, String paramString2);
int addAttribute(QName paramQName, String paramString1, String paramString2);
Augmentations getAugmentations(String paramString1, String paramString2);
}

View File

@@ -0,0 +1,39 @@
package org.apache.xerces.xni;
import org.apache.xerces.xni.parser.XMLDTDContentModelSource;
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 any(Augmentations paramAugmentations) throws XNIException;
void empty(Augmentations paramAugmentations) throws XNIException;
void endContentModel(Augmentations paramAugmentations) throws XNIException;
void endGroup(Augmentations paramAugmentations) throws XNIException;
void pcdata(Augmentations paramAugmentations) throws XNIException;
void startGroup(Augmentations paramAugmentations) throws XNIException;
void occurrence(short paramShort, Augmentations paramAugmentations) throws XNIException;
void separator(short paramShort, Augmentations paramAugmentations) throws XNIException;
XMLDTDContentModelSource getDTDContentModelSource();
void setDTDContentModelSource(XMLDTDContentModelSource paramXMLDTDContentModelSource);
void element(String paramString, Augmentations paramAugmentations) throws XNIException;
void startContentModel(String paramString, Augmentations paramAugmentations) throws XNIException;
}

View File

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

View File

@@ -0,0 +1,41 @@
package org.apache.xerces.xni;
import org.apache.xerces.xni.parser.XMLDocumentSource;
public interface XMLDocumentHandler {
void endCDATA(Augmentations paramAugmentations) throws XNIException;
void endDocument(Augmentations paramAugmentations) throws XNIException;
void startCDATA(Augmentations paramAugmentations) throws XNIException;
XMLDocumentSource getDocumentSource();
void setDocumentSource(XMLDocumentSource paramXMLDocumentSource);
void endGeneralEntity(String paramString, Augmentations paramAugmentations) throws XNIException;
void endElement(QName paramQName, Augmentations paramAugmentations) throws XNIException;
void characters(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void comment(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void ignorableWhitespace(XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void textDecl(String paramString1, String paramString2, Augmentations paramAugmentations) throws XNIException;
void emptyElement(QName paramQName, XMLAttributes paramXMLAttributes, Augmentations paramAugmentations) throws XNIException;
void startElement(QName paramQName, XMLAttributes paramXMLAttributes, Augmentations paramAugmentations) throws XNIException;
void processingInstruction(String paramString, XMLString paramXMLString, Augmentations paramAugmentations) throws XNIException;
void doctypeDecl(String paramString1, String paramString2, String paramString3, Augmentations paramAugmentations) throws XNIException;
void xmlDecl(String paramString1, String paramString2, String paramString3, Augmentations paramAugmentations) throws XNIException;
void startGeneralEntity(String paramString1, XMLResourceIdentifier paramXMLResourceIdentifier, String paramString2, Augmentations paramAugmentations) throws XNIException;
void startDocument(XMLLocator paramXMLLocator, String paramString, NamespaceContext paramNamespaceContext, Augmentations paramAugmentations) throws XNIException;
}

View File

@@ -0,0 +1,15 @@
package org.apache.xerces.xni;
public interface XMLLocator {
int getColumnNumber();
int getLineNumber();
String getBaseSystemId();
String getExpandedSystemId();
String getLiteralSystemId();
String getPublicId();
}

View File

@@ -0,0 +1,19 @@
package org.apache.xerces.xni;
public interface XMLResourceIdentifier {
String getBaseSystemId();
String getExpandedSystemId();
String getLiteralSystemId();
String getPublicId();
void setBaseSystemId(String paramString);
void setExpandedSystemId(String paramString);
void setLiteralSystemId(String paramString);
void setPublicId(String paramString);
}

View File

@@ -0,0 +1,63 @@
package org.apache.xerces.xni;
public class XMLString {
public char[] ch;
public int offset;
public int length;
public XMLString() {}
public XMLString(char[] ch, int offset, int length) {
setValues(ch, offset, length);
}
public XMLString(XMLString string) {
setValues(string);
}
public void setValues(char[] ch, int offset, int length) {
this.ch = ch;
this.offset = offset;
this.length = length;
}
public void setValues(XMLString s) {
setValues(s.ch, s.offset, s.length);
}
public void clear() {
this.ch = null;
this.offset = 0;
this.length = -1;
}
public boolean equals(char[] ch, int offset, int length) {
if (ch == null)
return false;
if (this.length != length)
return false;
for (int i = 0; i < length; i++) {
if (this.ch[this.offset + i] != ch[offset + i])
return false;
}
return true;
}
public boolean equals(String s) {
if (s == null)
return false;
if (this.length != s.length())
return false;
for (int i = 0; i < this.length; i++) {
if (this.ch[this.offset + i] != s.charAt(i))
return false;
}
return true;
}
public String toString() {
return (this.length > 0) ? new String(this.ch, this.offset, this.length) : "";
}
}

View File

@@ -0,0 +1,23 @@
package org.apache.xerces.xni;
public class XNIException extends RuntimeException {
private Exception fException;
public XNIException(String message) {
super(message);
}
public XNIException(Exception exception) {
super(exception.getMessage());
this.fException = exception;
}
public XNIException(String message, Exception exception) {
super(message);
this.fException = exception;
}
public Exception getException() {
return this.fException;
}
}

View File

@@ -0,0 +1,5 @@
package org.apache.xerces.xni.grammars;
public interface Grammar {
XMLGrammarDescription getGrammarDescription();
}

View File

@@ -0,0 +1,11 @@
package org.apache.xerces.xni.grammars;
import org.apache.xerces.xni.XMLResourceIdentifier;
public interface XMLGrammarDescription extends XMLResourceIdentifier {
public static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
public static final String XML_DTD = "http://www.w3.org/TR/REC-xml";
String getGrammarType();
}

View File

@@ -0,0 +1,15 @@
package org.apache.xerces.xni.grammars;
public interface XMLGrammarPool {
void clear();
void lockPool();
void unlockPool();
Grammar[] retrieveInitialGrammarSet(String paramString);
void cacheGrammars(String paramString, Grammar[] paramArrayOfGrammar);
Grammar retrieveGrammar(XMLGrammarDescription paramXMLGrammarDescription);
}

View File

@@ -0,0 +1,7 @@
package org.apache.xerces.xni.parser;
public interface XMLComponentManager {
boolean getFeature(String paramString) throws XMLConfigurationException;
Object getProperty(String paramString) throws XMLConfigurationException;
}

View File

@@ -0,0 +1,33 @@
package org.apache.xerces.xni.parser;
import org.apache.xerces.xni.XNIException;
public class XMLConfigurationException extends XNIException {
public static final short NOT_RECOGNIZED = 0;
public static final short NOT_SUPPORTED = 1;
protected short fType;
protected String fIdentifier;
public XMLConfigurationException(short type, String identifier) {
super(identifier);
this.fType = type;
this.fIdentifier = identifier;
}
public XMLConfigurationException(short type, String identifier, String message) {
super(message);
this.fType = type;
this.fIdentifier = identifier;
}
public short getType() {
return this.fType;
}
public String getIdentifier() {
return this.fIdentifier;
}
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.xni.parser;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
public interface XMLDTDContentModelSource {
XMLDTDContentModelHandler getDTDContentModelHandler();
void setDTDContentModelHandler(XMLDTDContentModelHandler paramXMLDTDContentModelHandler);
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.xni.parser;
import org.apache.xerces.xni.XMLDTDHandler;
public interface XMLDTDSource {
XMLDTDHandler getDTDHandler();
void setDTDHandler(XMLDTDHandler paramXMLDTDHandler);
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.xni.parser;
import org.apache.xerces.xni.XMLDocumentHandler;
public interface XMLDocumentSource {
XMLDocumentHandler getDocumentHandler();
void setDocumentHandler(XMLDocumentHandler paramXMLDocumentHandler);
}

View File

@@ -0,0 +1,9 @@
package org.apache.xerces.xni.parser;
import java.io.IOException;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
public interface XMLEntityResolver {
XMLInputSource resolveEntity(XMLResourceIdentifier paramXMLResourceIdentifier) throws XNIException, IOException;
}

View File

@@ -0,0 +1,11 @@
package org.apache.xerces.xni.parser;
import org.apache.xerces.xni.XNIException;
public interface XMLErrorHandler {
void error(String paramString1, String paramString2, XMLParseException paramXMLParseException) throws XNIException;
void fatalError(String paramString1, String paramString2, XMLParseException paramXMLParseException) throws XNIException;
void warning(String paramString1, String paramString2, XMLParseException paramXMLParseException) throws XNIException;
}

View File

@@ -0,0 +1,95 @@
package org.apache.xerces.xni.parser;
import java.io.InputStream;
import java.io.Reader;
import org.apache.xerces.xni.XMLResourceIdentifier;
public class XMLInputSource {
protected String fPublicId;
protected String fSystemId;
protected String fBaseSystemId;
protected InputStream fByteStream;
protected Reader fCharStream;
protected String fEncoding;
public XMLInputSource(String publicId, String systemId, String baseSystemId) {
this.fPublicId = publicId;
this.fSystemId = systemId;
this.fBaseSystemId = baseSystemId;
}
public XMLInputSource(XMLResourceIdentifier resourceIdentifier) {
this.fPublicId = resourceIdentifier.getPublicId();
this.fSystemId = resourceIdentifier.getLiteralSystemId();
this.fBaseSystemId = resourceIdentifier.getBaseSystemId();
}
public XMLInputSource(String publicId, String systemId, String baseSystemId, InputStream byteStream, String encoding) {
this.fPublicId = publicId;
this.fSystemId = systemId;
this.fBaseSystemId = baseSystemId;
this.fByteStream = byteStream;
this.fEncoding = encoding;
}
public XMLInputSource(String publicId, String systemId, String baseSystemId, Reader charStream, String encoding) {
this.fPublicId = publicId;
this.fSystemId = systemId;
this.fBaseSystemId = baseSystemId;
this.fCharStream = charStream;
this.fEncoding = encoding;
}
public void setPublicId(String publicId) {
this.fPublicId = publicId;
}
public String getPublicId() {
return this.fPublicId;
}
public void setSystemId(String systemId) {
this.fSystemId = systemId;
}
public String getSystemId() {
return this.fSystemId;
}
public void setBaseSystemId(String baseSystemId) {
this.fBaseSystemId = baseSystemId;
}
public String getBaseSystemId() {
return this.fBaseSystemId;
}
public void setByteStream(InputStream byteStream) {
this.fByteStream = byteStream;
}
public InputStream getByteStream() {
return this.fByteStream;
}
public void setCharacterStream(Reader charStream) {
this.fCharStream = charStream;
}
public Reader getCharacterStream() {
return this.fCharStream;
}
public void setEncoding(String encoding) {
this.fEncoding = encoding;
}
public String getEncoding() {
return this.fEncoding;
}
}

View File

@@ -0,0 +1,96 @@
package org.apache.xerces.xni.parser;
import org.apache.xerces.xni.XMLLocator;
import org.apache.xerces.xni.XNIException;
public class XMLParseException extends XNIException {
protected String fPublicId;
protected String fLiteralSystemId;
protected String fExpandedSystemId;
protected String fBaseSystemId;
protected int fLineNumber = -1;
protected int fColumnNumber = -1;
public XMLParseException(XMLLocator locator, String message) {
super(message);
if (locator != null) {
this.fPublicId = locator.getPublicId();
this.fLiteralSystemId = locator.getLiteralSystemId();
this.fExpandedSystemId = locator.getExpandedSystemId();
this.fBaseSystemId = locator.getBaseSystemId();
this.fLineNumber = locator.getLineNumber();
this.fColumnNumber = locator.getColumnNumber();
}
}
public XMLParseException(XMLLocator locator, String message, Exception exception) {
super(message, exception);
this.fPublicId = locator.getPublicId();
this.fLiteralSystemId = locator.getLiteralSystemId();
this.fExpandedSystemId = locator.getExpandedSystemId();
this.fBaseSystemId = locator.getBaseSystemId();
this.fLineNumber = locator.getLineNumber();
this.fColumnNumber = locator.getColumnNumber();
}
public String getPublicId() {
return this.fPublicId;
}
public String getExpandedSystemId() {
return this.fExpandedSystemId;
}
public String getLiteralSystemId() {
return this.fLiteralSystemId;
}
public String getBaseSystemId() {
return this.fBaseSystemId;
}
public int getLineNumber() {
return this.fLineNumber;
}
public int getColumnNumber() {
return this.fColumnNumber;
}
public String toString() {
StringBuffer str = new StringBuffer();
if (this.fPublicId != null)
str.append(this.fPublicId);
str.append(':');
if (this.fPublicId != null)
str.append(this.fPublicId);
str.append(':');
if (this.fLiteralSystemId != null)
str.append(this.fLiteralSystemId);
str.append(':');
if (this.fExpandedSystemId != null)
str.append(this.fExpandedSystemId);
str.append(':');
if (this.fBaseSystemId != null)
str.append(this.fBaseSystemId);
str.append(':');
str.append(this.fLineNumber);
str.append(':');
str.append(this.fColumnNumber);
str.append(':');
String message = getMessage();
if (message == null) {
Exception exception = getException();
if (exception != null)
message = exception.getMessage();
}
if (message != null)
str.append(message);
return str.toString();
}
}

View File

@@ -0,0 +1,48 @@
package org.apache.xerces.xni.parser;
import java.io.IOException;
import java.util.Locale;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XNIException;
public interface XMLParserConfiguration extends XMLComponentManager {
boolean getFeature(String paramString) throws XMLConfigurationException;
void setFeature(String paramString, boolean paramBoolean) throws XMLConfigurationException;
void addRecognizedFeatures(String[] paramArrayOfString);
void addRecognizedProperties(String[] paramArrayOfString);
Locale getLocale();
void setLocale(Locale paramLocale) throws XNIException;
XMLDTDContentModelHandler getDTDContentModelHandler();
void setDTDContentModelHandler(XMLDTDContentModelHandler paramXMLDTDContentModelHandler);
XMLDTDHandler getDTDHandler();
void setDTDHandler(XMLDTDHandler paramXMLDTDHandler);
XMLDocumentHandler getDocumentHandler();
void setDocumentHandler(XMLDocumentHandler paramXMLDocumentHandler);
XMLEntityResolver getEntityResolver();
void setEntityResolver(XMLEntityResolver paramXMLEntityResolver);
XMLErrorHandler getErrorHandler();
void setErrorHandler(XMLErrorHandler paramXMLErrorHandler);
void parse(XMLInputSource paramXMLInputSource) throws XNIException, IOException;
Object getProperty(String paramString) throws XMLConfigurationException;
void setProperty(String paramString, Object paramObject) throws XMLConfigurationException;
}

View File

@@ -0,0 +1,7 @@
package org.apache.xerces.xni.psvi;
import org.apache.xerces.impl.xs.psvi.XSAttributeDeclaration;
public interface AttributePSVI extends ItemPSVI {
XSAttributeDeclaration getAttributeDeclaration();
}

View File

@@ -0,0 +1,13 @@
package org.apache.xerces.xni.psvi;
import org.apache.xerces.impl.xs.psvi.XSElementDeclaration;
import org.apache.xerces.impl.xs.psvi.XSModel;
import org.apache.xerces.impl.xs.psvi.XSNotationDeclaration;
public interface ElementPSVI extends ItemPSVI {
XSElementDeclaration getElementDeclaration();
XSModel getSchemaInformation();
XSNotationDeclaration getNotation();
}

View File

@@ -0,0 +1,37 @@
package org.apache.xerces.xni.psvi;
import org.apache.xerces.impl.xs.psvi.StringList;
import org.apache.xerces.impl.xs.psvi.XSSimpleTypeDefinition;
import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
public interface ItemPSVI {
public static final short VALIDITY_NOTKNOWN = 0;
public static final short VALIDITY_INVALID = 1;
public static final short VALIDITY_VALID = 2;
public static final short VALIDATION_NONE = 0;
public static final short VALIDATION_PARTIAL = 1;
public static final short VALIDATION_FULL = 2;
short getValidationAttempted();
short getValidity();
boolean getIsSchemaSpecified();
String getSchemaDefault();
String getSchemaNormalizedValue();
String getValidationContext();
StringList getErrorCodes();
XSSimpleTypeDefinition getMemberTypeDefinition();
XSTypeDefinition getTypeDefinition();
}