| Method from com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader Detail: |
public void characters(char[] ch,
int start,
int length) throws SAXException {
if (saxParser != null) {
saxParser.characters(ch, start, length);
}
}
The SAX characters method. Does nothing. |
public void endDocument() throws SAXException {
if (saxParser != null) {
saxParser.endDocument();
}
}
The SAX endDocument method. Does nothing. |
public void endElement(String name) throws SAXException {
if (saxParser != null) {
saxParser.endElement(name);
}
}
The SAX endElement method. Does nothing. |
public void endElement(String namespaceURI,
String localName,
String qName) throws SAXException {
if (saxParser != null) {
saxParser.endElement(namespaceURI, localName, qName);
}
}
The SAX2 endElement method. Does nothing. |
public void endPrefixMapping(String prefix) throws SAXException {
if (saxParser != null) {
saxParser.endPrefixMapping (prefix);
}
}
The SAX endPrefixMapping method. Does nothing. |
public String getCatalogParser(String namespaceURI,
String rootElement) {
if (namespaceURI == null) {
return (String) namespaceMap.get(rootElement);
} else {
return (String) namespaceMap.get("{"+namespaceURI+"}"+rootElement);
}
}
Get the SAXCatalogParser class for the given namespace/root
element type. |
public String getParserClass() {
return parserClass;
}
Get the parser class currently in use. |
public SAXParserFactory getParserFactory() {
return parserFactory;
}
Get the parser factory currently in use. |
public void ignorableWhitespace(char[] ch,
int start,
int length) throws SAXException {
if (saxParser != null) {
saxParser.ignorableWhitespace(ch, start, length);
}
}
The SAX ignorableWhitespace method. Does nothing. |
public void processingInstruction(String target,
String data) throws SAXException {
if (saxParser != null) {
saxParser.processingInstruction(target, data);
}
}
The SAX processingInstruction method. Does nothing. |
public void readCatalog(Catalog catalog,
String fileUrl) throws MalformedURLException, IOException, CatalogException {
URL url = null;
try {
url = new URL(fileUrl);
} catch (MalformedURLException e) {
url = new URL("file:///" + fileUrl);
}
debug = catalog.getCatalogManager().debug;
try {
URLConnection urlCon = url.openConnection();
readCatalog(catalog, urlCon.getInputStream());
} catch (FileNotFoundException e) {
catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found",
url.toString());
}
}
Parse an XML Catalog file. |
public void readCatalog(Catalog catalog,
InputStream is) throws IOException, CatalogException {
// Create an instance of the parser
if (parserFactory == null && parserClass == null) {
debug.message(1, "Cannot read SAX catalog without a parser");
throw new CatalogException(CatalogException.UNPARSEABLE);
}
debug = catalog.getCatalogManager().debug;
EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();
this.catalog = catalog;
try {
if (parserFactory != null) {
SAXParser parser = parserFactory.newSAXParser();
SAXParserHandler spHandler = new SAXParserHandler();
spHandler.setContentHandler(this);
if (bResolver != null) {
spHandler.setEntityResolver(bResolver);
}
parser.parse(new InputSource(is), spHandler);
} else {
Parser parser = (Parser) Class.forName(parserClass).newInstance();
parser.setDocumentHandler(this);
if (bResolver != null) {
parser.setEntityResolver(bResolver);
}
parser.parse(new InputSource(is));
}
} catch (ClassNotFoundException cnfe) {
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (IllegalAccessException iae) {
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (InstantiationException ie) {
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (ParserConfigurationException pce) {
throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
} catch (SAXException se) {
Exception e = se.getException();
// FIXME: there must be a better way
UnknownHostException uhe = new UnknownHostException();
FileNotFoundException fnfe = new FileNotFoundException();
if (e != null) {
if (e.getClass() == uhe.getClass()) {
throw new CatalogException(CatalogException.PARSE_FAILED,
e.toString());
} else if (e.getClass() == fnfe.getClass()) {
throw new CatalogException(CatalogException.PARSE_FAILED,
e.toString());
}
}
throw new CatalogException(se);
}
}
Parse an XML Catalog stream. |
public void setCatalogParser(String namespaceURI,
String rootElement,
String parserClass) {
if (namespaceURI == null) {
namespaceMap.put(rootElement, parserClass);
} else {
namespaceMap.put("{"+namespaceURI+"}"+rootElement, parserClass);
}
}
Set the SAXCatalogParser class for the given namespace/root
element type. |
public void setDocumentLocator(Locator locator) {
if (saxParser != null) {
saxParser.setDocumentLocator(locator);
}
}
The SAX setDocumentLocator method. Does nothing. |
public void setParserClass(String parserClass) {
this.parserClass = parserClass;
}
Set the XML SAX Parser Class |
public void setParserFactory(SAXParserFactory parserFactory) {
this.parserFactory = parserFactory;
}
Set the XML SAX Parser Factory. |
public void skippedEntity(String name) throws SAXException {
if (saxParser != null) {
saxParser.skippedEntity(name);
}
}
The SAX skippedentity method. Does nothing. |
public void startDocument() throws SAXException {
saxParser = null;
abandonHope = false;
return;
}
The SAX startDocument method. Does nothing. |
public void startElement(String name,
AttributeList atts) throws SAXException {
if (abandonHope) {
return;
}
if (saxParser == null) {
String prefix = "";
if (name.indexOf(':") > 0) {
prefix = name.substring(0, name.indexOf(':"));
}
String localName = name;
if (localName.indexOf(':") > 0) {
localName = localName.substring(localName.indexOf(':")+1);
}
String namespaceURI = null;
if (prefix.equals("")) {
namespaceURI = atts.getValue("xmlns");
} else {
namespaceURI = atts.getValue("xmlns:" + prefix);
}
String saxParserClass = getCatalogParser(namespaceURI,
localName);
if (saxParserClass == null) {
abandonHope = true;
if (namespaceURI == null) {
debug.message(2, "No Catalog parser for " + name);
} else {
debug.message(2, "No Catalog parser for "
+ "{" + namespaceURI + "}"
+ name);
}
return;
}
try {
saxParser = (SAXCatalogParser)
Class.forName(saxParserClass).newInstance();
saxParser.setCatalog(catalog);
saxParser.startDocument();
saxParser.startElement(name, atts);
} catch (ClassNotFoundException cnfe) {
saxParser = null;
abandonHope = true;
debug.message(2, cnfe.toString());
} catch (InstantiationException ie) {
saxParser = null;
abandonHope = true;
debug.message(2, ie.toString());
} catch (IllegalAccessException iae) {
saxParser = null;
abandonHope = true;
debug.message(2, iae.toString());
} catch (ClassCastException cce ) {
saxParser = null;
abandonHope = true;
debug.message(2, cce.toString());
}
} else {
saxParser.startElement(name, atts);
}
}
The SAX startElement method.
The catalog parser is selected based on the namespace of the
first element encountered in the catalog. |
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts) throws SAXException {
if (abandonHope) {
return;
}
if (saxParser == null) {
String saxParserClass = getCatalogParser(namespaceURI,
localName);
if (saxParserClass == null) {
abandonHope = true;
if (namespaceURI == null) {
debug.message(2, "No Catalog parser for " + localName);
} else {
debug.message(2, "No Catalog parser for "
+ "{" + namespaceURI + "}"
+ localName);
}
return;
}
try {
saxParser = (SAXCatalogParser)
Class.forName(saxParserClass).newInstance();
saxParser.setCatalog(catalog);
saxParser.startDocument();
saxParser.startElement(namespaceURI, localName, qName, atts);
} catch (ClassNotFoundException cnfe) {
saxParser = null;
abandonHope = true;
debug.message(2, cnfe.toString());
} catch (InstantiationException ie) {
saxParser = null;
abandonHope = true;
debug.message(2, ie.toString());
} catch (IllegalAccessException iae) {
saxParser = null;
abandonHope = true;
debug.message(2, iae.toString());
} catch (ClassCastException cce ) {
saxParser = null;
abandonHope = true;
debug.message(2, cce.toString());
}
} else {
saxParser.startElement(namespaceURI, localName, qName, atts);
}
}
The SAX2 startElement method.
The catalog parser is selected based on the namespace of the
first element encountered in the catalog. |
public void startPrefixMapping(String prefix,
String uri) throws SAXException {
if (saxParser != null) {
saxParser.startPrefixMapping (prefix, uri);
}
}
The SAX startPrefixMapping method. Does nothing. |