Package com.stardog.stark.io.turtle
Class TurtleParser
- java.lang.Object
-
- com.stardog.stark.io.turtle.TurtleParser
-
- All Implemented Interfaces:
RDFParser
- Direct Known Subclasses:
TrigParser
public class TurtleParser extends java.lang.Object implements RDFParser
Default parser for the Turtle RDF syntax
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove, Arjohn Kampman
- Implementation Notes:
- This class is non-final due to reuse of the parser for TriG parsing
-
-
Constructor Summary
Constructors Constructor Description TurtleParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RDFFormatformat()The format this parser can parsevoidparse(java.io.InputStream theStream, RDFHandler theHandler, Options theOptions)Parse the contentprotected voidparseBase(IOParserContext theContext)protected ResourceparseCollection(TurtleParserContext theContext)protected booleanparseDirective(TurtleParserContext theContext, java.lang.String directive)protected StatementparseEmbeddedTriple(IOParserContext theContext)Parse an embedded triple, allowing subsequent predicate-object pairs to annotate this statement.protected ResourceparseImplicitBlank(TurtleParserContext theContext)protected java.lang.StringparseLongString(IOParserContext theContext, int closingCharacter)protected BNodeparseNodeID(IOParserContext theContext)protected LiteralparseNumber(IOParserContext theContext)protected voidparseObject(TurtleParserContext theContext)protected voidparseObjectList(TurtleParserContext theContext)protected IRIparsePredicate(IOParserContext theContext)protected voidparsePredicateObjectList(TurtleParserContext theContext)protected IRIparsePredicateWithEdgeProperties(TurtleParserContext theContext)protected voidparsePrefixID(IOParserContext theContext)protected ValueparseQNameOrBoolean(IOParserContext theContext)protected LiteralparseQuotedLiteral(IOParserContext theContext)protected java.lang.StringparseQuotedString(IOParserContext theContext)protected voidparseStatement(TurtleParserContext theContext)protected java.lang.StringparseString(IOParserContext theContext, int closingCharacter)protected voidparseSubject(TurtleParserContext theContext)protected ResourceparseSubjectResource(IOParserContext theContext)protected voidparseTriples(TurtleParserContext theContext)protected IRIparseURI(IOParserContext theContext)protected ValueparseValue(IOParserContext theContext)protected voidprocessComment(IOParserContext theContext)protected intskipWSC(IOParserContext theContext)
-
-
-
Method Detail
-
format
@Nonnull public RDFFormat format()
The format this parser can parse
-
parse
public void parse(@Nonnull java.io.InputStream theStream, @Nonnull RDFHandler theHandler, @Nonnull Options theOptions) throws java.io.IOExceptionParse the content
-
parseStatement
protected void parseStatement(TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseTriples
protected void parseTriples(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseEmbeddedTriple
protected Statement parseEmbeddedTriple(IOParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
Parse an embedded triple, allowing subsequent predicate-object pairs to annotate this statement.- Returns:
- the Statement found.
- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parsePredicateObjectList
protected void parsePredicateObjectList(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parsePredicateWithEdgeProperties
protected IRI parsePredicateWithEdgeProperties(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parsePredicate
protected IRI parsePredicate(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseObjectList
protected void parseObjectList(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseSubject
protected void parseSubject(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseSubjectResource
protected Resource parseSubjectResource(@Nonnull IOParserContext theContext) throws java.io.IOException
- Throws:
java.io.IOException
-
parseObject
protected void parseObject(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseCollection
protected Resource parseCollection(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseImplicitBlank
protected Resource parseImplicitBlank(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseValue
protected Value parseValue(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseURI
protected IRI parseURI(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseQNameOrBoolean
protected Value parseQNameOrBoolean(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseNodeID
protected BNode parseNodeID(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseQuotedLiteral
protected Literal parseQuotedLiteral(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseQuotedString
protected java.lang.String parseQuotedString(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF- Throws:
java.io.IOExceptionInvalidRDF
-
parseString
protected java.lang.String parseString(@Nonnull IOParserContext theContext, int closingCharacter) throws java.io.IOException, InvalidRDF- Throws:
java.io.IOExceptionInvalidRDF
-
parseLongString
protected java.lang.String parseLongString(@Nonnull IOParserContext theContext, int closingCharacter) throws java.io.IOException, InvalidRDF- Throws:
java.io.IOExceptionInvalidRDF
-
parseNumber
protected Literal parseNumber(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOExceptionInvalidRDF
-
parseDirective
protected boolean parseDirective(TurtleParserContext theContext, java.lang.String directive) throws java.io.IOException
- Throws:
java.io.IOException
-
parsePrefixID
protected void parsePrefixID(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
parseBase
protected void parseBase(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException- Throws:
java.io.IOExceptionInvalidRDFRDFHandlerException
-
skipWSC
protected int skipWSC(IOParserContext theContext) throws RDFHandlerException, java.io.IOException
- Throws:
RDFHandlerExceptionjava.io.IOException
-
processComment
protected void processComment(IOParserContext theContext) throws RDFHandlerException, java.io.IOException
- Throws:
RDFHandlerExceptionjava.io.IOException
-
-