org.xml.sax.SAXException#toString ( )源码实例Demo

下面列出了org.xml.sax.SAXException#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bytecoder   文件: TrAXFilter.java
@Override
public void parse (InputSource input) throws SAXException, IOException
{
    XMLReader managedReader = null;

    try {
        if (getParent() == null) {
            try {
                managedReader = XMLReaderManager.getInstance(_overrideDefaultParser)
                                                .getXMLReader();
                setParent(managedReader);
            } catch (SAXException  e) {
                throw new SAXException(e.toString());
            }
        }

        // call parse on the parent
        getParent().parse(input);
    } finally {
        if (managedReader != null) {
            XMLReaderManager.getInstance(_overrideDefaultParser).releaseXMLReader(managedReader);
        }
    }
}
 
源代码2 项目: openjdk-jdk9   文件: Bug6889654Test.java
@Test
public void testException() {
    try {
        parse();
    } catch (SAXException e) {
        // e.printStackTrace();
        String msg = e.toString();
        if (msg.indexOf("systemId") == -1) {
            Assert.fail("CR6889654 -- details should be returned.");
        }
        if (msg.indexOf(MSG) == -1) {
            Assert.fail("CR6889649 -- additional error message not returned.");
        }
        System.out.println("error message:\n" + msg);
    }
}
 
源代码3 项目: openjdk-jdk9   文件: Bug8073385.java
@Test(dataProvider = "illegalCharactersData")
public void test(int character) throws Exception {
    // Construct the XML document as a String
    int[] cps = new int[]{character};
    String txt = new String(cps, 0, cps.length);
    String inxml = "<topElement attTest=\'" + txt + "\'/>";
    String exceptionText = "NO EXCEPTION OBSERVED";
    String hexString = "0x" + Integer.toHexString(character);

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(false);
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource isrc = new InputSource(new StringReader(inxml));

    try {
        db.parse(isrc);
    } catch (SAXException e) {
        exceptionText = e.toString();
    }
    System.out.println("Got Exception:" + exceptionText);
    assertTrue(exceptionText.contains("attribute \"attTest\""));
    assertTrue(exceptionText.contains("element is \"topElement\""));
    assertTrue(exceptionText.contains("Unicode: " + hexString));
}
 
源代码4 项目: openjdk-jdk9   文件: TrAXFilter.java
public void parse (InputSource input) throws SAXException, IOException
{
    XMLReader managedReader = null;

    try {
        if (getParent() == null) {
            try {
                managedReader = XMLReaderManager.getInstance(_useServicesMechanism)
                                                .getXMLReader();
                setParent(managedReader);
            } catch (SAXException  e) {
                throw new SAXException(e.toString());
            }
        }

        // call parse on the parent
        getParent().parse(input);
    } finally {
        if (managedReader != null) {
            XMLReaderManager.getInstance(_useServicesMechanism).releaseXMLReader(managedReader);
        }
    }
}
 
源代码5 项目: hottub   文件: ToUnknownStream.java
private void flush()
{
    try
    {
    if (m_firstTagNotEmitted)
    {
        emitFirstTag();
    }
    if (m_needToCallStartDocument)
    {
        m_handler.startDocument();
        m_needToCallStartDocument = false;
    }
    }
    catch(SAXException e)
    {
        throw new RuntimeException(e.toString());
    }


}
 
源代码6 项目: openjdk-8-source   文件: ToUnknownStream.java
private void flush()
{
    try
    {
    if (m_firstTagNotEmitted)
    {
        emitFirstTag();
    }
    if (m_needToCallStartDocument)
    {
        m_handler.startDocument();
        m_needToCallStartDocument = false;
    }
    }
    catch(SAXException e)
    {
        throw new RuntimeException(e.toString());
    }


}
 
源代码7 项目: jdk8u_jdk   文件: BadExceptionMessageTest.java
@Test(dataProvider = "illegalCharactersData")
public void test(int character) throws Exception {
    // Construct the XML document as a String
    int[] cps = new int[]{character};
    String txt = new String(cps, 0, cps.length);
    String inxml = "<topElement attTest=\'" + txt + "\'/>";
    String exceptionText = "NO EXCEPTION OBSERVED";
    String hexString = "0x" + Integer.toHexString(character);

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(false);
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource isrc = new InputSource(new StringReader(inxml));

    try {
        db.parse(isrc);
    } catch (SAXException e) {
        exceptionText = e.toString();
    }
    System.out.println("Got Exception:" + exceptionText);
    assertTrue(exceptionText.contains("attribute \"attTest\""));
    assertTrue(exceptionText.contains("element is \"topElement\""));
    assertTrue(exceptionText.contains("Unicode: " + hexString));
}
 
源代码8 项目: jdk8u60   文件: ToUnknownStream.java
private void flush()
{
    try
    {
    if (m_firstTagNotEmitted)
    {
        emitFirstTag();
    }
    if (m_needToCallStartDocument)
    {
        m_handler.startDocument();
        m_needToCallStartDocument = false;
    }
    }
    catch(SAXException e)
    {
        throw new RuntimeException(e.toString());
    }


}
 
源代码9 项目: hottub   文件: BadExceptionMessageTest.java
@Test(dataProvider = "illegalCharactersData")
public void test(int character) throws Exception {
    // Construct the XML document as a String
    int[] cps = new int[]{character};
    String txt = new String(cps, 0, cps.length);
    String inxml = "<topElement attTest=\'" + txt + "\'/>";
    String exceptionText = "NO EXCEPTION OBSERVED";
    String hexString = "0x" + Integer.toHexString(character);

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(false);
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource isrc = new InputSource(new StringReader(inxml));

    try {
        db.parse(isrc);
    } catch (SAXException e) {
        exceptionText = e.toString();
    }
    System.out.println("Got Exception:" + exceptionText);
    assertTrue(exceptionText.contains("attribute \"attTest\""));
    assertTrue(exceptionText.contains("element is \"topElement\""));
    assertTrue(exceptionText.contains("Unicode: " + hexString));
}
 
