本文整理汇总了Java中org.xml.sax.SAXParseException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SAXParseException.getMessage方法的具体用法?Java SAXParseException.getMessage怎么用?Java SAXParseException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.SAXParseException
的用法示例。
在下文中一共展示了SAXParseException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSpecification
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
public void testSpecification() throws Exception {
try {
String filename = "test/data/specification.xml";
Validator validator = buildValidator("schema/specification-schema.xsd");
FileOutputStream fos = new FileOutputStream(filename);
try (FreeColXMLWriter xw = new FreeColXMLWriter(fos, null, false)) {
spec().toXML(xw);
} catch (IOException ioe) {
fail(ioe.getMessage());
}
validator.validate(new StreamSource(new FileReader(filename)));
} catch (SAXParseException e) {
String errMsg = e.getMessage()
+ " at line=" + e.getLineNumber()
+ " column=" + e.getColumnNumber();
fail(errMsg);
}
}
示例2: testStringTemplate
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
public void testStringTemplate() throws Exception {
StringTemplate t1 = StringTemplate.template("model.goods.goodsAmount")
.add("%goods%", "model.goods.food.name")
.addName("%amount%", "100");
StringTemplate t2 = StringTemplate.template("model.goods.goodsAmount")
.addAmount("%amount%", 50)
.addStringTemplate("%goods%", t1);
Game game = getGame();
Player player = game.getPlayerByNationId("model.nation.dutch");
try {
Validator validator = buildValidator("schema/data/data-stringTemplate.xsd");
validator.validate(buildSource(t2));
} catch (SAXParseException e){
String errMsg = e.getMessage()
+ " at line=" + e.getLineNumber()
+ " column=" + e.getColumnNumber();
fail(errMsg);
}
}
示例3: propagateEvent
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
示例4: createXMLParseException
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
/** Creates an XMLParseException from a SAXParseException. */
protected static XMLParseException createXMLParseException(SAXParseException exception) {
final String fPublicId = exception.getPublicId();
final String fExpandedSystemId = exception.getSystemId();
final int fLineNumber = exception.getLineNumber();
final int fColumnNumber = exception.getColumnNumber();
XMLLocator location = new XMLLocator() {
public String getPublicId() { return fPublicId; }
public String getExpandedSystemId() { return fExpandedSystemId; }
public String getBaseSystemId() { return null; }
public String getLiteralSystemId() { return null; }
public int getColumnNumber() { return fColumnNumber; }
public int getLineNumber() { return fLineNumber; }
public int getCharacterOffset() { return -1; }
public String getEncoding() { return null; }
public String getXMLVersion() { return null; }
};
return new XMLParseException(location, exception.getMessage(),exception);
}
示例5: error
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
public void error(SAXParseException e) throws SAXException {
if (errorCount >= ERROR_COUNT_LIMIT) {
// Ignore all errors after reaching the limit
return;
} else if (errorCount == 0) {
// Print a warning before the first error
System.err.println(SAXMessageFormatter.formatMessage(locale,
"errorHandlerNotSet", new Object [] {errorCount}));
}
String systemId = e.getSystemId();
if (systemId == null) {
systemId = "null";
}
String message = "Error: URI=" + systemId +
" Line=" + e.getLineNumber() +
": " + e.getMessage();
System.err.println(message);
errorCount++;
}
示例6: warning
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
/**
* NOT YET DOCUMENTED
*
* @param exception NOT YET DOCUMENTED
* @exception SAXException NOT YET DOCUMENTED
*/
public void warning(SAXParseException exception) throws SAXException {
String msg = exception.getMessage();
int startIndex = msg.indexOf(":");
startIndex = (startIndex >= 0 ? startIndex : 0);
appendResult("Warning : " + msg.substring(startIndex));
}
示例7: getParseExceptionInfo
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
private String getParseExceptionInfo(SAXParseException spe) {
String systemId = spe.getSystemId();
if (systemId == null) {
systemId = "null";
}
String info = "Catalog URI=" + systemId + " Line=" + spe.getLineNumber() + ": " + spe.getMessage();
return info;
}
示例8: fatalError
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
public void fatalError(SAXParseException exception)
{
String message = "Parser error: " + exception.getMessage();
message += ", line " + exception.getLineNumber();
message += ", column " + exception.getColumnNumber();
fail(message);
}
示例9: doError
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
private void doError(SAXParseException e, ParserNotice.Level level) {
int line = e.getLineNumber() - 1;
Element root = doc.getDefaultRootElement();
Element elem = root.getElement(line);
int offs = elem.getStartOffset();
int len = elem.getEndOffset() - offs;
if (line==root.getElementCount()-1) {
len++;
}
DefaultParserNotice pn = new DefaultParserNotice(XmlParser.this,
e.getMessage(), line, offs, len);
pn.setLevel(level);
result.addNotice(pn);
}
示例10: validateMap
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
private void validateMap(String name) throws Exception {
try {
Validator mapValidator = buildValidator("schema/data/data-savedGame.xsd");
FreeColSavegameFile mapFile = new FreeColSavegameFile(new File(name));
mapValidator.validate(new StreamSource(mapFile.getSavegameInputStream()));
} catch (SAXParseException e) {
String errMsg = e.getMessage()
+ " at line=" + e.getLineNumber()
+ " column=" + e.getColumnNumber();
fail(errMsg);
}
}
示例11: logParseFailure
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
private void logParseFailure(SAXParseException e, String serialized) {
int col = e.getColumnNumber();
String errMsg = e.getMessage()
+ "\nAt line=" + e.getLineNumber()
+ ", column=" + col + ":\n"
+ serialized.substring(Math.max(0, col - 100),
Math.min(col + 100, serialized.length()));
fail(errMsg);
}
示例12: testValidation
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
public void testValidation() throws Exception {
Game game = ServerTestHelper.startServerGame(getTestMap(true));
Colony colony = getStandardColony(6);
Player player = game.getPlayerByNationId("model.nation.dutch");
ServerTestHelper.newTurn();
ServerTestHelper.newTurn();
String serialized = null;
try {
Validator validator = buildValidator("schema/data/data-game.xsd");
serialized = game.serialize();
validator.validate(new StreamSource(new StringReader(serialized)));
} catch (SAXParseException e) {
int col = e.getColumnNumber();
String errMsg = e.getMessage()
+ "\nAt line=" + e.getLineNumber()
+ ", column=" + col + ":\n";
if (serialized != null) {
errMsg += serialized.substring(Math.max(0, col - 100),
Math.min(col + 100, serialized.length()));
}
fail(errMsg);
}
ServerTestHelper.stopServerGame();
}
示例13: getParseExceptionInfo
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
/**
* Returns a string describing parse exception details.
*
* @param poParseException exception to get info from
* @return string representation of the info
*/
private String getParseExceptionInfo(SAXParseException poParseException) {
String strSystemId = poParseException.getSystemId();
if (strSystemId == null) {
strSystemId = "null";
}
String strErrInfo =
"URI=" + strSystemId +
" Line=" + poParseException.getLineNumber() +
": " + poParseException.getMessage();
return strErrInfo;
}
示例14: fatalError
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
/**
* Write fatalError tag along with exception to the file when meet
* unrecoverable error event.
* @throws IOException error happen when writing file.
*/
@Override
public void fatalError(SAXParseException e) throws SAXException {
String str = "In fatalError..\nSAXParseException: " + e.getMessage();
try {
bWriter.write( str, 0,str.length());
bWriter.newLine();
} catch (IOException ex) {
throw new SAXException(ex);
}
}
示例15: error
import org.xml.sax.SAXParseException; //导入方法依赖的package包/类
/**
* Throws back the exception with the name of the XML file and the position where the exception
* occurred.
*/
@Override
public void error(final SAXParseException exception) throws SAXException {
throw new SAXParseException("Error while parsing XML at line " + exception.getLineNumber()
+ " column " + exception.getColumnNumber() + ": " + exception.getMessage(), null,
exception);
}