本文整理汇总了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;
}
示例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);
}
}
}
示例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());
}
}
示例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));
}
示例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);
}
}
示例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() );
}
}
示例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();
}
}
示例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());
}
}