Class JsonLdParser
- java.lang.Object
-
- org.apache.commons.rdf.simple.experimental.AbstractRDFParser<JsonLdParser>
-
- org.apache.commons.rdf.jsonldjava.experimental.JsonLdParser
-
- All Implemented Interfaces:
java.lang.Cloneable
,RDFParser
public class JsonLdParser extends AbstractRDFParser<JsonLdParser>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.rdf.experimental.RDFParser
RDFParser.ParseResult
-
-
Field Summary
-
Fields inherited from class org.apache.commons.rdf.simple.experimental.AbstractRDFParser
threadGroup
-
-
Constructor Summary
Constructors Constructor Description JsonLdParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.net.URL
asURL(IRI iri)
protected void
checkSource()
Check that one and only one source is present and valid.JsonLdParser
contentType(java.lang.String contentType)
Specify the content type of the RDF syntax to parse.JsonLdParser
contentType(RDFSyntax rdfSyntax)
Specify the content type of the RDF syntax to parse.protected JsonLdRDF
createRDFTermFactory()
Create a newRDF
for a parse session.private JsonLdRDF
getJsonLdFactory()
protected void
parseSynchronusly()
private java.lang.Object
readSource()
-
Methods inherited from class org.apache.commons.rdf.simple.experimental.AbstractRDFParser
asT, base, base, checkBaseRequired, checkContentType, checkIsAbsolute, checkTarget, clone, getBase, getContentType, getContentTypeSyntax, getRdfTermFactory, getSourceFile, getSourceInputStream, getSourceIri, getTarget, getTargetDataset, getTargetGraph, guessRDFSyntax, parse, prepareForParsing, rdfTermFactory, resetSource, resetTarget, source, source, source, source, target, target, target
-
-
-
-
Method Detail
-
createRDFTermFactory
protected JsonLdRDF createRDFTermFactory()
Description copied from class:AbstractRDFParser
Create a newRDF
for a parse session.This is called by
AbstractRDFParser.parse()
to setAbstractRDFParser.rdfTermFactory(RDF)
if it isOptional.empty()
.As parsed blank nodes might be made with
RDF.createBlankNode(String)
, each call to this method SHOULD return a new RDF instance.- Overrides:
createRDFTermFactory
in classAbstractRDFParser<JsonLdParser>
- Returns:
- A new
RDF
-
contentType
public JsonLdParser contentType(RDFSyntax rdfSyntax) throws java.lang.IllegalArgumentException
Description copied from interface:RDFParser
Specify the content type of the RDF syntax to parse.This option can be used to select the RDFSyntax of the source, overriding any
Content-Type
headers or equivalent.The character set of the RDFSyntax is assumed to be
StandardCharsets.UTF_8
unless overridden within the document (e.g.<?xml version="1.0" encoding="iso-8859-1"?>
inRDFSyntax.RDFXML
).This method will override any contentType set with
RDFParser.contentType(String)
.- Specified by:
contentType
in interfaceRDFParser
- Overrides:
contentType
in classAbstractRDFParser<JsonLdParser>
- Parameters:
rdfSyntax
- AnRDFSyntax
to parse the source according to, e.g.RDFSyntax.TURTLE
.- Returns:
- An
RDFParser
that will use the specified content type. - Throws:
java.lang.IllegalArgumentException
- If this RDFParser does not support the specified RDFSyntax.- See Also:
RDFParser.contentType(String)
-
contentType
public JsonLdParser contentType(java.lang.String contentType) throws java.lang.IllegalArgumentException
Description copied from interface:RDFParser
Specify the content type of the RDF syntax to parse.This option can be used to select the RDFSyntax of the source, overriding any
Content-Type
headers or equivalent.The content type MAY include a
charset
parameter if the RDF media types permit it; the default charset isStandardCharsets.UTF_8
unless overridden within the document.This method will override any contentType set with
RDFParser.contentType(RDFSyntax)
.- Specified by:
contentType
in interfaceRDFParser
- Overrides:
contentType
in classAbstractRDFParser<JsonLdParser>
- Parameters:
contentType
- A content-type string, e.g.application/ld+json
ortext/turtle;charset="UTF-8"
as specified by RFC7231.- Returns:
- An
RDFParser
that will use the specified content type. - Throws:
java.lang.IllegalArgumentException
- If the contentType has an invalid syntax, or this RDFParser does not support the specified contentType.- See Also:
RDFParser.contentType(RDFSyntax)
-
asURL
private static java.net.URL asURL(IRI iri) throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
checkSource
protected void checkSource() throws java.io.IOException
Description copied from class:AbstractRDFParser
Check that one and only one source is present and valid.Used by
AbstractRDFParser.parse()
.Subclasses might override this method, e.g. to support other source combinations, or to check if the sourceIri is resolvable.
- Overrides:
checkSource
in classAbstractRDFParser<JsonLdParser>
- Throws:
java.io.IOException
- If a source file can't be read
-
parseSynchronusly
protected void parseSynchronusly() throws java.io.IOException
Description copied from class:AbstractRDFParser
ParseAbstractRDFParser.sourceInputStream
,AbstractRDFParser.sourceFile
orAbstractRDFParser.sourceIri
.One of the source fields MUST be present, as checked by
AbstractRDFParser.checkSource()
.AbstractRDFParser.checkBaseRequired()
is called to verify ifAbstractRDFParser.getBase()
is required.- Specified by:
parseSynchronusly
in classAbstractRDFParser<JsonLdParser>
- Throws:
java.io.IOException
- If the source could not be read
-
getJsonLdFactory
private JsonLdRDF getJsonLdFactory()
-
readSource
private java.lang.Object readSource() throws java.io.IOException
- Throws:
java.io.IOException
-
-