Class 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 -
Method Summary
Modifier and TypeMethodDescriptionprivate static URL
protected void
Check that one and only one source is present and valid.contentType
(String contentType) Specify the content type of the RDF syntax to parse.contentType
(RDFSyntax rdfSyntax) Specify the content type of the RDF syntax to parse.protected JsonLdRDF
Create a newRDF
for a parse session.private JsonLdRDF
protected void
private Object
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
-
Constructor Details
-
JsonLdParser
public JsonLdParser()
-
-
Method Details
-
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
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:
IllegalArgumentException
- If this RDFParser does not support the specified RDFSyntax.- See Also:
-
contentType
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:
IllegalArgumentException
- If the contentType has an invalid syntax, or this RDFParser does not support the specified contentType.- See Also:
-
asURL
- Throws:
IllegalStateException
-
checkSource
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:
IOException
- If a source file can't be read
-
parseSynchronusly
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:
IOException
- If the source could not be read
-
getJsonLdFactory
-
readSource
- Throws:
IOException
-