public interface IParser
Thread safety: Parsers are not guaranteed to be thread safe. Create a new parser instance for every thread or every message being parsed/encoded.
| Modifier and Type | Method and Description |
|---|---|
String |
encodeResourceToString(IBaseResource theResource) |
void |
encodeResourceToWriter(IBaseResource theResource,
Writer theWriter) |
Set<String> |
getDontStripVersionsFromReferencesAtPaths()
Returns the value supplied to
setDontStripVersionsFromReferencesAtPaths(String...)
or null if no value has been set for this parser (in which case the default from
the ParserOptions will be used} |
Set<String> |
getEncodeElements()
|
Set<String> |
getEncodeElementsAppliesToResourceTypes()
|
IIdType |
getEncodeForceResourceId()
If not set to null (as is the default) this ID will be used as the ID in any
resources encoded by this parser
|
EncodingEnum |
getEncoding()
Which encoding does this parser instance produce?
|
Boolean |
getOverrideResourceIdWithBundleEntryFullUrl()
If set to
true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
resource id if the fullUrl is defined. |
List<Class<? extends IBaseResource>> |
getPreferTypes()
Gets the preferred types, as set using
setPreferTypes(List) |
Boolean |
getStripVersionsFromReferences()
If set to
true |
boolean |
isOmitResourceId()
Returns true if resource IDs should be omitted
|
boolean |
isSummaryMode()
Is the parser in "summary mode"? See
setSummaryMode(boolean) for information |
<T extends IBaseResource> |
parseResource(Class<T> theResourceType,
Reader theReader)
Parses a resource
|
<T extends IBaseResource> |
parseResource(Class<T> theResourceType,
String theString)
Parses a resource
|
IBaseResource |
parseResource(Reader theReader)
Parses a resource
|
IBaseResource |
parseResource(String theMessageString)
Parses a resource
|
void |
setDontEncodeElements(Set<String> theDontEncodeElements)
If provided, specifies the elements which should NOT be encoded.
|
IParser |
setDontStripVersionsFromReferencesAtPaths(Collection<String> thePaths)
If supplied value(s), any resource references at the specified paths will have their
resource versions encoded instead of being automatically stripped during the encoding
process.
|
IParser |
setDontStripVersionsFromReferencesAtPaths(String... thePaths)
If supplied value(s), any resource references at the specified paths will have their
resource versions encoded instead of being automatically stripped during the encoding
process.
|
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 |
setEncodeForceResourceId(IIdType theForceResourceId)
When encoding, force this resource ID to be encoded as the resource ID
|
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 |
setOverrideResourceIdWithBundleEntryFullUrl(Boolean theOverrideResourceIdWithBundleEntryFullUrl)
If set to
true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
resource id if the fullUrl is defined. |
IParser |
setParserErrorHandler(IParserErrorHandler theErrorHandler)
Registers an error handler which will be invoked when any parse errors are found
|
void |
setPreferTypes(List<Class<? extends IBaseResource>> thePreferTypes)
If set, when parsing resources the parser will try to use the given types when possible, in
the order that they are provided (from highest to lowest priority).
|
IParser |
setPrettyPrint(boolean thePrettyPrint)
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.
|
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. |
String encodeResourceToString(IBaseResource theResource) throws DataFormatException
DataFormatExceptionvoid encodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException
IOExceptionDataFormatExceptionSet<String> getEncodeElements()
Set<String> getEncodeElementsAppliesToResourceTypes()
IIdType getEncodeForceResourceId()
EncodingEnum getEncoding()
List<Class<? extends IBaseResource>> getPreferTypes()
setPreferTypes(List)nullsetPreferTypes(List)boolean isOmitResourceId()
setOmitResourceId(boolean)Boolean getStripVersionsFromReferences()
true (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.null if no value is set, in which case
the value from the ParserOptions will be used (default is true)ParserOptionsBoolean getOverrideResourceIdWithBundleEntryFullUrl()
true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
to false if this is not the desired behavior (e.g. the client code wishes to perform additional
validation checks between the fullUrl and the resource id).null if no value is set, in
which case the value from the ParserOptions will be used (default is true)ParserOptionsboolean isSummaryMode()
setSummaryMode(boolean) for information#setSummaryMode(boolean)} for information<T extends IBaseResource> T parseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException
theResourceType - 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 reason<T extends IBaseResource> T parseResource(Class<T> theResourceType, String theString) throws DataFormatException
theResourceType - 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)theString - The string to parseDataFormatException - If the resource can not be parsed because the data is not recognized or invalid for any reasonIBaseResource parseResource(Reader theReader) throws ConfigurationException, DataFormatException
theReader - 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 reasonConfigurationExceptionIBaseResource parseResource(String theMessageString) throws ConfigurationException, DataFormatException
theMessageString - 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 reasonConfigurationExceptionvoid setDontEncodeElements(Set<String> theDontEncodeElements)
DSTU2 note: Note that values including meta, such as Patient.meta
will work for DSTU2 parsers, but values with subelements on meta such
as Patient.meta.lastUpdated will only work in
DSTU3+ mode.
theDontEncodeElements - The elements to encodesetEncodeElements(Set)void setEncodeElements(Set<String> theEncodeElements)
theEncodeElements - The elements to encodesetDontEncodeElements(Set)void setEncodeElementsAppliesToResourceTypes(Set<String> theEncodeElementsAppliesToResourceTypes)
encode elements to. Any
resource types not specified here will be encoded completely, with no elements excluded.theEncodeElementsAppliesToResourceTypes - IParser setEncodeForceResourceId(IIdType theForceResourceId)
IParser setOmitResourceId(boolean theOmitResourceId)
true (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.theOmitResourceId - Should resource IDs be omittedthis parser so that method calls can be chained togetherIParser setParserErrorHandler(IParserErrorHandler theErrorHandler)
theErrorHandler - The error handler to set. Must not be null.void setPreferTypes(List<Class<? extends IBaseResource>> thePreferTypes)
This feature is related to, but not the same as the
FhirContext.setDefaultTypeForProfile(String, Class) feature.
setDefaultTypeForProfile is used to specify a type to be used
when a resource explicitly declares support for a given profile. This
feature specifies a type to be used irrespective of the profile declaration
in the metadata statement.
thePreferTypes - The preferred types, or nullIParser setPrettyPrint(boolean thePrettyPrint)
thePrettyPrint - The flagthis parser so that method calls can be chained togetherIParser setServerBaseUrl(String theUrl)
theUrl - The base URL, e.g. "http://example.com/base"this parser so that method calls can be chained togetherIParser setStripVersionsFromReferences(Boolean theStripVersionsFromReferences)
true (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.
This method provides the ability to globally disable reference encoding. If finer-grained
control is needed, use setDontStripVersionsFromReferencesAtPaths(String...)
theStripVersionsFromReferences - Set this to false to prevent the parser from removing resource versions from references (or null to apply the default setting from the ParserOptionsthis parser so that method calls can be chained togethersetDontStripVersionsFromReferencesAtPaths(String...),
ParserOptionsIParser setOverrideResourceIdWithBundleEntryFullUrl(Boolean theOverrideResourceIdWithBundleEntryFullUrl)
true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
to false if this is not the desired behavior (e.g. the client code wishes to perform additional
validation checks between the fullUrl and the resource id).theOverrideResourceIdWithBundleEntryFullUrl - Set this to false to prevent the parser from overriding resource ids with the
Bundle.entry.fullUrl (or null to apply the default setting from the ParserOptions)this parser so that method calls can be chained togetherParserOptionsIParser setSummaryMode(boolean theSummaryMode)
true (default is false) only elements marked by the FHIR specification as
being "summary elements" will be included.this parser so that method calls can be chained togetherIParser setSuppressNarratives(boolean theSuppressNarratives)
true (default is false), narratives will not be included in the encoded
values.IParser setDontStripVersionsFromReferencesAtPaths(String... thePaths)
This method provides a finer-grained level of control than setStripVersionsFromReferences(Boolean)
and any paths specified by this method will be encoded even if setStripVersionsFromReferences(Boolean)
has been set to true (which is the default)
thePaths - A collection of paths for which the resource versions will not be removed automatically
when serializing, e.g. "Patient.managingOrganization" or "AuditEvent.object.reference". Note that
only resource name and field names with dots separating is allowed here (no repetition
indicators, FluentPath expressions, etc.). Set to null to use the value
set in the ParserOptionsthis parser so that method calls can be chained togethersetStripVersionsFromReferences(Boolean),
ParserOptionsIParser setDontStripVersionsFromReferencesAtPaths(Collection<String> thePaths)
This method provides a finer-grained level of control than setStripVersionsFromReferences(Boolean)
and any paths specified by this method will be encoded even if setStripVersionsFromReferences(Boolean)
has been set to true (which is the default)
thePaths - A collection of paths for which the resource versions will not be removed automatically
when serializing, e.g. "Patient.managingOrganization" or "AuditEvent.object.reference". Note that
only resource name and field names with dots separating is allowed here (no repetition
indicators, FluentPath expressions, etc.). Set to null to use the value
set in the ParserOptionsthis parser so that method calls can be chained togethersetStripVersionsFromReferences(Boolean),
ParserOptionsSet<String> getDontStripVersionsFromReferencesAtPaths()
setDontStripVersionsFromReferencesAtPaths(String...)
or null if no value has been set for this parser (in which case the default from
the ParserOptions will be used}Copyright © 2014–2017 University Health Network. All rights reserved.