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


Java SAXException.toString方法代碼示例

本文整理匯總了Java中org.xml.sax.SAXException.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXException.toString方法的具體用法?Java SAXException.toString怎麽用?Java SAXException.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xml.sax.SAXException的用法示例。


在下文中一共展示了SAXException.toString方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: load

import org.xml.sax.SAXException; //導入方法依賴的package包/類
public static SyntaxScheme load(Font baseFont, InputStream in)
		throws IOException {
	SyntaxSchemeLoader parser = null;
	try {
		XMLReader reader = XMLReaderFactory.createXMLReader();
		parser = new SyntaxSchemeLoader(baseFont);
		parser.baseFont = baseFont;
		reader.setContentHandler(parser);
		InputSource is = new InputSource(in);
		is.setEncoding("UTF-8");
		reader.parse(is);
	} catch (SAXException se) {
		throw new IOException(se.toString());
	}
	return parser.scheme;
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:17,代碼來源:SyntaxScheme.java

示例2: parse

import org.xml.sax.SAXException; //導入方法依賴的package包/類
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);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:TrAXFilter.java

示例3: flush

import org.xml.sax.SAXException; //導入方法依賴的package包/類
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());
    }


}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:ToUnknownStream.java

示例4: test

import org.xml.sax.SAXException; //導入方法依賴的package包/類
@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));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:BadExceptionMessageTest.java

示例5: testException

import org.xml.sax.SAXException; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:Bug6889654Test.java

示例6: getDocument

import org.xml.sax.SAXException; //導入方法依賴的package包/類
public HTMLPage.Scriptable getDocument() {
    try {
        if (!isHTML()) replaceText( BLANK_HTML, HTML_CONTENT );
        return getReceivedPage().getScriptableObject();
    } catch (SAXException e) {
        throw new RuntimeException( e.toString() );
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:WebResponse.java

示例7: loadFromXML

import org.xml.sax.SAXException; //導入方法依賴的package包/類
/**
 * Loads completions from an XML input stream.  The XML should validate
 * against <code>CompletionXml.dtd</code>.
 *
 * @param in The input stream to read from.
 * @param cl The class loader to use when loading any extra classes defined
 *        in the XML, such as custom {@link FunctionCompletion}s.  This
 *        may be <code>null</code> if the default is to be used, or if no
 *        custom completions are defined in the XML.
 * @throws IOException If an IO error occurs.
 */
public void loadFromXML(InputStream in, ClassLoader cl) throws IOException {

	//long start = System.currentTimeMillis();

	SAXParserFactory factory = SAXParserFactory.newInstance();
	factory.setValidating(true);
	CompletionXMLParser handler = new CompletionXMLParser(this, cl);
	BufferedInputStream bin = new BufferedInputStream(in);
	try {
		SAXParser saxParser = factory.newSAXParser();
		saxParser.parse(bin, handler);
		List<Completion> completions =  handler.getCompletions();
		addCompletions(completions);
		char startChar = handler.getParamStartChar();
		if (startChar!=0) {
			char endChar = handler.getParamEndChar();
			String sep = handler.getParamSeparator();
			if (endChar!=0 && sep!=null && sep.length()>0) { // Sanity
				setParameterizedCompletionParams(startChar, sep, endChar);
			}
		}
	} catch (SAXException se) {
		throw new IOException(se.toString());
	} catch (ParserConfigurationException pce) {
		throw new IOException(pce.toString());
	} finally {
		//long time = System.currentTimeMillis() - start;
		//System.out.println("XML loaded in: " + time + "ms");
		bin.close();
	}

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:44,代碼來源:DefaultCompletionProvider.java

示例8: flush

import org.xml.sax.SAXException; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:ToUnknownStream.java


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