Class RdfNTriplesReader
- java.lang.Object
-
- org.restlet.ext.rdf.internal.RdfReader
-
- org.restlet.ext.rdf.internal.ntriples.RdfNTriplesReader
-
- Direct Known Subclasses:
RdfTurtleReader
public class RdfNTriplesReader extends RdfReader
Handler of RDF content according to the N-Triples notation.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.BufferedReaderbrInternal buffered reader.private char[]bufferThe reading buffer.private intBUFFER_SIZESize of the reading buffer.intEOFEnd of reading buffer marker.private intscoutIndexIndex that discovers the end of the current token and the beginning of the futur one.private intstartTokenIndexStart index of current lexical unit.
-
Constructor Summary
Constructors Constructor Description RdfNTriplesReader(Representation rdfRepresentation, GraphHandler graphHandler)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconsumeStatement()Discard all read characters until the end of the statement is reached (marked by a '.').protected voidconsumeWhiteSpaces()Discard all read characters.protected voiddiscard()Discard all read characters.protected chargetChar()Returns the current parsed character.protected java.lang.StringgetCurrentToken()Returns the current token.java.lang.StringgetParsingMessage()Returns a message describing the current state of the parsing process.protected java.lang.StringgetParsingMessage(char[] buffer, int startTokenIndex, int scoutIndex)Returns a message describing the current state of the parsing process.protected booleanisAlphaNum(int c)Returns true if the given character is alphanumeric.protected booleanisDelimiter(int c)Returns true if the given character is a delimiter.protected booleanisEndOfFile(int c)protected booleanisWhiteSpace(int c)Returns true if the given character is a whitespace.voidparse()Parses the current representation.protected voidparseComment()Parses a comment.protected voidparseStatement()Reads the current statement until its end, and parses it.protected java.lang.StringparseToken()Returns the value of the current token.protected java.lang.StringparseUri()Returns the value of the current URI.protected intstep()Read a new character.protected voidstep(int n)Steps forward.protected voidstepBack()Steps back of one step.protected voidstepBack(int n)Steps back.-
Methods inherited from class org.restlet.ext.rdf.internal.RdfReader
getGraphHandler, getRdfRepresentation
-
-
-
-
Field Detail
-
br
private java.io.BufferedReader br
Internal buffered reader.
-
buffer
private final char[] buffer
The reading buffer.
-
BUFFER_SIZE
private final int BUFFER_SIZE
Size of the reading buffer.- See Also:
- Constant Field Values
-
EOF
public final int EOF
End of reading buffer marker.- See Also:
- Constant Field Values
-
scoutIndex
private int scoutIndex
Index that discovers the end of the current token and the beginning of the futur one.
-
startTokenIndex
private int startTokenIndex
Start index of current lexical unit.
-
-
Constructor Detail
-
RdfNTriplesReader
public RdfNTriplesReader(Representation rdfRepresentation, 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
-
consumeStatement
protected void consumeStatement() throws java.io.IOExceptionDiscard all read characters until the end of the statement is reached (marked by a '.').- Throws:
java.io.IOException
-
consumeWhiteSpaces
protected void consumeWhiteSpaces() throws java.io.IOExceptionDiscard all read characters. A call togetCurrentToken()will return a single character.- Throws:
java.io.IOException
-
discard
protected void discard()
Discard all read characters. A call togetCurrentToken()will return a single character.
-
getChar
protected char getChar()
Returns the current parsed character.- Returns:
- The current parsed character.
-
getCurrentToken
protected java.lang.String getCurrentToken()
Returns the current token.- Returns:
- The current token.
-
getParsingMessage
public java.lang.String getParsingMessage()
Returns a message describing the current state of the parsing process.- Returns:
- A message describing the current state of the parsing process.
-
getParsingMessage
protected java.lang.String getParsingMessage(char[] buffer, int startTokenIndex, int scoutIndex)Returns a message describing the current state of the parsing process.- Parameters:
buffer- The current buffer.startTokenIndex- The start index of parsing.scoutIndex- The index of the probable future token.- Returns:
-
isAlphaNum
protected boolean isAlphaNum(int c)
Returns true if the given character is alphanumeric.- Parameters:
c- The given character to check.- Returns:
- true if the given character is alphanumeric.
-
isDelimiter
protected boolean isDelimiter(int c)
Returns true if the given character is a delimiter.- Parameters:
c- The given character to check.- Returns:
- true if the given character is a delimiter.
-
isEndOfFile
protected boolean isEndOfFile(int c)
-
isWhiteSpace
protected boolean isWhiteSpace(int c)
Returns true if the given character is a whitespace.- Parameters:
c- The given character to check.- Returns:
- true if the given character is a whitespace.
-
parse
public void parse() throws java.io.IOExceptionParses the current representation.
-
parseComment
protected void parseComment() throws java.io.IOExceptionParses a comment.- Throws:
java.io.IOException
-
parseStatement
protected void parseStatement() throws java.io.IOExceptionReads the current statement until its end, and parses it.- Parameters:
context- The current context.- Throws:
java.io.IOException
-
parseToken
protected java.lang.String parseToken() throws java.io.IOExceptionReturns the value of the current token.- Returns:
- The value of the current token.
- Throws:
java.io.IOException
-
parseUri
protected java.lang.String parseUri() throws java.io.IOExceptionReturns the value of the current URI.- Returns:
- The value of the current URI.
- Throws:
java.io.IOException
-
step
protected int step() throws java.io.IOExceptionRead a new character.- Returns:
- The new read character.
- Throws:
java.io.IOException
-
step
protected void step(int n) throws java.io.IOExceptionSteps forward.- Parameters:
n- The number of steps to go forward.- Throws:
java.io.IOException
-
stepBack
protected void stepBack()
Steps back of one step.
-
stepBack
protected void stepBack(int n)
Steps back.- Parameters:
n- The number of steps to go back.
-
-