本文整理汇总了Java中org.xml.sax.SAXException.getException方法的典型用法代码示例。如果您正苦于以下问题:Java SAXException.getException方法的具体用法?Java SAXException.getException怎么用?Java SAXException.getException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.SAXException
的用法示例。
在下文中一共展示了SAXException.getException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InstanceCreator
import org.xml.sax.SAXException; //导入方法依赖的package包/类
public InstanceCreator(InputStream in) {
try {
this.relations = new HashMap<Relation,Set<List<String>>>();
this.atoms = new LinkedHashSet<String>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
this.document = builder.parse(in);
} catch (SAXException sxe) {
// Error generated during parsing
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
throw new InstanceCreationException("Error generated during parsing: " + x.getMessage());
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
throw new InstanceCreationException("Parser with specified options cannot be built: " + pce.getMessage());
} catch (IOException ioe) {
// I/O error
throw new InstanceCreationException("I/O error: " + ioe.getMessage());
} finally {
try {
in.close();
} catch (IOException e) {
// ignore
}
}
}
示例2: ParserContext
import org.xml.sax.SAXException; //导入方法依赖的package包/类
public ParserContext( XSOMParser owner, XMLParser parser ) {
this.owner = owner;
this.parser = parser;
try {
parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));
SchemaImpl xs = (SchemaImpl)
schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
xs.addSimpleType(schemaSet.anySimpleType,true);
xs.addComplexType(schemaSet.anyType,true);
} catch( SAXException e ) {
// this must be a bug of XSOM
if(e.getException()!=null)
e.getException().printStackTrace();
else
e.printStackTrace();
throw new InternalError();
}
}
示例3: createUnmarshalException
import org.xml.sax.SAXException; //导入方法依赖的package包/类
/**
* Creates an UnmarshalException from a SAXException.
*
* This is an utility method provided for the derived classes.
*
* <p>
* When a provider-implemented ContentHandler wants to throw a
* JAXBException, it needs to wrap the exception by a SAXException.
* If the unmarshaller implementation blindly wrap SAXException
* by JAXBException, such an exception will be a JAXBException
* wrapped by a SAXException wrapped by another JAXBException.
* This is silly.
*
* <p>
* This method checks the nested exception of SAXException
* and reduce those excessive wrapping.
*
* @return the resulting UnmarshalException
*/
protected UnmarshalException createUnmarshalException( SAXException e ) {
// check the nested exception to see if it's an UnmarshalException
Exception nested = e.getException();
if(nested instanceof UnmarshalException)
return (UnmarshalException)nested;
if(nested instanceof RuntimeException)
// typically this is an unexpected exception,
// just throw it rather than wrap it, so that the full stack
// trace can be displayed.
throw (RuntimeException)nested;
// otherwise simply wrap it
if(nested!=null)
return new UnmarshalException(nested);
else
return new UnmarshalException(e);
}
示例4: getFileChecksum
import org.xml.sax.SAXException; //导入方法依赖的package包/类
private FileChecksum getFileChecksum(String f) throws IOException {
final HttpURLConnection connection = openConnection(
"/fileChecksum" + ServletUtil.encodePath(f),
"ugi=" + getEncodedUgiParameter());
try {
final XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setContentHandler(this);
xr.parse(new InputSource(connection.getInputStream()));
} catch(SAXException e) {
final Exception embedded = e.getException();
if (embedded != null && embedded instanceof IOException) {
throw (IOException)embedded;
}
throw new IOException("invalid xml directory content", e);
} finally {
connection.disconnect();
}
return filechecksum;
}
示例5: parse
import org.xml.sax.SAXException; //导入方法依赖的package包/类
/**
* Parses a set of styles from <code>inputStream</code>, adding the
* resulting styles to the passed in DefaultSynthStyleFactory.
* Resources are resolved either from a URL or from a Class. When calling
* this method, one of the URL or the Class must be null but not both at
* the same time.
*
* @param inputStream XML document containing the styles to read
* @param factory DefaultSynthStyleFactory that new styles are added to
* @param urlResourceBase the URL used to resolve any resources, such as Images
* @param classResourceBase the Class used to resolve any resources, such as Images
* @param defaultsMap Map that UIDefaults properties are placed in
*/
public void parse(InputStream inputStream,
DefaultSynthStyleFactory factory,
URL urlResourceBase, Class<?> classResourceBase,
Map<String, Object> defaultsMap)
throws ParseException, IllegalArgumentException {
if (inputStream == null || factory == null ||
(urlResourceBase == null && classResourceBase == null)) {
throw new IllegalArgumentException(
"You must supply an InputStream, StyleFactory and Class or URL");
}
assert(!(urlResourceBase != null && classResourceBase != null));
_factory = factory;
_classResourceBase = classResourceBase;
_urlResourceBase = urlResourceBase;
_defaultsMap = defaultsMap;
try {
try {
SAXParser saxParser = SAXParserFactory.newInstance().
newSAXParser();
saxParser.parse(new BufferedInputStream(inputStream), this);
} catch (ParserConfigurationException e) {
throw new ParseException("Error parsing: " + e, 0);
}
catch (SAXException se) {
throw new ParseException("Error parsing: " + se + " " +
se.getException(), 0);
}
catch (IOException ioe) {
throw new ParseException("Error parsing: " + ioe, 0);
}
} finally {
reset();
}
}
示例6: instanceCreate
import org.xml.sax.SAXException; //导入方法依赖的package包/类
@Override
@NonNull
public synchronized RemotePlatform instanceCreate() throws IOException, ClassNotFoundException {
RemotePlatform remotePlatform = platformRef == null ? null : platformRef.get();
if (remotePlatform == null) {
final SAXHandler handler = new SAXHandler();
try (InputStream in = store.getPrimaryFile().getInputStream()) {
final XMLReader reader = XMLUtil.createXMLReader();
InputSource is = new InputSource(in);
is.setSystemId(store.getPrimaryFile().toURL().toExternalForm());
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
reader.setEntityResolver(handler);
reader.parse(is);
} catch (SAXException ex) {
final Exception x = ex.getException();
if (x instanceof java.io.IOException) {
throw (IOException)x;
} else {
throw new java.io.IOException(ex);
}
}
remotePlatform = RemotePlatform.create(
handler.name,
handler.properties,
handler.sysProperties);
remotePlatform.addPropertyChangeListener(this);
platformRef = new WeakReference<>(remotePlatform);
}
return remotePlatform;
}
示例7: instanceCreate
import org.xml.sax.SAXException; //导入方法依赖的package包/类
@Override
public Object instanceCreate() throws java.io.IOException, ClassNotFoundException {
synchronized (this) {
Object o = refConnection.get();
if (o != null) {
return o;
}
XMLDataObject obj = getHolder();
if (obj == null) {
return null;
}
FileObject connectionFO = obj.getPrimaryFile();
Handler handler = new Handler(connectionFO.getNameExt());
try {
XMLReader reader = XMLUtil.createXMLReader();
InputSource is = new InputSource(obj.getPrimaryFile().getInputStream());
is.setSystemId(connectionFO.toURL().toExternalForm());
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
reader.setEntityResolver(EntityCatalog.getDefault());
reader.parse(is);
} catch (SAXException ex) {
Exception x = ex.getException();
LOGGER.log(Level.FINE, "Cannot read " + obj + ". Cause: " + ex.getLocalizedMessage(), ex);
if (x instanceof java.io.IOException) {
throw (IOException)x;
} else {
throw new java.io.IOException(ex.getMessage());
}
}
DatabaseConnection inst = createDatabaseConnection(handler);
refConnection = new WeakReference<>(inst);
attachListener();
return inst;
}
}
示例8: getContentSummary
import org.xml.sax.SAXException; //导入方法依赖的package包/类
/**
* Connect to the name node and get content summary.
* @param path The path
* @return The content summary for the path.
* @throws IOException
*/
private ContentSummary getContentSummary(String path) throws IOException {
final HttpURLConnection connection = openConnection(
"/contentSummary" + ServletUtil.encodePath(path),
"ugi=" + getEncodedUgiParameter());
InputStream in = null;
try {
in = connection.getInputStream();
final XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setContentHandler(this);
xr.parse(new InputSource(in));
} catch(FileNotFoundException fnfe) {
//the server may not support getContentSummary
return null;
} catch(SAXException saxe) {
final Exception embedded = saxe.getException();
if (embedded != null && embedded instanceof IOException) {
throw (IOException)embedded;
}
throw new IOException("Invalid xml format", saxe);
} finally {
if (in != null) {
in.close();
}
connection.disconnect();
}
return contentsummary;
}
示例9: addStart
import org.xml.sax.SAXException; //导入方法依赖的package包/类
protected final void addStart(final String name, final Attributes attrs) {
try {
h.startElement("", name, name, attrs);
} catch (SAXException ex) {
throw new RuntimeException(ex.getMessage(), ex.getException());
}
}
示例10: getExternalSubset
import org.xml.sax.SAXException; //导入方法依赖的package包/类
/**
* <p>Locates an external subset for documents which do not explicitly
* provide one. If no external subset is provided, this method should
* return <code>null</code>.</p>
*
* @param grammarDescription a description of the DTD
*
* @throws XNIException Thrown on general error.
* @throws IOException Thrown if resolved entity stream cannot be
* opened or some other i/o error occurs.
*/
public XMLInputSource getExternalSubset(XMLDTDDescription grammarDescription)
throws XNIException, IOException {
if (fEntityResolver != null) {
String name = grammarDescription.getRootName();
String baseURI = grammarDescription.getBaseSystemId();
// Resolve using EntityResolver2
try {
InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI);
return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
}
// error resolving external subset
catch (SAXException e) {
Exception ex = e.getException();
if (ex == null) {
ex = e;
}
throw new XNIException(ex);
}
}
// unable to resolve external subset
return null;
}
示例11: ScriptDocument
import org.xml.sax.SAXException; //导入方法依赖的package包/类
public ScriptDocument(String name, InputStream input)
{
_name = name;
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try
{
final DocumentBuilder builder = factory.newDocumentBuilder();
_document = builder.parse(input);
}
catch (SAXException sxe)
{
// Error generated during parsing)
Exception x = sxe;
if (sxe.getException() != null)
{
x = sxe.getException();
}
_log.warning(getClass().getSimpleName() + ": " + x.getMessage());
}
catch (ParserConfigurationException pce)
{
// Parser with specified options can't be built
_log.log(Level.WARNING, "", pce);
}
catch (IOException ioe)
{
// I/O error
_log.log(Level.WARNING, "", ioe);
}
}
示例12: addDocumentEnd
import org.xml.sax.SAXException; //导入方法依赖的package包/类
protected void addDocumentEnd() {
try {
h.endDocument();
} catch (SAXException ex) {
throw new RuntimeException(ex.getMessage(), ex.getException());
}
}
示例13: resolveEntity
import org.xml.sax.SAXException; //导入方法依赖的package包/类
/**
* Resolves an external parsed entity. If the entity cannot be
* resolved, this method should return null.
*
* @param resourceIdentifier contains the physical co-ordinates of the resource to be resolved
*
* @throws XNIException Thrown on general error.
* @throws IOException Thrown if resolved entity stream cannot be
* opened or some other i/o error occurs.
*/
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
throws XNIException, IOException {
if (fEntityResolver != null) {
String pubId = resourceIdentifier.getPublicId();
String sysId = resourceIdentifier.getLiteralSystemId();
String baseURI = resourceIdentifier.getBaseSystemId();
String name = null;
if (resourceIdentifier instanceof XMLDTDDescription) {
name = "[dtd]";
}
else if (resourceIdentifier instanceof XMLEntityDescription) {
name = ((XMLEntityDescription) resourceIdentifier).getEntityName();
}
// When both pubId and sysId are null, the user's entity resolver
// can do nothing about it. We'd better not bother calling it.
// This happens when the resourceIdentifier is a GrammarDescription,
// which describes a schema grammar of some namespace, but without
// any schema location hint. -Sg
if (pubId == null && sysId == null) {
return null;
}
// Resolve using EntityResolver2
try {
InputSource inputSource =
fEntityResolver.resolveEntity(name, pubId, baseURI, sysId);
return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
}
// error resolving entity
catch (SAXException e) {
Exception ex = e.getException();
if (ex == null) {
ex = e;
}
throw new XNIException(ex);
}
}
// unable to resolve entity
return null;
}
示例14: XMLParserTablaEstados
import org.xml.sax.SAXException; //导入方法依赖的package包/类
/**
* Constructor
*/
public XMLParserTablaEstados(String nombreFich)throws ExcepcionNoSePudoCrearAutomataEFE {
// Esta parte es genrica para cualquier parsing XML
// parsing XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
// factory.setNamespaceAware(true);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(this.getClass().getResourceAsStream(nombreFich));
} catch (SAXException sxe) {
// Error generated during parsing
Exception x = sxe;
if (sxe.getException() != null) {
x = sxe.getException();
}
System.out.println("Se ha producido un error al procesar el fichero XML: "
+ x.getMessage());
throw new ExcepcionNoSePudoCrearAutomataEFE( "XMLParserTablaEstados", "error al procesar el fichero XML"+ nombreFich,
"document = builder.parse(this.getClass().getResourceAsStream(nombreFich)");
//x.printStackTrace();
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
System.out
.println("No se pudo construir un analizador XML con las opciones especificadas referido al fichero XML: "
+ nombreFich);
throw new ExcepcionNoSePudoCrearAutomataEFE("XMLParserTablaEstados","no se pudo construir un analizador XML a partir del fichero XML: "+ nombreFich,
"document = builder.parse(this.getClass().getResourceAsStream(nombreFich)");
//pce.printStackTrace();
} catch (IOException ioe) {
System.out.println("Error de lectura en el fichero XML. Est usted seguro de que el fichero '"
+ nombreFich + "' esta ahi?");
throw new ExcepcionNoSePudoCrearAutomataEFE("XMLParserTablaEstados","Error de lectura en el fichero XML : "+ nombreFich,
"document = builder.parse(this.getClass().getResourceAsStream(nombreFich)");
//pce.printStackTrace();
}
}
示例15: toBuildException
import org.xml.sax.SAXException; //导入方法依赖的package包/类
static BuildException toBuildException(SAXException e) {
Exception inner = e.getException();
if (inner instanceof BuildException)
throw (BuildException)inner;
throw new BuildException(e);
}