源代码10 项目: openjdk-8   文件: ToUnknownStream.java
private void flush()
{
    try
    {
    if (m_firstTagNotEmitted)
    {
        emitFirstTag();
    }
    if (m_needToCallStartDocument)
    {
        m_handler.startDocument();
        m_needToCallStartDocument = false;
    }
    }
    catch(SAXException e)
    {
        throw new RuntimeException(e.toString());
    }


}
 
源代码11 项目: j2objc   文件: ToUnknownStream.java
private void flush()
{
    try
    {
    if (m_firstTagNotEmitted)
    {
        emitFirstTag();
    }
    if (m_needToCallStartDocument)
    {
        m_handler.startDocument();
        m_needToCallStartDocument = false;
    }
    }
    catch(SAXException e)
    {
        throw new RuntimeException(e.toString());
    }
      

}
 
@Test(dataProvider = "illegalCharactersData")
public void test(int character) throws Exception {
    // Construct the XML document as a String
    int[] cps = new int[]{character};
    String txt = new String(cps, 0, cps.length);
    String inxml = "<topElement attTest=\'" + txt + "\'/>";
    String exceptionText = "NO EXCEPTION OBSERVED";
    String hexString = "0x" + Integer.toHexString(character);

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(false);
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource isrc = new InputSource(new StringReader(inxml));

    try {
        db.parse(isrc);
    } catch (SAXException e) {
        exceptionText = e.toString();
    }
    System.out.println("Got Exception:" + exceptionText);
    assertTrue(exceptionText.contains("attribute \"attTest\""));
    assertTrue(exceptionText.contains("element is \"topElement\""));
    assertTrue(exceptionText.contains("Unicode: " + hexString));
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: TrAXFilter.java
@Override
public void parse (InputSource input) throws SAXException, IOException
{
    XMLReader managedReader = null;

    try {
        if (getParent() == null) {
            try {
                managedReader = XMLReaderManager.getInstance(_overrideDefaultParser)
                                                .getXMLReader();
                setParent(managedReader);
            } catch (SAXException  e) {
                throw new SAXException(e.toString());
            }
        }

        // call parse on the parent
        getParent().parse(input);
    } finally {
        if (managedReader != null) {
            XMLReaderManager.getInstance(_overrideDefaultParser).releaseXMLReader(managedReader);
        }
    }
}
 
源代码14 项目: ontopia   文件: CanonicalTopicMapWriter.java
@Override
public void write(TopicMapIF topicmap) throws IOException {
  try {
    export(topicmap, out);
  }
  catch (SAXException e) {
    if (e.getException() instanceof IOException)
      throw (IOException) e.getException();
    throw new IOException("XML writing problem: " + e.toString());
  }
}
 
源代码15 项目: Bytecoder   文件: ToUnknownStream.java
private void flush() {
    try {
        if (m_firstTagNotEmitted) {
            emitFirstTag();
        }
        if (m_needToCallStartDocument) {
            m_handler.startDocument();
            m_needToCallStartDocument = false;
        }
    } catch(SAXException e) {
        throw new RuntimeException(e.toString());
    }
}
 
源代码16 项目: Onosendai   文件: SuccessWhale.java
@Override
public List<ServiceRef> handleResponse (final HttpResponse response) throws IOException {
	checkReponseCode(response);
	try {
		final byte[] data = EntityUtils.toByteArray(response.getEntity());
		final List<ServiceRef> accounts = new PostToAccountsXml(new ByteArrayInputStream(data)).getAccounts();
		if (this.sw != null) this.sw.writePostToAccountsToCache(new String(data, Charset.forName("UTF-8")));
		return accounts;
	}
	catch (final SAXException e) {
		throw new IOException("Failed to parse response: " + e.toString(), e);
	}
}
 
源代码17 项目: annotation-tools   文件: SAXAdapter.java
protected final void addEnd(String name) {
    try {
        h.endElement("", name, name);
    } catch (SAXException ex) {
        throw new RuntimeException(ex.toString());
    }
}
 
源代码18 项目: lams   文件: WebResponse.java
public HTMLPage.Scriptable getDocument() {
    try {
        if (!isHTML()) replaceText( BLANK_HTML, HTML_CONTENT );
        return getReceivedPage().getScriptableObject();
    } catch (SAXException e) {
        throw new RuntimeException( e.toString() );
    }
}
 
源代码19 项目: annotation-tools   文件: SAXAdapter.java
protected final void addStart(String name, Attributes attrs) {
    try {
        h.startElement("", name, name, attrs);
    } catch (SAXException ex) {
        throw new RuntimeException(ex.toString());
    }
}
 
源代码20 项目: uima-uimaj   文件: PMUimaAgent.java
/**
 * Saves a given UIMA aggregate component desciption in a specified XML descriptor file.
 * 
 * @param aggDescription
 *          The given UIMA aggregate component desciption.
 * @param aggDescFile
 *          The given XML descriptor file.
 * @throws IOException
 *           If an I/O exception occurrs.
 */
static void saveAggregateDescription(AnalysisEngineDescription aggDescription, File aggDescFile)
        throws IOException {
  try (Writer fWriter = new FileWriter(aggDescFile)) {
    aggDescription.toXML(fWriter);
  } catch (SAXException exc) {
    throw new IOException(exc.toString());
  }
}