
Package ca.uhn.fhir.parser
Class RDFParser
- java.lang.Object
-
- ca.uhn.fhir.parser.BaseParser
-
- ca.uhn.fhir.parser.RDFParser
-
- All Implemented Interfaces:
IParser
public class RDFParser extends BaseParser
This class is the FHIR RDF parser/encoder. Users should not interact with this class directly, but should useFhirContext.newRDFParser()
to get an instance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ca.uhn.fhir.parser.BaseParser
BaseParser.CompositeChildElement, BaseParser.EncodeContext
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONTAINED
static String
DOMAIN_RESOURCE_CONTAINED
static String
ELEMENT_ID
static String
EXTENSION
static String
ID
static String
MODIFIER_EXTENSION
static String
NODE_ROLE
static String
RESOURCE_ID
static String
TREE_ROOT
-
Fields inherited from class ca.uhn.fhir.parser.BaseParser
RESOURCE_CREATED_BY_PARSER
-
-
Constructor Summary
Constructors Constructor Description 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()
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doEncodeResourceToWriter(IBaseResource resource, Writer writer, 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 JenaEncodingEnum
getEncoding()
Which encoding does this parser instance produce?IParser
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, containResourcesForEncoding, encodeResourceToString, encodeResourceToWriter, encodeResourceToWriter, extractMetadataListNotNull, findBaseReferences, fixContainedResourceId, getAllBaseReferences, getCompositeElementId, 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
-
-
-
-
Field Detail
-
NODE_ROLE
public static final String NODE_ROLE
- See Also:
- Constant Field Values
-
TREE_ROOT
public static final String TREE_ROOT
- See Also:
- Constant Field Values
-
RESOURCE_ID
public static final String RESOURCE_ID
- See Also:
- Constant Field Values
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
ELEMENT_ID
public static final String ELEMENT_ID
- See Also:
- Constant Field Values
-
DOMAIN_RESOURCE_CONTAINED
public static final String DOMAIN_RESOURCE_CONTAINED
- See Also:
- Constant Field Values
-
EXTENSION
public static final String EXTENSION
- See Also:
- Constant Field Values
-
CONTAINED
public static final String CONTAINED
- See Also:
- Constant Field Values
-
MODIFIER_EXTENSION
public static final String MODIFIER_EXTENSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
getEncoding
public EncodingEnum getEncoding()
Description copied from interface:IParser
Which encoding does this parser instance produce?
-
setPrettyPrint
public IParser setPrettyPrint(boolean prettyPrint)
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, 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
-
-