本文整理匯總了Java中org.xml.sax.SAXParseException.getColumnNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXParseException.getColumnNumber方法的具體用法?Java SAXParseException.getColumnNumber怎麽用?Java SAXParseException.getColumnNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xml.sax.SAXParseException
的用法示例。
在下文中一共展示了SAXParseException.getColumnNumber方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DefaultXMLProcessorDetail
import org.xml.sax.SAXParseException; //導入方法依賴的package包/類
/**
* Create new DefaultXMLProcessorMessage based on SAXParseException.
* @param spex SAX exception to be wrapped (never <code>null</code>).
*/
public DefaultXMLProcessorDetail(SAXParseException spex) {
if (spex == null) throw new NullPointerException();
this.exception = spex;
this.columnNumber = spex.getColumnNumber();
this.lineNumber = spex.getLineNumber();
this.publicId = spex.getPublicId();
this.systemId = spex.getSystemId();
if ( Util.THIS.isLoggable() ) /* then */ {
Util.THIS.debug ("DefaultXMLProcessorDetail: SAXParseException");
Util.THIS.debug (" exception= " + exception);
Util.THIS.debug (" columnNumber= " + columnNumber);
Util.THIS.debug (" lineNumber= " + lineNumber);
Util.THIS.debug (" publicId= " + publicId);
Util.THIS.debug (" systemId= " + systemId);
}
}
示例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: 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);
}
}
示例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: 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);
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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();
}
示例9: 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);
}
示例10: fatalError
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 fatalError(final SAXParseException exception) throws SAXException {
throw new SAXParseException("Fatal error while parsing XML at line " + exception.getLineNumber()
+ " column " + exception.getColumnNumber() + ": " + exception.getMessage(), null,
exception);
}
示例11: tryWrappedLocator
import org.xml.sax.SAXParseException; //導入方法依賴的package包/類
private void tryWrappedLocator(Exception ex) {
if ( Util.THIS.isLoggable() ) /* then */ {
Util.THIS.debug ("DefaultXMLProcessorDetail.tryWrappedLocator: " + ex);
}
// I saw SAXException wrapped in TransformerException and vice versa
Throwable wrapped = null;
if (ex instanceof TransformerException) {
wrapped = ((TransformerException) ex).getException();
} else if (ex instanceof SAXException) {
wrapped = ((SAXException) ex).getException();
} else {
return;
}
// look if wrapped exception does not provide location info
if (wrapped instanceof SAXParseException) {
SAXParseException pex = (SAXParseException) wrapped;
if (pex.getLineNumber() == -1) {
tryWrappedLocator(pex);
} else {
this.columnNumber = pex.getColumnNumber();
this.lineNumber = pex.getLineNumber();
this.publicId = pex.getPublicId();
this.systemId = pex.getSystemId();
}
} else if (wrapped instanceof TransformerException) {
TransformerException wrappedTransformerEx =
(TransformerException) wrapped;
SourceLocator locator = wrappedTransformerEx.getLocator();
if (locator == null) {
tryWrappedLocator(wrappedTransformerEx);
} else {
if (locator.getLineNumber() == -1) {
tryWrappedLocator(wrappedTransformerEx);
} else {
this.columnNumber = locator.getColumnNumber();
this.lineNumber = locator.getLineNumber();
this.publicId = locator.getPublicId();
this.systemId = locator.getSystemId();
}
}
} else if (wrapped instanceof SAXException) {
tryWrappedLocator((SAXException)wrapped);
}
}
示例12: ValidationEventLocatorImpl
import org.xml.sax.SAXParseException; //導入方法依賴的package包/類
/**
* Constructs an object from the location information of a SAXParseException.
*
* The object's ColumnNumber, LineNumber, and URL become available from the
* values returned by the locator's getColumnNumber(), getLineNumber(), and
* getSystemId() methods respectively. Node, Object, and Offset are not
* available.
*
* @param e the SAXParseException object that will be used to populate this
* event locator.
* @throws IllegalArgumentException if the SAXParseException is null
*/
public ValidationEventLocatorImpl( SAXParseException e ) {
if( e == null ) {
throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "e" ) );
}
this.url = toURL(e.getSystemId());
this.columnNumber = e.getColumnNumber();
this.lineNumber = e.getLineNumber();
}