Package ca.uhn.fhir.parser
Class RDFParser
java.lang.Object
ca.uhn.fhir.parser.BaseParser
ca.uhn.fhir.parser.RDFParser
- All Implemented Interfaces:
IParser
This class is the FHIR RDF parser/encoder. Users should not interact with this class directly, but should use
FhirContext.newRDFParser()
to get an instance.-
Nested Class Summary
Nested classes/interfaces inherited from class ca.uhn.fhir.parser.BaseParser
BaseParser.CompositeChildElement
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class ca.uhn.fhir.parser.BaseParser
RESOURCE_CREATED_BY_PARSER
-
Constructor Summary
ConstructorDescriptionRDFParser
(FhirContext context, IParserErrorHandler parserErrorHandler, org.apache.jena.riot.Lang lang) Do not use this constructor, the recommended way to obtain a new instance of the RDF parser is to invokeFhirContext.newRDFParser()
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doEncodeResourceToWriter
(IBaseResource resource, Writer writer, ca.uhn.fhir.parser.BaseParser.EncodeContext encodeContext) Writes the provided resource to the writer.protected <T extends IBaseResource>
TdoParseResource
(Class<T> resourceType, Reader reader) Parses RDF content to a FHIR resource using Apache JenaWhich encoding does this parser instance produce?setPrettyPrint
(boolean prettyPrint) Sets the "pretty print" flag, meaning that the parser will encode resources with human-readable spacing and newlines between elements instead of condensing output as much as possible.Methods inherited from class ca.uhn.fhir.parser.BaseParser
compositeChildIterator, containResourcesInReferences, doEncodeToWriter, encodeResourceToString, encodeResourceToWriter, encodeResourceToWriter, encodeToString, encodeToWriter, encodeToWriter, extractMetadataListNotNull, fixContainedResourceId, getCompositeElementId, getContext, getDontStripVersionsFromReferencesAtPaths, getEncodeForceResourceId, getErrorHandler, getExtensionMetadataKeys, getExtensionUrl, getMetaTagsForEncoding, getPreferTypes, getProfileTagsForEncoding, getServerBaseUrl, getStripVersionsFromReferences, getSuppressNarratives, isChildContained, isEncodeElementsAppliesToChildResourcesOnly, isOmitResourceId, isSummaryMode, isSuppressNarratives, parseResource, parseResource, parseResource, parseResource, parseResource, parseResource, preProcessValues, setDontEncodeElements, setDontStripVersionsFromReferencesAtPaths, setDontStripVersionsFromReferencesAtPaths, setEncodeElements, setEncodeElementsAppliesToChildResourcesOnly, setEncodeForceResourceId, setOmitResourceId, setOverrideResourceIdWithBundleEntryFullUrl, setParserErrorHandler, setPreferTypes, setServerBaseUrl, setStripVersionsFromReferences, setSummaryMode, setSuppressNarratives, shouldAddSubsettedTag, shouldEncodePath, shouldEncodeResource, shouldEncodeResourceId, shouldEncodeResourceMeta, throwExceptionForUnknownChildType
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ca.uhn.fhir.parser.IParser
setDontEncodeElements, setEncodeElements
-
Field Details
-
NODE_ROLE
- See Also:
-
TREE_ROOT
- See Also:
-
RESOURCE_ID
- See Also:
-
ID
- See Also:
-
ELEMENT_ID
- See Also:
-
DOMAIN_RESOURCE_CONTAINED
- See Also:
-
EXTENSION
- See Also:
-
CONTAINED
- See Also:
-
MODIFIER_EXTENSION
- See Also:
-
-
Constructor Details
-
RDFParser
public RDFParser(FhirContext context, IParserErrorHandler parserErrorHandler, org.apache.jena.riot.Lang lang) Do not use this constructor, the recommended way to obtain a new instance of the RDF parser is to invokeFhirContext.newRDFParser()
.- Parameters:
parserErrorHandler
- the Parser Error Handler
-
-
Method Details
-
getEncoding
Description copied from interface:IParser
Which encoding does this parser instance produce? -
setPrettyPrint
Description copied from interface:IParser
Sets the "pretty print" flag, meaning that the parser will encode resources with human-readable spacing and newlines between elements instead of condensing output as much as possible.- Parameters:
prettyPrint
- The flag- Returns:
- Returns an instance of
this
parser so that method calls can be chained together
-
doEncodeResourceToWriter
protected void doEncodeResourceToWriter(IBaseResource resource, Writer writer, ca.uhn.fhir.parser.BaseParser.EncodeContext encodeContext) Writes the provided resource to the writer. This should only be called for the top-level resource being encoded.- Specified by:
doEncodeResourceToWriter
in classBaseParser
- Parameters:
resource
- FHIR resource for writingwriter
- The writer to write to -- Note: Jena prefers streams over writersencodeContext
- encoding content from parent
-
doParseResource
protected <T extends IBaseResource> T doParseResource(Class<T> resourceType, Reader reader) throws DataFormatException Parses RDF content to a FHIR resource using Apache Jena- Specified by:
doParseResource
in classBaseParser
- Type Parameters:
T
- Type parameter denoting which resource is being parsed- Parameters:
resourceType
- Class of FHIR resource being deserializedreader
- Reader containing RDF (turtle) content- Returns:
- Populated FHIR resource
- Throws:
DataFormatException
- Exception that can be thrown from parser
-