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.URLasURL(IRI iri)protected voidcheckSource()Check that one and only one source is present and valid.JsonLdParsercontentType(java.lang.String contentType)Specify the content type of the RDF syntax to parse.JsonLdParsercontentType(RDFSyntax rdfSyntax)Specify the content type of the RDF syntax to parse.protected JsonLdRDFcreateRDFTermFactory()Create a newRDFfor a parse session.private JsonLdRDFgetJsonLdFactory()protected voidparseSynchronusly()private java.lang.ObjectreadSource()-
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:AbstractRDFParserCreate a newRDFfor 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:
createRDFTermFactoryin classAbstractRDFParser<JsonLdParser>- Returns:
- A new
RDF
-
contentType
public JsonLdParser contentType(RDFSyntax rdfSyntax) throws java.lang.IllegalArgumentException
Description copied from interface:RDFParserSpecify the content type of the RDF syntax to parse.This option can be used to select the RDFSyntax of the source, overriding any
Content-Typeheaders or equivalent.The character set of the RDFSyntax is assumed to be
StandardCharsets.UTF_8unless 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:
contentTypein interfaceRDFParser- Overrides:
contentTypein classAbstractRDFParser<JsonLdParser>- Parameters:
rdfSyntax- AnRDFSyntaxto parse the source according to, e.g.RDFSyntax.TURTLE.- Returns:
- An
RDFParserthat 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:RDFParserSpecify the content type of the RDF syntax to parse.This option can be used to select the RDFSyntax of the source, overriding any
Content-Typeheaders or equivalent.The content type MAY include a
charsetparameter if the RDF media types permit it; the default charset isStandardCharsets.UTF_8unless overridden within the document.This method will override any contentType set with
RDFParser.contentType(RDFSyntax).- Specified by:
contentTypein interfaceRDFParser- Overrides:
contentTypein classAbstractRDFParser<JsonLdParser>- Parameters:
contentType- A content-type string, e.g.application/ld+jsonortext/turtle;charset="UTF-8"as specified by RFC7231.- Returns:
- An
RDFParserthat 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.IOExceptionDescription copied from class:AbstractRDFParserCheck 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:
checkSourcein classAbstractRDFParser<JsonLdParser>- Throws:
java.io.IOException- If a source file can't be read
-
parseSynchronusly
protected void parseSynchronusly() throws java.io.IOExceptionDescription copied from class:AbstractRDFParserParseAbstractRDFParser.sourceInputStream,AbstractRDFParser.sourceFileorAbstractRDFParser.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:
parseSynchronuslyin 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
-
-