Package org.hl7.fhir.r4.formats
Interface IParser
- All Known Implementing Classes:
JsonParser
,JsonParserBase
,ParserBase
,RdfParser
,RdfParserBase
,XmlParser
,XmlParserBase
public interface IParser
General interface - either an XML or JSON parser: read or write instances
Defined to allow a factory to create a parser of the right type
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
compose
(OutputStream stream, Resource resource) Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)void
compose
(OutputStream stream, Type type, String rootName) Compose a type to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production) Not supported by all implementations.byte[]
composeBytes
(Resource resource) Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)byte[]
composeBytes
(Type type, String rootName) Compose a type to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production) Not supported by all implementations.composeString
(Resource resource) Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)composeString
(Type type, String rootName) Compose a type to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production) Not supported by all implementations.boolean
Whether to parse or ignore comments - either reading or writingWriting:getType()
check what kind of parser this isboolean
parse
(byte[] bytes) parse content that is known to be a resourceparse
(InputStream input) parse content that is known to be a resourceparse content that is known to be a resourceparseAnyType
(InputStream input, String knownType) This is used to parse a type - a fragment of a resource.parseType
(InputStream input, String knownType) This is used to parse a type - a fragment of a resource.This is used to parse a type - a fragment of a resource.setAllowUnknownContent
(boolean value) setHandleComments
(boolean value) setSuppressXhtml
(String message) This method is used by the publication tooling to stop the xhrtml narrative being generated.
-
Method Details
-
getType
check what kind of parser this is- Returns:
- what kind of parser this is
-
getHandleComments
boolean getHandleComments()Whether to parse or ignore comments - either reading or writing -
setHandleComments
-
isAllowUnknownContent
boolean isAllowUnknownContent()- Parameters:
allowUnknownContent
- Whether to throw an exception if unknown content is found (or just skip it) when parsing
-
setAllowUnknownContent
-
getOutputStyle
Writing: -
setOutputStyle
-
setSuppressXhtml
This method is used by the publication tooling to stop the xhrtml narrative being generated. It is not valid to use in production use. The tooling uses it to generate json/xml representations in html that are not cluttered by escaped html representations of the html representation -
parse
parse content that is known to be a resource- Throws:
org.xmlpull.v1.XmlPullParserException
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
parse
Resource parse(String input) throws UnsupportedEncodingException, org.hl7.fhir.exceptions.FHIRFormatError, IOException parse content that is known to be a resource- Throws:
UnsupportedEncodingException
IOException
org.hl7.fhir.exceptions.FHIRFormatError
-
parse
parse content that is known to be a resource- Throws:
IOException
org.hl7.fhir.exceptions.FHIRFormatError
-
parseType
Type parseType(InputStream input, String knownType) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError This is used to parse a type - a fragment of a resource. There's no reason to use this in production - it's used in the build tools Not supported by all implementations- Parameters:
input
-knownType
- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
org.xmlpull.v1.XmlPullParserException
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
parseAnyType
Type parseAnyType(InputStream input, String knownType) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError - Throws:
IOException
org.hl7.fhir.exceptions.FHIRFormatError
-
parseType
Type parseType(String input, String knownType) throws UnsupportedEncodingException, org.hl7.fhir.exceptions.FHIRFormatError, IOException This is used to parse a type - a fragment of a resource. There's no reason to use this in production - it's used in the build tools Not supported by all implementations- Parameters:
input
-knownType
- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
UnsupportedEncodingException
IOException
org.hl7.fhir.exceptions.FHIRFormatError
-
parseType
Type parseType(byte[] bytes, String knownType) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException This is used to parse a type - a fragment of a resource. There's no reason to use this in production - it's used in the build tools Not supported by all implementations- Parameters:
knownType
- . if this is blank, the parser may try to infer the type (xml only)input
-- Returns:
- Throws:
IOException
org.hl7.fhir.exceptions.FHIRFormatError
-
compose
Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)- Throws:
IOException
-
composeString
Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)- Throws:
IOException
-
composeBytes
Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)- Throws:
IOException
-
compose
Compose a type to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production) Not supported by all implementations. rootName is ignored in the JSON format- Throws:
org.xmlpull.v1.XmlPullParserException
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
composeString
Compose a type to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production) Not supported by all implementations. rootName is ignored in the JSON format- Throws:
IOException
-
composeBytes
Compose a type to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production) Not supported by all implementations. rootName is ignored in the JSON format- Throws:
IOException
-