Package com.stardog.stark.io
Class ParserContext
java.lang.Object
com.stardog.stark.io.AbstractRDFHandler
com.stardog.stark.io.ParserContext
- All Implemented Interfaces:
RDFHandler
- Direct Known Subclasses:
IOParserContext
Object to hold the current state of the parsing operation, parsing configuration, and Value creation.
This class can and should be extended by each specific parser to add additional state and functionality for parsing their supported format.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionThe prefix that will be prepended to every bnode identifier be returned by the parser.final booleanlonglongCurrent line number of the inputprotected final com.stardog.stark.impl.NamespacesImpl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new uniqueBNodeobjectcreateBNode(String theNodeID) Creates aBNodeobject for the specified identifier.createLiteral(String label, String lang, IRI datatype) Creates aLiteralobject from parsed information and context.voidend()Notification that processing has finishedIndicates afatal errorvoiderror(String theMsg, ParserContext.ParseError theError) Indicates an error of the given typestatic StringReturns a new randomly generated string to be used as the prefix for bnode identifiers that will be returned by the parser.voidEvent for when a statement was encounteredbooleanvoidEvent for when a namespace was encounteredvoidvoidresolveURI(String theIRISpec) Resolves a URI-string against the base URI and creates aIRIobject for it.voidstart()Notification that the processing has started
-
Field Details
-
BNODE_ID_PREFIX
The prefix that will be prepended to every bnode identifier be returned by the parser. For internal use only. -
caseInsensitiveDirectives
public final boolean caseInsensitiveDirectives -
mNamespaces
protected final com.stardog.stark.impl.NamespacesImpl mNamespaces -
mLineNumber
public long mLineNumberCurrent line number of the input -
mColumnNumber
public long mColumnNumber -
mSubject
-
mPredicate
-
mObject
-
mContext
-
mBaseIRI
-
-
Constructor Details
-
ParserContext
-
-
Method Details
-
resolveURI
Resolves a URI-string against the base URI and creates aIRIobject for it.- Throws:
InvalidRDF
-
is
-
start
public void start()Description copied from class:AbstractRDFHandlerNotification that the processing has started- Specified by:
startin interfaceRDFHandler- Overrides:
startin classAbstractRDFHandler
-
end
public void end()Description copied from class:AbstractRDFHandlerNotification that processing has finished- Specified by:
endin interfaceRDFHandler- Overrides:
endin classAbstractRDFHandler
-
handle
Event for when a statement was encountered- Parameters:
theStatement- the statement
-
namespace
Event for when a namespace was encountered- Specified by:
namespacein interfaceRDFHandler- Overrides:
namespacein classAbstractRDFHandler- Parameters:
thePrefix- the namespace prefixtheIRI- the associated IRI
-
namespace
-
currentStatement
-
reportStatement
public void reportStatement() -
resetStatement
public void resetStatement() -
error
Indicates afatal error- Parameters:
theMsg- the error message- Returns:
- this will always raise an exception
-
error
Indicates an error of the given type- Parameters:
theMsg- the error messagetheError- the type of the error
-
createLiteral
public Literal createLiteral(@Nonnull String label, @Nullable String lang, @Nullable IRI datatype) throws InvalidRDF Creates aLiteralobject from parsed information and context.- Throws:
InvalidRDF
-
createBNode
Creates a new uniqueBNodeobject -
createBNode
Creates aBNodeobject for the specified identifier. -
getRandomBnodeIdPrefix
Returns a new randomly generated string to be used as the prefix for bnode identifiers that will be returned by the parser. It is important that each parsr instance uses a unique prefix or otherwise parsed from different files can be mapped to the same RDF node.
-