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`

public class ParserContext extends AbstractRDFHandler

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
  Modifier and Type
  Class
  Description
  `static enum`
  `ParserContext.ParseError`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Option<String>`
  `BNODE_ID_PREFIX`
  The prefix that will be prepended to every bnode identifier be returned by the parser.
  `final boolean`
  `caseInsensitiveDirectives`
  `ParsedURI`
  `mBaseIRI`
  `long`
  `mColumnNumber`
  `Resource`
  `mContext`
  `long`
  `mLineNumber`
  Current line number of the input
  `protected final com.stardog.stark.impl.NamespacesImpl`
  `mNamespaces`
  `Value`
  `mObject`
  `IRI`
  `mPredicate`
  `Resource`
  `mSubject`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ParserContext(RDFHandler theHandler, Options theOptions)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `BNode`
  `createBNode()`
  Creates a new unique `BNode` object
  `BNode`
  `createBNode(String theNodeID)`
  Creates a `BNode` object for the specified identifier.
  `Literal`
  `createLiteral(String label, String lang, IRI datatype)`
  Creates a `Literal` object from parsed information and context.
  `Statement`
  `currentStatement()`
  `void`
  `end()`
  Notification that processing has finished
  `InvalidRDF`
  `error(String theMsg)`
  Indicates a `fatal error`
  `void`
  `error(String theMsg, ParserContext.ParseError theError)`
  Indicates an error of the given type
  `static String`
  `getRandomBnodeIdPrefix()`
  Returns a new randomly generated string to be used as the prefix for bnode identifiers that will be returned by the parser.
  `void`
  `handle(Statement theStatement)`
  Event for when a statement was encountered
  `boolean`
  `is(Option<Boolean> theParserOption)`
  `String`
  `namespace(String thePrefix)`
  `void`
  `namespace(String thePrefix, String theIRI)`
  Event for when a namespace was encountered
  `void`
  `reportStatement()`
  `void`
  `resetStatement()`
  `IRI`
  `resolveURI(String theIRISpec)`
  Resolves a URI-string against the base URI and creates a `IRI` object for it.
  `void`
  `start()`
  Notification that the processing has started

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### BNODE_ID_PREFIX

    public static final Option<String> 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 mLineNumber
    Current line number of the input

  - ### mColumnNumber

    public long mColumnNumber

  - ### mSubject

    public Resource mSubject

  - ### mPredicate

    public IRI mPredicate

  - ### mObject

    public Value mObject

  - ### mContext

    public Resource mContext

  - ### mBaseIRI

    public ParsedURI mBaseIRI

- ## Constructor Details

  - ### ParserContext

    public ParserContext(@Nonnull RDFHandler theHandler, @Nonnull Options theOptions)

- ## Method Details

  - ### resolveURI

    @Nonnull public IRI resolveURI(@Nonnull String theIRISpec) throws InvalidRDF
    Resolves a URI-string against the base URI and creates a `IRI` object for it.
    Throws:
      `InvalidRDF`

  - ### is

    public boolean is(Option<Boolean> theParserOption)

  - ### start

    public void start()
    Description copied from class: `AbstractRDFHandler`
    Notification that the processing has started
    Specified by:
      `start` in interface `RDFHandler`
    Overrides:
      `start` in class `AbstractRDFHandler`

  - ### end

    public void end()
    Description copied from class: `AbstractRDFHandler`
    Notification that processing has finished
    Specified by:
      `end` in interface `RDFHandler`
    Overrides:
      `end` in class `AbstractRDFHandler`

  - ### handle

    public void handle(@Nonnull Statement theStatement)
    Event for when a statement was encountered
    Parameters:
      `theStatement` - the statement

  - ### namespace

    public void namespace(@Nonnull String thePrefix, @Nonnull String theIRI)
    Event for when a namespace was encountered
    Specified by:
      `namespace` in interface `RDFHandler`
    Overrides:
      `namespace` in class `AbstractRDFHandler`
    Parameters:
      `thePrefix` - the namespace prefix
      `theIRI` - the associated IRI

  - ### namespace

    @Nonnull public String namespace(@Nonnull String thePrefix)

  - ### currentStatement

    public Statement currentStatement()

  - ### reportStatement

    public void reportStatement()

  - ### resetStatement

    public void resetStatement()

  - ### error

    public InvalidRDF error(String theMsg)
    Indicates a `fatal error`
    Parameters:
      `theMsg` - the error message
    Returns:
      this will always raise an exception

  - ### error

    public void error(String theMsg, ParserContext.ParseError theError)
    Indicates an error of the given type
    Parameters:
      `theMsg` - the error message
      `theError` - the type of the error

  - ### createLiteral

    public Literal createLiteral(@Nonnull String label, @Nullable String lang, @Nullable IRI datatype) throws InvalidRDF
    Creates a `Literal` object from parsed information and context.
    Throws:
      `InvalidRDF`

  - ### createBNode

    public BNode createBNode()
    Creates a new unique `BNode` object

  - ### createBNode

    public BNode createBNode(@Nonnull String theNodeID)
    Creates a `BNode` object for the specified identifier.

  - ### getRandomBnodeIdPrefix

    public static String 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.