public abstract class BaseParser extends Object implements IParser
| Modifier and Type | Class and Description |
|---|---|
protected class |
BaseParser.CompositeChildElement |
| Constructor and Description |
|---|
BaseParser(FhirContext theContext,
IParserErrorHandler theParserErrorHandler)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected Iterable<BaseParser.CompositeChildElement> |
compositeChildIterator(List<? extends BaseRuntimeChildDefinition> theChildren,
boolean theContainedResource,
BaseParser.CompositeChildElement theParent) |
protected void |
containResourcesForEncoding(IBaseResource theResource) |
protected String |
determineReferenceText(IBaseReference theRef) |
protected String |
determineResourceBaseUrl(String bundleBaseUrl,
BundleEntry theEntry) |
protected abstract void |
doEncodeBundleToWriter(Bundle theBundle,
Writer theWriter) |
protected abstract void |
doEncodeResourceToWriter(IBaseResource theResource,
Writer theWriter) |
protected abstract <T extends IBaseResource> |
doParseResource(Class<T> theResourceType,
Reader theReader) |
String |
encodeBundleToString(Bundle theBundle) |
void |
encodeBundleToWriter(Bundle theBundle,
Writer theWriter) |
String |
encodeResourceToString(IBaseResource theResource) |
void |
encodeResourceToWriter(IBaseResource theResource,
Writer theWriter) |
String |
encodeTagListToString(TagList theTagList)
Encodes a tag list, as defined in the FHIR
Specification.
|
protected static <T> List<T> |
extractMetadataListNotNull(IResource resource,
ResourceMetadataKeyEnum<List<T>> key) |
protected String |
fixContainedResourceId(String theValue) |
Set<String> |
getEncodeElements()
|
Set<String> |
getEncodeElementsAppliesToResourceTypes()
|
protected IParserErrorHandler |
getErrorHandler() |
protected TagList |
getMetaTagsForEncoding(IResource theIResource) |
boolean |
getSuppressNarratives()
Deprecated.
|
protected boolean |
isChildContained(BaseRuntimeElementDefinition<?> childDef,
boolean theIncludedResource) |
boolean |
isOmitResourceId()
Returns true if resource IDs should be omitted
|
boolean |
isStripVersionsFromReferences()
If set to
true |
boolean |
isSummaryMode()
Is the parser in "summary mode"? See
IParser.setSummaryMode(boolean) for information |
boolean |
isSuppressNarratives()
If set to
true (default is false), narratives will not be included in the encoded
values. |
Bundle |
parseBundle(Reader theReader)
Parse a DSTU1 style Atom Bundle.
|
Bundle |
parseBundle(String theXml)
Parse a DSTU1 style Atom Bundle.
|
<T extends IBaseResource> |
parseResource(Class<T> theResourceType,
Reader theReader)
Parses a resource
|
<T extends IBaseResource> |
parseResource(Class<T> theResourceType,
String theMessageString)
Parses a resource
|
IBaseResource |
parseResource(Reader theReader)
Parses a resource
|
IBaseResource |
parseResource(String theMessageString)
Parses a resource
|
TagList |
parseTagList(String theString)
Parses a tag list, as defined in the FHIR
Specification.
|
protected List<? extends IBase> |
preProcessValues(BaseRuntimeChildDefinition metaChildUncast,
IBaseResource theResource,
List<? extends IBase> theValues) |
void |
setEncodeElements(Set<String> theEncodeElements)
If provided, specifies the elements which should be encoded, to the exclusion of all others.
|
void |
setEncodeElementsAppliesToResourceTypes(Set<String> theEncodeElementsAppliesToResourceTypes)
If provided, tells the parse which resource types to apply
encode elements to. |
IParser |
setOmitResourceId(boolean theOmitResourceId)
If set to
true (default is false) the ID of any resources being encoded will not be
included in the output. |
IParser |
setParserErrorHandler(IParserErrorHandler theErrorHandler)
Registers an error handler which will be invoked when any parse errors are found
|
IParser |
setServerBaseUrl(String theUrl)
Sets the server's base URL used by this parser.
|
IParser |
setStripVersionsFromReferences(boolean theStripVersionsFromReferences)
If set to
true |
IParser |
setSummaryMode(boolean theSummaryMode)
If set to
true (default is false) only elements marked by the FHIR specification as
being "summary elements" will be included. |
IParser |
setSuppressNarratives(boolean theSuppressNarratives)
If set to
true (default is false), narratives will not be included in the encoded
values. |
protected boolean |
shouldAddSubsettedTag() |
protected void |
throwExceptionForUnknownChildType(BaseRuntimeChildDefinition nextChild,
Class<? extends IBase> theType) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitencodeTagListToWriter, getEncoding, parseBundle, parseTagList, setPrettyPrintpublic BaseParser(FhirContext theContext, IParserErrorHandler theParserErrorHandler)
theParserErrorHandler - protected Iterable<BaseParser.CompositeChildElement> compositeChildIterator(List<? extends BaseRuntimeChildDefinition> theChildren, boolean theContainedResource, BaseParser.CompositeChildElement theParent)
protected void containResourcesForEncoding(IBaseResource theResource)
protected String determineReferenceText(IBaseReference theRef)
protected String determineResourceBaseUrl(String bundleBaseUrl, BundleEntry theEntry)
protected abstract void doEncodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException
IOExceptionDataFormatExceptionprotected abstract void doEncodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException
IOExceptionDataFormatExceptionprotected abstract <T extends IBaseResource> T doParseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException
DataFormatExceptionpublic String encodeBundleToString(Bundle theBundle) throws DataFormatException
encodeBundleToString in interface IParserDataFormatExceptionpublic final void encodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException
encodeBundleToWriter in interface IParserIOExceptionDataFormatExceptionpublic String encodeResourceToString(IBaseResource theResource) throws DataFormatException
encodeResourceToString in interface IParserDataFormatExceptionpublic final void encodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException
encodeResourceToWriter in interface IParserIOExceptionDataFormatExceptionpublic String encodeTagListToString(TagList theTagList)
IParserencodeTagListToString in interface IParsertheTagList - The tag list to encode. Must not be null.protected String fixContainedResourceId(String theValue)
public Set<String> getEncodeElements()
getEncodeElements in interface IParserpublic Set<String> getEncodeElementsAppliesToResourceTypes()
getEncodeElementsAppliesToResourceTypes in interface IParserprotected IParserErrorHandler getErrorHandler()
protected TagList getMetaTagsForEncoding(IResource theIResource)
@Deprecated public boolean getSuppressNarratives()
isSuppressNarratives()true (default is false), narratives will not be included in the encoded
values.protected boolean isChildContained(BaseRuntimeElementDefinition<?> childDef, boolean theIncludedResource)
public boolean isOmitResourceId()
IParserisOmitResourceId in interface IParserIParser.setOmitResourceId(boolean)public boolean isStripVersionsFromReferences()
IParsertrue (which is the default), resource references containing a version
will have the version removed when the resource is encoded. This is generally good behaviour because
in most situations, references from one resource to another should be to the resource by ID, not
by ID and version. In some cases though, it may be desirable to preserve the version in resource
links. In that case, this value should be set to false.isStripVersionsFromReferences in interface IParsertrue.public boolean isSummaryMode()
IParserIParser.setSummaryMode(boolean) for informationisSummaryMode in interface IParser#setSummaryMode(boolean)} for informationpublic boolean isSuppressNarratives()
true (default is false), narratives will not be included in the encoded
values.public Bundle parseBundle(Reader theReader)
IParserIParser.parseResource(Class, Reader) with the Bundle class found in the
ca.uhn.hapi.fhir.model.[version].resource package instead.parseBundle in interface IParserpublic Bundle parseBundle(String theXml) throws ConfigurationException, DataFormatException
IParserIParser.parseResource(Class, String) with the Bundle class found in the
ca.uhn.hapi.fhir.model.[version].resource package instead.parseBundle in interface IParserConfigurationExceptionDataFormatExceptionpublic <T extends IBaseResource> T parseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException
IParserparseResource in interface IParsertheResourceType - The resource type to use. This can be used to explicitly specify a class which extends a built-in type
(e.g. a custom type extending the default Patient class)theReader - The reader to parse input from. Note that the Reader will not be closed by the parser upon completion.DataFormatException - If the resource can not be parsed because the data is not recognized or invalid for any reasonpublic <T extends IBaseResource> T parseResource(Class<T> theResourceType, String theMessageString)
IParserparseResource in interface IParsertheResourceType - The resource type to use. This can be used to explicitly specify a class which extends a built-in type
(e.g. a custom type extending the default Patient class)theMessageString - The string to parsepublic IBaseResource parseResource(Reader theReader) throws ConfigurationException, DataFormatException
IParserparseResource in interface IParsertheReader - The reader to parse input from. Note that the Reader will not be closed by the parser upon completion.IResource or
IAnyResource depending on the specific FhirContext which created this parser.DataFormatException - If the resource can not be parsed because the data is not recognized or invalid for any reasonConfigurationExceptionpublic IBaseResource parseResource(String theMessageString) throws ConfigurationException, DataFormatException
IParserparseResource in interface IParsertheMessageString - The string to parseIResource or
IAnyResource depending on the specific FhirContext which created this parser.DataFormatException - If the resource can not be parsed because the data is not recognized or invalid for any reasonConfigurationExceptionpublic TagList parseTagList(String theString)
IParserparseTagList in interface IParsertheString - A string containing a tag listprotected List<? extends IBase> preProcessValues(BaseRuntimeChildDefinition metaChildUncast, IBaseResource theResource, List<? extends IBase> theValues)
public void setEncodeElements(Set<String> theEncodeElements)
IParsersetEncodeElements in interface IParsertheEncodeElements - The elements to encodepublic void setEncodeElementsAppliesToResourceTypes(Set<String> theEncodeElementsAppliesToResourceTypes)
IParserencode elements to. Any
resource types not specified here will be encoded completely, with no elements excluded.setEncodeElementsAppliesToResourceTypes in interface IParserpublic IParser setOmitResourceId(boolean theOmitResourceId)
IParsertrue (default is false) the ID of any resources being encoded will not be
included in the output. Note that this does not apply to contained resources, only to root resources. In other
words, if this is set to true, contained resources will still have local IDs but the outer/containing
ID will not have an ID.setOmitResourceId in interface IParsertheOmitResourceId - Should resource IDs be omittedthis parser so that method calls can be chained togetherpublic IParser setParserErrorHandler(IParserErrorHandler theErrorHandler)
IParsersetParserErrorHandler in interface IParsertheErrorHandler - The error handler to set. Must not be null.public IParser setServerBaseUrl(String theUrl)
IParsersetServerBaseUrl in interface IParsertheUrl - The base URL, e.g. "http://example.com/base"this parser so that method calls can be chained togetherpublic IParser setStripVersionsFromReferences(boolean theStripVersionsFromReferences)
IParsertrue (which is the default), resource references containing a version
will have the version removed when the resource is encoded. This is generally good behaviour because
in most situations, references from one resource to another should be to the resource by ID, not
by ID and version. In some cases though, it may be desirable to preserve the version in resource
links. In that case, this value should be set to false.setStripVersionsFromReferences in interface IParsertheStripVersionsFromReferences - Set this to false to prevent the parser from removing
resource versions from references.this parser so that method calls can be chained togetherpublic IParser setSummaryMode(boolean theSummaryMode)
IParsertrue (default is false) only elements marked by the FHIR specification as
being "summary elements" will be included.setSummaryMode in interface IParserthis parser so that method calls can be chained togetherpublic IParser setSuppressNarratives(boolean theSuppressNarratives)
IParsertrue (default is false), narratives will not be included in the encoded
values.setSuppressNarratives in interface IParserprotected boolean shouldAddSubsettedTag()
protected void throwExceptionForUnknownChildType(BaseRuntimeChildDefinition nextChild, Class<? extends IBase> theType)
protected static <T> List<T> extractMetadataListNotNull(IResource resource, ResourceMetadataKeyEnum<List<T>> key)
Copyright © 2014–2016 University Health Network. All rights reserved.