當前位置: 首頁>>代碼示例>>Java>>正文


Java SAXException.getException方法代碼示例

本文整理匯總了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
		}
	}
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:31,代碼來源:InstanceCreator.java

示例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();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:ParserContext.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:AbstractUnmarshallerImpl.java

示例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;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:HftpFileSystem.java

示例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();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:50,代碼來源:SynthParser.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:RemotePlatformProvider.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:DatabaseConnectionConvertor.java

示例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;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:35,代碼來源:HftpFileSystem.java

示例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());
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:8,代碼來源:SAXAdapter.java

示例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;

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:EntityResolver2Wrapper.java

示例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);
	}
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:34,代碼來源:ScriptDocument.java

示例12: addDocumentEnd

import org.xml.sax.SAXException; //導入方法依賴的package包/類
protected void addDocumentEnd() {
    try {
        h.endDocument();
    } catch (SAXException ex) {
        throw new RuntimeException(ex.getMessage(), ex.getException());
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:8,代碼來源:SAXAdapter.java

示例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;

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:56,代碼來源:EntityResolver2Wrapper.java

示例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();

	}

}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:44,代碼來源:XMLParserTablaEstados.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:SAXParseable.java


注:本文中的org.xml.sax.SAXException.getException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。