org.xml.sax.SAXParseException#getColumnNumber ( )源码实例Demo

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

源代码1 项目: openjdk-8   文件: ErrorHandlerWrapper.java
/** 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);
}
 
源代码2 项目: openjdk-jdk8u   文件: ErrorHandlerWrapper.java
/** 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);
}
 
源代码3 项目: teamengine   文件: ErrorHandlerImpl.java
private void error(String type, SAXParseException e) {
    Logger.print(type);
    if (e.getLineNumber() >= 0) {
        Logger.print(" at line " + e.getLineNumber());
        if (e.getColumnNumber() >= 0) {
            Logger.print(", column " + e.getColumnNumber());
        }
        if (e.getSystemId() != null) {
            Logger.print(" of " + e.getSystemId());
        }
    } else {
        if (e.getSystemId() != null) {
            Logger.print(" in " + e.getSystemId());
        }
    }
    Logger.println(":");
    Logger.println("  " + e.getMessage());
    Logger.flush();
    // System.err.println(type + " at line " + + e.getLineNumber() + ",
    // column " + e.getColumnNumber() + " of " + e.getSystemId() + ":");
    // System.err.println(" " + e.getMessage());
}
 
源代码4 项目: freecol   文件: SerializationTest.java
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);
        }
    }
 
源代码5 项目: dhis2-core   文件: DefaultGmlImportService.java
private String createNotifierErrorMessage( Throwable throwable )
{
    StringBuilder sb = new StringBuilder( "GML import failed: " );

    Throwable rootThrowable = ExceptionUtils.getRootCause( throwable );

    if ( rootThrowable == null )
    {
        rootThrowable = throwable;
    }

    if ( rootThrowable instanceof SAXParseException )
    {
        SAXParseException e = (SAXParseException) rootThrowable;
        sb.append( e.getMessage() );

        if ( e.getLineNumber() >= 0 )
        {
            sb.append( " On line " ).append( e.getLineNumber() );

            if ( e.getColumnNumber() >= 0 )
            {
                sb.append( " column " ).append( e.getColumnNumber() );
            }
        }
    }
    else
    {
        sb.append( rootThrowable.getMessage() );
    }

    if ( sb.charAt( sb.length() - 1 ) != '.' )
    {
        sb.append( '.' );
    }

    return HtmlUtils.htmlEscape( sb.toString() );
}
 
源代码6 项目: maven-jaxb2-plugin   文件: LoggingErrorReceiver.java
private String getMessage(SAXParseException ex) {
	final int row = ex.getLineNumber();
	final int col = ex.getColumnNumber();
	final String sys = ex.getSystemId();
	final String pub = ex.getPublicId();

	return messagePrefix + "Location [" + (sys != null ? " " + sys : "")
			+ (pub != null ? " " + pub : "")
			+ (row > 0 ? "{" + row + (col > 0 ? "," + col : "") + "}" : "")
			+ "].";
}
 
源代码7 项目: gemfirexd-oss   文件: TestUtil.java
/**
 * Throws back the exception with the name of the XML file and the position
 * where the exception occurred.
 */
@Override
public void error(SAXParseException exception) throws SAXException {
  throw new SAXParseException("Error while parsing XML at line "
      + exception.getLineNumber() + " column "
      + exception.getColumnNumber() + ": " + exception.getMessage(), null);
}
 
源代码8 项目: gemfirexd-oss   文件: TestUtil.java
/**
 * Throws back the exception with the name of the XML file and the position
 * where the exception occurred.
 */
@Override
public void fatalError(SAXParseException exception) throws SAXException {
  throw new SAXParseException("Fatal error while parsing XML at line "
      + exception.getLineNumber() + " column "
      + exception.getColumnNumber() + ": " + exception.getMessage(), null);
}
 
源代码9 项目: maven-jaxb2-plugin   文件: LoggingErrorReceiver.java
private String getMessage(SAXParseException ex) {
	final int row = ex.getLineNumber();
	final int col = ex.getColumnNumber();
	final String sys = ex.getSystemId();
	final String pub = ex.getPublicId();

	return messagePrefix + "Location [" + (sys != null ? " " + sys : "")
			+ (pub != null ? " " + pub : "")
			+ (row > 0 ? "{" + row + (col > 0 ? "," + col : "") + "}" : "")
			+ "].";
}
 
源代码10 项目: gemfirexd-oss   文件: XmlErrorHandler.java
/**
 * Throws back the exception with the name of the XML file and the position
 * where the exception occurred.
 */
public void fatalError(SAXParseException exception) throws SAXException {

  throw new SAXParseException("Fatal error while parsing XML at line "
      + exception.getLineNumber() + " column " + exception.getColumnNumber()
      + ": " + exception.getMessage(), null);
}
 
源代码11 项目: swift-k   文件: SiteCatalogParser.java
private void print(SAXParseException e, String header, boolean err) {
    String msg = "[" + header + "] " + src.getName() + ", line " + 
        e.getLineNumber() + ", col " + e.getColumnNumber() + ": " + e.getMessage();
    if (err) {
        System.err.println(msg);
    }
    else {
        System.out.println(msg);
    }
    if (logger.isInfoEnabled()) {
        logger.info(msg);
    }
}
 
源代码12 项目: vespa   文件: SchemaValidator.java
private String message(SAXParseException e) {
    return "XML error in " + fileName + ": " +
            Exceptions.toMessageString(e)
            + " [" + e.getLineNumber() + ":" + e.getColumnNumber() + "]" +
            ", input:\n" + getErrorContext(e.getLineNumber());
}
 
源代码13 项目: netbeans   文件: DefaultXMLProcessorDetail.java
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);
    }
}
 
源代码14 项目: cacheonix-core   文件: CacheonixXsdTest.java
private static SAXException toSAXException(final SAXParseException exception) {

         final SAXException saxException = new SAXException("Line " + exception.getLineNumber() + ':' + exception.getColumnNumber() + ": " + exception.getMessage());
         saxException.setStackTrace(exception.getStackTrace());
         return saxException;
      }
 
源代码15 项目: cxf   文件: SchemaValidator.java
private String getErrorMessage(SAXParseException ex) {
    return "line " + ex.getLineNumber() + " column " + ex.getColumnNumber() + " of " + ex.getSystemId()
            + ": " + ex.getMessage();
}
 
源代码16 项目: TencentKona-8   文件: ValidationEventLocatorImpl.java
/**
 * 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();
}
 
源代码17 项目: openjdk-jdk8u   文件: ValidationEventLocatorImpl.java
/**
 * 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();
}
 
/**
 * 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();
}
 
源代码19 项目: openjdk-jdk9   文件: ValidationEventLocatorImpl.java
/**
 * 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();
}
 
源代码20 项目: codebase   文件: PNMLSerializer.java
/**
 * Creates a detailled error notification!
 * 
 * @param e Exception vom Typ SAXParseException
 * @return Notification containing Line, Column and Error.
 */
private String saxMsg( SAXParseException e ) 
{ 
	return "Line: " + e.getLineNumber() + ", Column: " + e.getColumnNumber() + ", Error: " + e.getMessage(); 
}