Class RdfTurtleReader
- java.lang.Object
-
- org.restlet.ext.rdf.internal.RdfReader
-
- org.restlet.ext.rdf.internal.ntriples.RdfNTriplesReader
-
- org.restlet.ext.rdf.internal.turtle.RdfTurtleReader
-
- Direct Known Subclasses:
RdfN3Reader
public class RdfTurtleReader extends RdfNTriplesReader
Handler of RDF content according to the RDF Turtle notation.
-
-
Field Summary
Fields Modifier and Type Field Description private intblankNodeIdIncrement used to identify inner blank nodes.private ContextcontextThe current context object.-
Fields inherited from class org.restlet.ext.rdf.internal.ntriples.RdfNTriplesReader
EOF
-
-
Constructor Summary
Constructors Constructor Description RdfTurtleReader(Representation rdfN3Representation, GraphHandler graphHandler)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidgenerateLinks(java.util.List<LexicalUnit> lexicalUnits)Loops over the given list of lexical units and generates the adequat calls to link* methods.protected ContextgetContext()Returns the current context.private ReferencegetPredicate(LexicalUnit lexicalUnit)Returns the given lexical unit as a predicate.protected booleanisDelimiter(int c)Returns true if the given character is a delimiter.protected voidlink(java.lang.Object source, Reference typeRef, java.lang.Object target)Callback method used when a link is parsed or written.protected java.lang.StringnewBlankNodeId()Returns the identifier of a new blank node.voidparse()Parses the current representation.protected voidparseBlankNode(BlankNodeToken blankNode)Parse the given blank node.protected voidparseDirective(Context context)Parse the current directive and update the context according to the kind of directive ("base", "prefix", etc).protected voidparseList(ListToken listToken)Parse the given list token.protected voidparseStatement(Context context)Reads the current statement until its end, and parses it.protected voidparseString(StringToken stringToken)Parse the given String token.protected voidparseToken(Token token)Parses the given token.protected voidparseUri(UriToken uriToken)Parses the given URI token.-
Methods inherited from class org.restlet.ext.rdf.internal.ntriples.RdfNTriplesReader
consumeStatement, consumeWhiteSpaces, discard, getChar, getCurrentToken, getParsingMessage, getParsingMessage, isAlphaNum, isEndOfFile, isWhiteSpace, parseComment, parseStatement, parseToken, parseUri, step, step, stepBack, stepBack
-
Methods inherited from class org.restlet.ext.rdf.internal.RdfReader
getGraphHandler, getRdfRepresentation
-
-
-
-
Field Detail
-
blankNodeId
private int blankNodeId
Increment used to identify inner blank nodes.
-
context
private Context context
The current context object.
-
-
Constructor Detail
-
RdfTurtleReader
public RdfTurtleReader(Representation rdfN3Representation, GraphHandler graphHandler) throws java.io.IOException
Constructor.- Parameters:
rdfRepresentation- The representation to read.graphHandler- The graph handler invoked during the parsing.- Throws:
java.io.IOException
-
-
Method Detail
-
generateLinks
protected void generateLinks(java.util.List<LexicalUnit> lexicalUnits)
Loops over the given list of lexical units and generates the adequat calls to link* methods.- Parameters:
lexicalUnits- The list of lexical units used to generate the links.- See Also:
GraphHandler.link(Graph, Reference, Reference),GraphHandler.link(Reference, Reference, Literal),GraphHandler.link(Reference, Reference, Reference)
-
getContext
protected Context getContext()
Returns the current context.- Returns:
- The current context.
-
getPredicate
private Reference getPredicate(LexicalUnit lexicalUnit)
Returns the given lexical unit as a predicate.- Parameters:
lexicalUnit- The lexical unit to get as a predicate.- Returns:
- A RDF URI reference of the predicate.
-
isDelimiter
protected boolean isDelimiter(int c)
Returns true if the given character is a delimiter.- Overrides:
isDelimiterin classRdfNTriplesReader- Parameters:
c- The given character to check.- Returns:
- true if the given character is a delimiter.
-
link
protected void link(java.lang.Object source, Reference typeRef, java.lang.Object target)Callback method used when a link is parsed or written.- Parameters:
source- The source or subject of the link.typeRef- The type reference of the link.target- The target or object of the link.
-
newBlankNodeId
protected java.lang.String newBlankNodeId()
Returns the identifier of a new blank node.- Returns:
- The identifier of a new blank node.
-
parse
public void parse() throws java.io.IOExceptionParses the current representation.- Overrides:
parsein classRdfNTriplesReader- Throws:
java.io.IOException
-
parseBlankNode
protected void parseBlankNode(BlankNodeToken blankNode) throws java.io.IOException
Parse the given blank node.- Parameters:
blankNode- The blank node to parse.- Throws:
java.io.IOException
-
parseDirective
protected void parseDirective(Context context) throws java.io.IOException
Parse the current directive and update the context according to the kind of directive ("base", "prefix", etc).- Parameters:
context- The context to update.- Throws:
java.io.IOException
-
parseList
protected void parseList(ListToken listToken) throws java.io.IOException
Parse the given list token.- Parameters:
listToken- The list token to parse.- Throws:
java.io.IOException
-
parseStatement
protected void parseStatement(Context context) throws java.io.IOException
Reads the current statement until its end, and parses it.- Parameters:
context- The current context.- Throws:
java.io.IOException
-
parseString
protected void parseString(StringToken stringToken) throws java.io.IOException
Parse the given String token.- Parameters:
stringToken- The String token to parse.- Throws:
java.io.IOException
-
parseToken
protected void parseToken(Token token) throws java.io.IOException
Parses the given token.- Parameters:
token- The token to parse.- Throws:
java.io.IOException
-
parseUri
protected void parseUri(UriToken uriToken) throws java.io.IOException
Parses the given URI token.- Parameters:
token- The URI token to parse.- Throws:
java.io.IOException
-
-