Package com.apicatalog.rdf.nquads
Class NQuadsTokenizer
- java.lang.Object
-
- com.apicatalog.rdf.nquads.NQuadsTokenizer
-
public class NQuadsTokenizer extends java.lang.ObjectA tokenizer for parsing N-Quads data streams according to the N-Quads Grammar.This class reads an input stream character by character and extracts tokens representing RDF terms, literals, and syntax elements in the N-Quads format. It supports whitespace handling, comments, and various escape sequences.
Usage example:
Reader reader = new FileReader("data.nq"); NQuadsTokenizer tokenizer = new NQuadsTokenizer(reader); while (tokenizer.hasNext()) { Token token = tokenizer.next(); System.out.println(token); }- See Also:
- RDF 1.1 N-Quads Specification
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNQuadsTokenizer.Tokenstatic classNQuadsTokenizer.TokenType
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZEprotected NQuadsTokenizer.Tokennextprotected java.io.Readerreader
-
Constructor Summary
Constructors Constructor Description NQuadsTokenizer(java.io.Reader reader)NQuadsTokenizer(java.io.Reader reader, int bufferSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(NQuadsTokenizer.TokenType type)protected NQuadsTokenizer.TokendoRead()booleanhasNext()NQuadsTokenizer.Tokennext()protected NQuadsTokenizer.TokenreadBlankNode()protected NQuadsTokenizer.TokenreadComment()protected voidreadEscape(java.lang.StringBuilder value)protected charreadHex8()protected voidreadIriEscape(java.lang.StringBuilder value)protected NQuadsTokenizer.TokenreadIriRef()protected NQuadsTokenizer.TokenreadLangTag()protected NQuadsTokenizer.TokenreadString()protected char[]readUnicode()protected char[]readUnicode64()protected NQuadsTokenizer.TokenskipEol()protected NQuadsTokenizer.TokenskipWhitespaces()NQuadsTokenizer.Tokentoken()protected static intunescape(int symbol)protected static voidunexpected(int actual, java.lang.String... expected)
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
reader
protected final java.io.Reader reader
-
next
protected NQuadsTokenizer.Token next
-
-
Method Detail
-
hasNext
public boolean hasNext() throws NQuadsReaderException- Throws:
NQuadsReaderException
-
next
public NQuadsTokenizer.Token next() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
token
public NQuadsTokenizer.Token token() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
accept
public boolean accept(NQuadsTokenizer.TokenType type) throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
doRead
protected NQuadsTokenizer.Token doRead() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
unexpected
protected static final void unexpected(int actual, java.lang.String... expected) throws NQuadsReaderException- Throws:
NQuadsReaderException
-
skipWhitespaces
protected NQuadsTokenizer.Token skipWhitespaces() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
skipEol
protected NQuadsTokenizer.Token skipEol() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
readIriRef
protected NQuadsTokenizer.Token readIriRef() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
readString
protected NQuadsTokenizer.Token readString() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
readLangTag
protected NQuadsTokenizer.Token readLangTag() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
readIriEscape
protected void readIriEscape(java.lang.StringBuilder value) throws NQuadsReaderException, java.io.IOException- Throws:
NQuadsReaderExceptionjava.io.IOException
-
readEscape
protected void readEscape(java.lang.StringBuilder value) throws NQuadsReaderException, java.io.IOException- Throws:
NQuadsReaderExceptionjava.io.IOException
-
readBlankNode
protected NQuadsTokenizer.Token readBlankNode() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
readUnicode
protected char[] readUnicode() throws NQuadsReaderException, java.io.IOException- Throws:
NQuadsReaderExceptionjava.io.IOException
-
readHex8
protected char readHex8() throws java.io.IOException, NQuadsReaderException- Throws:
java.io.IOExceptionNQuadsReaderException
-
readUnicode64
protected char[] readUnicode64() throws java.io.IOException, NQuadsReaderException- Throws:
java.io.IOExceptionNQuadsReaderException
-
unescape
protected static final int unescape(int symbol)
-
readComment
protected NQuadsTokenizer.Token readComment() throws NQuadsReaderException
- Throws:
NQuadsReaderException
-
-