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


Java SAXParseException.getLineNumber方法代碼示例

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


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

示例1: 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++;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:DefaultValidationErrorHandler.java

示例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);
        }
    }
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:23,代碼來源:SerializationTest.java

示例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);
    }

}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:21,代碼來源:SerializationTest.java

示例4: 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);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:8,代碼來源:XMLValidityTestCase.java

示例5: 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);
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:10,代碼來源:SerializationTest.java

示例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);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:15,代碼來源:SerializationTest.java

示例7: 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();
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:29,代碼來源:SerializationTest.java

示例8: 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;
}
 
開發者ID:souhaib100,項目名稱:MARF-for-Android,代碼行數:21,代碼來源:NeuralNetwork.java

示例9: getLocationString

import org.xml.sax.SAXParseException; //導入方法依賴的package包/類
/**
 * Returns the human readable string representation of the
 * {@link org.xml.sax.Locator} part of the specified
 * {@link SAXParseException}.
 *
 * @return  non-null valid object.
 */
protected final String getLocationString( SAXParseException e ) {
    if(e.getLineNumber()!=-1 || e.getSystemId()!=null) {
        int line = e.getLineNumber();
        return ModelMessages.CONSOLE_ERROR_REPORTER_LINE_X_OF_Y(line==-1?"?":Integer.toString( line ),
            getShortName( e.getSystemId()));
    } else {
        return ""; //for unkown location just return empty string
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:ErrorReceiver.java

示例10: getLocationString

import org.xml.sax.SAXParseException; //導入方法依賴的package包/類
/**
 * Returns the human readable string representation of the
 * {@link org.xml.sax.Locator} part of the specified
 * {@link SAXParseException}.
 *
 * @return  non-null valid object.
 */
protected final String getLocationString( SAXParseException e ) {
    if(e.getLineNumber()!=-1 || e.getSystemId()!=null) {
        int line = e.getLineNumber();
        return Messages.format( Messages.LINE_X_OF_Y,
            line==-1?"?":Integer.toString( line ),
            getShortName( e.getSystemId() ) );
    } else {
        return Messages.format( Messages.UNKNOWN_LOCATION );
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:ErrorReceiver.java

示例11: 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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:AstroProcessor.java

示例12: 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);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:11,代碼來源:XmlErrorHandler.java

示例13: 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);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:11,代碼來源:XmlErrorHandler.java

示例14: 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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:49,代碼來源:DefaultXMLProcessorDetail.java

示例15: 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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:ValidationEventLocatorImpl.java


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