Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions jena-arq/src/main/java/org/apache/jena/riot/lang/LangNTriples.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ public final class LangNTriples extends LangNTuple<Triple>
{
private static Logger messageLog = LoggerFactory.getLogger("N-Triples") ;

public LangNTriples(Tokenizer tokens,
ParserProfile profile,
StreamRDF dest)
{
public LangNTriples(Tokenizer tokens, ParserProfile profile, StreamRDF dest) {
super(tokens, profile, dest) ;
}

Expand All @@ -51,19 +48,16 @@ public LangNTriples(Tokenizer tokens,

/** Method to parse the whole stream of triples, sending each to the sink */
@Override
protected final void runParser()
{
while(hasNext())
{
Triple x = parseOne() ;
protected final void runParser() {
while (hasNext()) {
Triple x = parseOne();
if ( x != null )
dest.triple(x) ;
dest.triple(x);
}
}

@Override
protected final Triple parseOne()
{
protected final Triple parseOne() {
Token sToken = nextToken() ;
if ( sToken.isEOF() )
exception(sToken, "Premature end of file: %s", sToken) ;
Expand All @@ -84,10 +78,6 @@ protected final Triple parseOne()

if ( x.getType() != TokenType.DOT )
exception(x, "Triple not terminated by DOT: %s", x) ;
// Node s = X ;
// Node p = X ;
// Node o = X ;
// return T ;

Node s = tokenAsNode(sToken) ;
Node p = tokenAsNode(pToken) ;
Expand All @@ -96,8 +86,7 @@ protected final Triple parseOne()
}

@Override
protected final Node tokenAsNode(Token token)
{
protected final Node tokenAsNode(Token token) {
return profile.create(null, token) ;
}
}
47 changes: 20 additions & 27 deletions jena-arq/src/main/java/org/apache/jena/riot/lang/LangNTuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,19 @@ public abstract class LangNTuple<X> extends LangBase implements Iterator<X>

protected boolean skipOnBadTerm = false ;

protected LangNTuple(Tokenizer tokens,
ParserProfile profile,
StreamRDF dest)
{
super(tokens, profile, dest) ;
protected LangNTuple(Tokenizer tokens, ParserProfile profile, StreamRDF dest) {
super(tokens, profile, dest);
}

// Assumes no syntax errors.
@Override
public final boolean hasNext()
{
return super.moreTokens() ;
public final boolean hasNext() {
return super.moreTokens();
}

@Override
public final X next()
{
return parseOne() ;
public final X next() {
return parseOne();
}

@Override
Expand All @@ -81,30 +76,28 @@ public final void remove()
protected abstract X parseOne() ;

/** Note a tuple not being output */
protected void skipOne(X object, String printForm, long line, long col)
{
profile.getHandler().warning("Skip: "+printForm, line, col) ;
protected void skipOne(X object, String printForm, long line, long col) {
profile.getHandler().warning("Skip: " + printForm, line, col);
}

protected abstract Node tokenAsNode(Token token) ;

protected final void checkIRIOrBNode(Token token)
{
if ( token.hasType(TokenType.IRI) ) return ;
if ( token.hasType(TokenType.BNODE) ) return ;
exception(token, "Expected BNode or IRI: Got: %s", token) ;
protected final void checkIRIOrBNode(Token token) {
if ( token.hasType(TokenType.IRI) )
return;
if ( token.hasType(TokenType.BNODE) )
return;
exception(token, "Expected BNode or IRI: Got: %s", token);
}

protected final void checkIRI(Token token)
{
if ( token.hasType(TokenType.IRI) ) return ;
exception(token, "Expected IRI: Got: %s", token) ;
protected final void checkIRI(Token token) {
if ( token.hasType(TokenType.IRI) )
return;
exception(token, "Expected IRI: Got: %s", token);
}

protected final void checkRDFTerm(Token token)
{
switch(token.getType())
{
protected final void checkRDFTerm(Token token) {
switch (token.getType()) {
case IRI:
case BNODE:
case STRING2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public String resolveIRI(String uriStr, long line, long col) {
public IRI makeIRI(String uriStr, long line, long col) {
// resolves, but we handle the errors and warnings.
IRI iri = prologue.getResolver().resolveSilent(uriStr) ;
if ( uriStr.contains(" ") ) {
// Specific check for spaces.
errorHandler.warning("Bad IRI: <"+uriStr+"> Spaces are not legal in URIs/IRIs.", line, col);
return iri ;
}
// At this point, IRI "errors" are warnings.
CheckerIRI.iriViolations(iri, errorHandler, line, col) ;
return iri ;
}
Expand Down
Loading