本文整理汇总了Java中org.w3c.dom.ls.LSException类的典型用法代码示例。如果您正苦于以下问题:Java LSException类的具体用法?Java LSException怎么用?Java LSException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LSException类属于org.w3c.dom.ls包,在下文中一共展示了LSException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
public Document parse(InputStream in)
throws SAXException, IOException
{
LSInput input = ls.createLSInput();
input.setByteStream(in);
try
{
return parser.parse(input);
}
catch (LSException e)
{
Throwable e2 = e.getCause();
if (e2 instanceof IOException)
throw (IOException) e2;
else
throw e;
}
}
示例2: serializeDOM_LS
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
protected void serializeDOM_LS(Element elt, OutputStream out, boolean pretty) throws LSException
{
DOMImplementationLS impl = (DOMImplementationLS)XMLImplFinder.getDOMImplementation();
// init and configure serializer
LSSerializer serializer = impl.createLSSerializer();
DOMConfiguration config = serializer.getDomConfig();
config.setParameter("format-pretty-print", pretty);
// wrap output stream
LSOutput output = impl.createLSOutput();
output.setByteStream(out);
// launch serialization
serializer.write(elt, output);
}
示例3: createLSException
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
/**
* Creates an LSException. On J2SE 1.4 and above the cause for the exception will be set.
*/
public static LSException createLSException(short code, Throwable cause) {
LSException lse = new LSException(code, cause != null ? cause.getMessage() : null);
if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
try {
ThrowableMethods.fgThrowableInitCauseMethod.invoke(lse, new Object [] {cause});
}
// Something went wrong. There's not much we can do about it.
catch (Exception e) {}
}
return lse;
}
示例4: parse
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
public Document parse(LSInput input)
throws DOMException, LSException
{
if (async)
{
return doParse(input);
}
else
{
synchronized (this)
{
return doParse(input);
}
}
}
示例5: parseURI
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
public Document parseURI(String uri)
throws DOMException, LSException
{
LSInput input = new DomLSInput();
input.setSystemId(uri);
return parse(input);
}
示例6: writeToURI
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
public boolean writeToURI(Node node, String uri)
throws LSException
{
LSOutput output = new DomLSOutput();
output.setSystemId(uri);
return write(node, output);
}
示例7: writeToString
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
public String writeToString(Node node)
throws DOMException, LSException
{
Writer writer = new StringWriter();
LSOutput output = new DomLSOutput();
output.setCharacterStream(writer);
write(node, output);
return writer.toString();
}
示例8: createLSException
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
/**
* Creates an LSException. On J2SE 1.4 and above the cause for the exception will be set.
*/
private static LSException createLSException(short code, Throwable cause) {
LSException lse = new LSException(code, cause != null ? cause.getMessage() : null);
if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
try {
ThrowableMethods.fgThrowableInitCauseMethod.invoke(lse, new Object [] {cause});
}
// Something went wrong. There's not much we can do about it.
catch (Exception e) {}
}
return lse;
}
示例9: serializeTransformElement
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
private static String serializeTransformElement(Element xformEl) throws DOMException, LSException {
Document document = xformEl.getOwnerDocument();
DOMImplementationLS domImplLS = (DOMImplementationLS) document.getImplementation();
LSSerializer serializer = domImplLS.createLSSerializer();
// serializer.getDomConfig().setParameter("namespaces", true);
// serializer.getDomConfig().setParameter("namespace-declarations", true);
serializer.getDomConfig().setParameter("canonical-form", false);
serializer.getDomConfig().setParameter("xml-declaration", false);
String str = serializer.writeToString(xformEl);
return str;
}
示例10: parseURI
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
/**
* Parse an XML document from a location identified by an URI reference.
* If the URI contains a fragment identifier (see section 4.1 in ), the
* behavior is not defined by this specification.
*
*/
public Document parseURI (String uri) throws LSException {
//If DOMParser insstance is already busy parsing another document when this
// method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
if ( fBusy ) {
String msg = DOMMessageFormatter.formatMessage (
DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR",null);
throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
}
XMLInputSource source = new XMLInputSource (null, uri, null);
try {
currentThread = Thread.currentThread();
fBusy = true;
parse (source);
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
//reset interrupt state
abortNow = false;
Thread.interrupted();
}
} catch (Exception e){
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
Thread.interrupted();
}
if (abortNow) {
abortNow = false;
restoreHandlers();
return null;
}
// Consume this exception if the user
// issued an interrupt or an abort.
if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
error.fMessage = e.getMessage ();
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler ().handleError (error);
}
if (DEBUG) {
e.printStackTrace ();
}
throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
Document doc = getDocument();
dropDocumentReferences();
return doc;
}
示例11: parse
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
/**
* Parse an XML document from a resource identified by an
* <code>LSInput</code>.
*
*/
public Document parse (LSInput is) throws LSException {
// need to wrap the LSInput with an XMLInputSource
XMLInputSource xmlInputSource = dom2xmlInputSource (is);
if ( fBusy ) {
String msg = DOMMessageFormatter.formatMessage (
DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR",null);
throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
}
try {
currentThread = Thread.currentThread();
fBusy = true;
parse (xmlInputSource);
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
//reset interrupt state
abortNow = false;
Thread.interrupted();
}
} catch (Exception e) {
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
Thread.interrupted();
}
if (abortNow) {
abortNow = false;
restoreHandlers();
return null;
}
// Consume this exception if the user
// issued an interrupt or an abort.
if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
error.fMessage = e.getMessage ();
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler().handleError (error);
}
if (DEBUG) {
e.printStackTrace ();
}
throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
Document doc = getDocument();
dropDocumentReferences();
return doc;
}
示例12: parseURI
import org.w3c.dom.ls.LSException; //导入依赖的package包/类
/**
* Parse an XML document from a location identified by an URI reference.
* If the URI contains a fragment identifier (see section 4.1 in ), the
* behavior is not defined by this specification.
*
*/
public Document parseURI (String uri) throws LSException {
//If DOMParser insstance is already busy parsing another document when this
// method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
if ( fBusy ) {
String msg = DOMMessageFormatter.formatMessage (
DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR",null);
throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
}
XMLInputSource source = new XMLInputSource (null, uri, null, false);
try {
currentThread = Thread.currentThread();
fBusy = true;
parse (source);
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
//reset interrupt state
abortNow = false;
Thread.interrupted();
}
} catch (Exception e){
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
Thread.interrupted();
}
if (abortNow) {
abortNow = false;
restoreHandlers();
return null;
}
// Consume this exception if the user
// issued an interrupt or an abort.
if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
error.fMessage = e.getMessage ();
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler ().handleError (error);
}
if (DEBUG) {
e.printStackTrace ();
}
throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
Document doc = getDocument();
dropDocumentReferences();
return doc;
}