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
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 -
Method Summary
Modifier and TypeMethodDescriptionformat()The format this parser can parsevoidparse(InputStream theStream, RDFHandler theHandler, Options theOptions) Parse the contentprotected voidparseBase(IOParserContext theContext) protected ResourceparseCollection(TurtleParserContext theContext) protected booleanparseDirective(TurtleParserContext theContext, String directive) protected StatementparseEmbeddedTriple(IOParserContext theContext) Parse an embedded triple, allowing subsequent predicate-object pairs to annotate this statement.protected ResourceparseImplicitBlank(TurtleParserContext theContext) protected 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 StringparseQuotedString(IOParserContext theContext) protected voidparseStatement(TurtleParserContext theContext) protected 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)
-
Constructor Details
-
TurtleParser
public TurtleParser()
-
-
Method Details
-
format
The format this parser can parse -
parse
public void parse(@Nonnull InputStream theStream, @Nonnull RDFHandler theHandler, @Nonnull Options theOptions) throws IOException Parse the content- Specified by:
parsein interfaceRDFParser- Parameters:
theStream- the stream to read fromtheHandler- the handler to pass parse events totheOptions- the parsing options- Throws:
IOException- if there was an error while reading from the stream
-
parseStatement
protected void parseStatement(TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseTriples
protected void parseTriples(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseEmbeddedTriple
protected Statement parseEmbeddedTriple(IOParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException Parse an embedded triple, allowing subsequent predicate-object pairs to annotate this statement.- Returns:
- the Statement found.
- Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parsePredicateObjectList
protected void parsePredicateObjectList(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parsePredicateWithEdgeProperties
protected IRI parsePredicateWithEdgeProperties(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF - Throws:
IOExceptionInvalidRDF
-
parsePredicate
- Throws:
IOExceptionInvalidRDF
-
parseObjectList
protected void parseObjectList(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseSubject
protected void parseSubject(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseSubjectResource
- Throws:
IOException
-
parseObject
protected void parseObject(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseCollection
protected Resource parseCollection(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseImplicitBlank
protected Resource parseImplicitBlank(@Nonnull TurtleParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseValue
- Throws:
IOExceptionInvalidRDF
-
parseURI
- Throws:
IOExceptionInvalidRDF
-
parseQNameOrBoolean
protected Value parseQNameOrBoolean(@Nonnull IOParserContext theContext) throws IOException, InvalidRDF - Throws:
IOExceptionInvalidRDF
-
parseNodeID
- Throws:
IOExceptionInvalidRDF
-
parseQuotedLiteral
protected Literal parseQuotedLiteral(@Nonnull IOParserContext theContext) throws IOException, InvalidRDF - Throws:
IOExceptionInvalidRDF
-
parseQuotedString
protected String parseQuotedString(@Nonnull IOParserContext theContext) throws IOException, InvalidRDF - Throws:
IOExceptionInvalidRDF
-
parseString
protected String parseString(@Nonnull IOParserContext theContext, int closingCharacter) throws IOException, InvalidRDF - Throws:
IOExceptionInvalidRDF
-
parseLongString
protected String parseLongString(@Nonnull IOParserContext theContext, int closingCharacter) throws IOException, InvalidRDF - Throws:
IOExceptionInvalidRDF
-
parseNumber
- Throws:
IOExceptionInvalidRDF
-
parseDirective
protected boolean parseDirective(TurtleParserContext theContext, String directive) throws IOException - Throws:
IOException
-
parsePrefixID
protected void parsePrefixID(@Nonnull IOParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
parseBase
protected void parseBase(@Nonnull IOParserContext theContext) throws IOException, InvalidRDF, RDFHandlerException - Throws:
IOExceptionInvalidRDFRDFHandlerException
-
skipWSC
- Throws:
RDFHandlerExceptionIOException
-
processComment
- Throws:
RDFHandlerExceptionIOException
-