本文整理了Java中org.openrdf.rio.RDFParseException.getLineNumber
方法的一些代码示例,展示了RDFParseException.getLineNumber
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RDFParseException.getLineNumber
方法的具体详情如下:
包路径:org.openrdf.rio.RDFParseException
类名称:RDFParseException
方法名:getLineNumber
[英]Gets the line number associated with this parse exception.
[中]获取与此分析异常关联的行号。
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
@Test
public void testWrongUnicodeEncodedCharFail()
throws RDFHandlerException, IOException, RDFParseException
{
final ByteArrayInputStream bais = new ByteArrayInputStream(
"<http://s> <http://p> \"\\u123X\" <http://g> .".getBytes());
try {
parser.parse(bais, "http://test.base.uri");
Assert.fail("Expected exception when an incorrect unicode character is included");
}
catch (RDFParseException rdfpe) {
Assert.assertEquals(1, rdfpe.getLineNumber());
// FIXME: Enable column numbers when parser supports them
// Assert.assertEquals(30, rdfpe.getColumnNumber());
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
/**
* Tests the behaviour with non-whitespace characters after a period
* character without a context.
*
* @throws RDFHandlerException
* @throws IOException
* @throws RDFParseException
*/
@Test
public void testNonWhitespaceAfterPeriodNoContext()
throws RDFHandlerException, IOException, RDFParseException
{
final ByteArrayInputStream bais = new ByteArrayInputStream(
"<http://www.wrong.com> <http://wrong.com/1.1/tt> \"x\"^^<http://xxx.net/int> . <http://path.to.graph> ".getBytes());
try {
parser.parse(bais, "http://base-uri");
Assert.fail("Expected exception when there is non-whitespace characters after a period.");
}
catch (RDFParseException rdfpe) {
Assert.assertEquals(1, rdfpe.getLineNumber());
// FIXME: Enable column numbers when parser supports them
// Assert.assertEquals(44, rdfpe.getColumnNumber());
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
/**
* Tests the behaviour with non-whitespace characters after a period
* character without a context.
*
* @throws RDFHandlerException
* @throws IOException
* @throws RDFParseException
*/
@Test
public void testNonWhitespaceAfterPeriodWithContext()
throws RDFHandlerException, IOException, RDFParseException
{
final ByteArrayInputStream bais = new ByteArrayInputStream(
"<http://www.wrong.com> <http://wrong.com/1.1/tt> \"x\"^^<http://xxx.net/int> <http://path.to.graph> . <thisisnotlegal> ".getBytes());
try {
parser.parse(bais, "http://base-uri");
Assert.fail("Expected exception when there is non-whitespace characters after a period.");
}
catch (RDFParseException rdfpe) {
Assert.assertEquals(1, rdfpe.getLineNumber());
// FIXME: Enable column numbers when parser supports them
// Assert.assertEquals(44, rdfpe.getColumnNumber());
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
@Test
public void testStopAtFirstErrorStrictParsing()
throws RDFHandlerException, IOException, RDFParseException
{
final ByteArrayInputStream bais = new ByteArrayInputStream(
("<http://s0> <http://p0> <http://o0> <http://g0> .\n"
+ "<http://sX> .\n" + // Line
// with
// error.
"<http://s1> <http://p1> <http://o1> <http://g1> .\n").getBytes());
parser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, false);
try {
parser.parse(bais, "http://test.base.uri");
Assert.fail("Expected exception when encountering an invalid line");
}
catch (RDFParseException rdfpe) {
Assert.assertEquals(2, rdfpe.getLineNumber());
// Assert.assertEquals(50, rdfpe.getColumnNumber());
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
/**
* Tests N-Quads parsing with literal and datatype using a prefix, which is
* illegal in NQuads, but legal in N3/Turtle that may otherwise look like
* NQuads
*/
@Test
public void testParseBasicLiteralDatatypePrefix()
throws RDFHandlerException, IOException
{
final ByteArrayInputStream bais = new ByteArrayInputStream(
("<http://www.v/dat/4b2-21> " + "<http://www.w3.org/20/ica#dtend> " + "\"2010\"^^xsd:integer "
+ "<http://sin.siteserv.org/def/>.").getBytes());
final TestRDFHandler rdfHandler = new TestRDFHandler();
parser.setRDFHandler(rdfHandler);
try {
parser.parse(bais, "http://test.base.uri");
Assert.fail("Expected exception when passing in a datatype using an N3 style prefix");
}
catch (RDFParseException rdfpe) {
Assert.assertEquals(1, rdfpe.getLineNumber());
// FIXME: Enable column numbers when parser supports them
// Assert.assertEquals(69, rdfpe.getColumnNumber());
}
}
代码示例来源:origin: anno4j/anno4j
logger.warn("Could not load {} {}", url, e.getMessage());
String msg = e.getMessage() + " in " + url;
throw new RDFParseException(msg, e.getLineNumber(), e.getColumnNumber());
} catch (IOException e) {
logger.warn("Could not load {} {}", url, e.getMessage());
代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object
logger.warn("Could not load {} {}", url, e.getMessage());
String msg = e.getMessage() + " in " + url;
throw new RDFParseException(msg, e.getLineNumber(), e.getColumnNumber());
} catch (IOException e) {
logger.warn("Could not load {} {}", url, e.getMessage());
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
@Test
public void testExceptionHandlingWithDefaultSettings()
throws Exception
{
String data = "invalid nt";
RDFParser ntriplesParser = createRDFParser();
ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);
Model model = new LinkedHashModel();
ntriplesParser.setRDFHandler(new StatementCollector(model));
try {
ntriplesParser.parse(new StringReader(data), NTRIPLES_TEST_URL);
fail("expected RDFParseException due to invalid data");
}
catch (RDFParseException expected) {
assertEquals(expected.getLineNumber(), 1);
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-rio-testsuite
@Test
public void testExceptionHandlingWithStopAtFirstError()
throws Exception
{
String data = "invalid nt";
RDFParser ntriplesParser = createRDFParser();
ntriplesParser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES,
Boolean.FALSE);
Model model = new LinkedHashModel();
ntriplesParser.setRDFHandler(new StatementCollector(model));
try {
ntriplesParser.parse(new StringReader(data), NTRIPLES_TEST_URL);
fail("expected RDFParseException due to invalid data");
}
catch (RDFParseException expected) {
assertEquals(expected.getLineNumber(), 1);
}
}
内容来源于网络,如有侵权,请联系作者删除!