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 RDFFormat
format()
The format this parser can parsevoid
parse(java.io.InputStream theStream, RDFHandler theHandler, Options theOptions)
Parse the contentprotected void
parseBase(IOParserContext theContext)
protected Resource
parseCollection(TurtleParserContext theContext)
protected boolean
parseDirective(TurtleParserContext theContext, java.lang.String directive)
protected Statement
parseEmbeddedTriple(IOParserContext theContext)
Parse an embedded triple, allowing subsequent predicate-object pairs to annotate this statement.protected Resource
parseImplicitBlank(TurtleParserContext theContext)
protected java.lang.String
parseLongString(IOParserContext theContext, int closingCharacter)
protected BNode
parseNodeID(IOParserContext theContext)
protected Literal
parseNumber(IOParserContext theContext)
protected void
parseObject(TurtleParserContext theContext)
protected void
parseObjectList(TurtleParserContext theContext)
protected IRI
parsePredicate(IOParserContext theContext)
protected void
parsePredicateObjectList(TurtleParserContext theContext)
protected IRI
parsePredicateWithEdgeProperties(TurtleParserContext theContext)
protected void
parsePrefixID(IOParserContext theContext)
protected Value
parseQNameOrBoolean(IOParserContext theContext)
protected Literal
parseQuotedLiteral(IOParserContext theContext)
protected java.lang.String
parseQuotedString(IOParserContext theContext)
protected void
parseStatement(TurtleParserContext theContext)
protected java.lang.String
parseString(IOParserContext theContext, int closingCharacter)
protected void
parseSubject(TurtleParserContext theContext)
protected Resource
parseSubjectResource(IOParserContext theContext)
protected void
parseTriples(TurtleParserContext theContext)
protected IRI
parseURI(IOParserContext theContext)
protected Value
parseValue(IOParserContext theContext)
protected void
processComment(IOParserContext theContext)
protected int
skipWSC(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.IOException
Parse the content
-
parseStatement
protected void parseStatement(TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
parseTriples
protected void parseTriples(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
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.IOException
InvalidRDF
RDFHandlerException
-
parsePredicateObjectList
protected void parsePredicateObjectList(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
parsePredicateWithEdgeProperties
protected IRI parsePredicateWithEdgeProperties(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parsePredicate
protected IRI parsePredicate(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseObjectList
protected void parseObjectList(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
parseSubject
protected void parseSubject(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
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.IOException
InvalidRDF
RDFHandlerException
-
parseCollection
protected Resource parseCollection(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
parseImplicitBlank
protected Resource parseImplicitBlank(@Nonnull TurtleParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
parseValue
protected Value parseValue(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseURI
protected IRI parseURI(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseQNameOrBoolean
protected Value parseQNameOrBoolean(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseNodeID
protected BNode parseNodeID(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseQuotedLiteral
protected Literal parseQuotedLiteral(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseQuotedString
protected java.lang.String parseQuotedString(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseString
protected java.lang.String parseString(@Nonnull IOParserContext theContext, int closingCharacter) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseLongString
protected java.lang.String parseLongString(@Nonnull IOParserContext theContext, int closingCharacter) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
parseNumber
protected Literal parseNumber(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF
- Throws:
java.io.IOException
InvalidRDF
-
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.IOException
InvalidRDF
RDFHandlerException
-
parseBase
protected void parseBase(@Nonnull IOParserContext theContext) throws java.io.IOException, InvalidRDF, RDFHandlerException
- Throws:
java.io.IOException
InvalidRDF
RDFHandlerException
-
skipWSC
protected int skipWSC(IOParserContext theContext) throws RDFHandlerException, java.io.IOException
- Throws:
RDFHandlerException
java.io.IOException
-
processComment
protected void processComment(IOParserContext theContext) throws RDFHandlerException, java.io.IOException
- Throws:
RDFHandlerException
java.io.IOException
-
-