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
Nested Classes Modifier and Type Interface Description static classIParser.OutputStyle
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcompose(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)voidcompose(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.StringcomposeString(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)StringcomposeString(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.booleangetHandleComments()Whether to parse or ignore comments - either reading or writingIParser.OutputStylegetOutputStyle()Writing:ParserTypegetType()check what kind of parser this isbooleanisAllowUnknownContent()Resourceparse(byte[] bytes)parse content that is known to be a resourceResourceparse(InputStream input)parse content that is known to be a resourceResourceparse(String input)parse content that is known to be a resourceTypeparseAnyType(InputStream input, String knownType)TypeparseType(byte[] bytes, String knownType)This is used to parse a type - a fragment of a resource.TypeparseType(InputStream input, String knownType)This is used to parse a type - a fragment of a resource.TypeparseType(String input, String knownType)This is used to parse a type - a fragment of a resource.IParsersetAllowUnknownContent(boolean value)IParsersetHandleComments(boolean value)IParsersetOutputStyle(IParser.OutputStyle value)IParsersetSuppressXhtml(String message)This method is used by the publication tooling to stop the xhrtml narrative being generated.
-
-
-
Method Detail
-
getType
ParserType 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
IParser setHandleComments(boolean value)
-
isAllowUnknownContent
boolean isAllowUnknownContent()
- Parameters:
allowUnknownContent- Whether to throw an exception if unknown content is found (or just skip it) when parsing
-
setAllowUnknownContent
IParser setAllowUnknownContent(boolean value)
-
getOutputStyle
IParser.OutputStyle getOutputStyle()
Writing:
-
setOutputStyle
IParser setOutputStyle(IParser.OutputStyle value)
-
setSuppressXhtml
IParser setSuppressXhtml(String message)
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
Resource parse(InputStream input) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
parse content that is known to be a resource- Throws:
org.xmlpull.v1.XmlPullParserExceptionorg.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
parse
Resource parse(String input) throws UnsupportedEncodingException, org.hl7.fhir.exceptions.FHIRFormatError, IOException
parse content that is known to be a resource- Throws:
UnsupportedEncodingExceptionIOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parse
Resource parse(byte[] bytes) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
parse content that is known to be a resource- Throws:
IOExceptionorg.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.XmlPullParserExceptionorg.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
parseAnyType
Type parseAnyType(InputStream input, String knownType) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.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:
UnsupportedEncodingExceptionIOExceptionorg.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:
input-knownType- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
compose
void compose(OutputStream stream, Resource resource) throws IOException
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
String composeString(Resource resource) throws IOException
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
byte[] composeBytes(Resource resource) throws IOException
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
void compose(OutputStream stream, Type type, String rootName) throws IOException
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.XmlPullParserExceptionorg.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
composeString
String composeString(Type type, String rootName) throws IOException
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
byte[] composeBytes(Type type, String rootName) throws IOException
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
-
-