Package org.hl7.fhir.r5.formats
Class ParserBase
- java.lang.Object
-
- org.hl7.fhir.r5.formats.FormatUtilities
-
- org.hl7.fhir.r5.formats.ParserBase
-
- All Implemented Interfaces:
IParser
- Direct Known Subclasses:
JsonParserBase
,RdfParserBase
,XmlParserBase
public abstract class ParserBase extends FormatUtilities implements IParser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hl7.fhir.r5.formats.IParser
IParser.OutputStyle
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowComments
whether to allow comments in the json (special case for IG publisher source)protected boolean
allowUnknownContent
Whether to throw an exception if unknown content is found (or just skip it)protected boolean
handleComments
protected Map<String,Object>
idMap
protected IParser.OutputStyle
style
protected String
xhtmlMessage
-
Fields inherited from class org.hl7.fhir.r5.formats.FormatUtilities
FHIR_NS, ID_REGEX, NS_XSI, XHTML_NS
-
-
Constructor Summary
Constructors Constructor Description ParserBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
composeBytes(DataType type, String typeName)
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)String
composeString(DataType type, String typeName)
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.String
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)boolean
getHandleComments()
Whether to parse or ignore comments - either reading or writingIParser.OutputStyle
getOutputStyle()
Writing:boolean
isAllowComments()
boolean
isAllowUnknownContent()
Resource
parse(byte[] bytes)
parse content that is known to be a resourceResource
parse(String input)
parse content that is known to be a resourceDataType
parseAnyType(byte[] bytes, String typeName)
DataType
parseAnyType(String input, String typeName)
protected byte[]
parseBase64BinaryPrimitive(String value)
protected Boolean
parseBooleanPrimitive(Boolean value)
protected Boolean
parseBooleanPrimitive(String value)
protected String
parseCodePrimitive(String value)
protected BigDecimal
parseDecimalPrimitive(String value)
protected BigDecimal
parseDecimalPrimitive(BigDecimal value)
protected String
parseIdPrimitive(String value)
protected int
parseIntegerPrimitive(Long value)
protected int
parseIntegerPrimitive(String value)
protected String
parseOidPrimitive(String value)
protected String
parseStringPrimitive(String value)
protected String
parseTimePrimitive(String value)
DataType
parseType(byte[] bytes, String typeName)
This is used to parse a type - a fragment of a resource.DataType
parseType(String input, String typeName)
This is used to parse a type - a fragment of a resource.protected String
parseUriPrimitive(String value)
protected String
parseUuidPrimitive(String value)
void
setAllowComments(boolean allowComments)
IParser
setAllowUnknownContent(boolean allowUnknownContent)
IParser
setHandleComments(boolean value)
IParser
setOutputStyle(IParser.OutputStyle style)
IParser
setSuppressXhtml(String message)
This method is used by the publication tooling to stop the xhrtml narrative being generated.-
Methods inherited from class org.hl7.fhir.r5.formats.FormatUtilities
determineFormat, determineFormat, isValidId, loadFile, makeId, makeParser, makeParser, toString, toString, toString, toString, toString, toString
-
-
-
-
Field Detail
-
xhtmlMessage
protected String xhtmlMessage
-
handleComments
protected boolean handleComments
-
allowUnknownContent
protected boolean allowUnknownContent
Whether to throw an exception if unknown content is found (or just skip it)
-
allowComments
protected boolean allowComments
whether to allow comments in the json (special case for IG publisher source)
-
style
protected IParser.OutputStyle style
-
-
Constructor Detail
-
ParserBase
public ParserBase()
-
-
Method Detail
-
parse
public Resource parse(String input) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParser
parse content that is known to be a resource- Specified by:
parse
in interfaceIParser
- Throws:
org.hl7.fhir.exceptions.FHIRFormatError
UnsupportedEncodingException
IOException
-
parse
public Resource parse(byte[] bytes) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParser
parse content that is known to be a resource- Specified by:
parse
in interfaceIParser
- Throws:
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
parseType
public DataType parseType(String input, String typeName) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParser
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- Specified by:
parseType
in interfaceIParser
typeName
- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
org.hl7.fhir.exceptions.FHIRFormatError
UnsupportedEncodingException
IOException
-
parseAnyType
public DataType parseAnyType(String input, String typeName) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
- Throws:
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
parseType
public DataType parseType(byte[] bytes, String typeName) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParser
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- Specified by:
parseType
in interfaceIParser
typeName
- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
parseAnyType
public DataType parseAnyType(byte[] bytes, String typeName) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
- Throws:
org.hl7.fhir.exceptions.FHIRFormatError
IOException
-
composeString
public String composeString(Resource resource) throws IOException
Description copied from interface:IParser
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)- Specified by:
composeString
in interfaceIParser
- Throws:
IOException
-
composeBytes
public byte[] composeBytes(Resource resource) throws IOException
Description copied from interface:IParser
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)- Specified by:
composeBytes
in interfaceIParser
- Throws:
IOException
-
composeString
public String composeString(DataType type, String typeName) throws IOException
Description copied from interface:IParser
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- Specified by:
composeString
in interfaceIParser
- Throws:
IOException
-
composeBytes
public byte[] composeBytes(DataType type, String typeName) throws IOException
Description copied from interface:IParser
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- Specified by:
composeBytes
in interfaceIParser
- Throws:
IOException
-
setSuppressXhtml
public IParser setSuppressXhtml(String message)
Description copied from interface:IParser
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- Specified by:
setSuppressXhtml
in interfaceIParser
-
getHandleComments
public boolean getHandleComments()
Description copied from interface:IParser
Whether to parse or ignore comments - either reading or writing- Specified by:
getHandleComments
in interfaceIParser
-
setHandleComments
public IParser setHandleComments(boolean value)
- Specified by:
setHandleComments
in interfaceIParser
-
isAllowUnknownContent
public boolean isAllowUnknownContent()
- Specified by:
isAllowUnknownContent
in interfaceIParser
- Returns:
- Whether to throw an exception if unknown content is found (or just skip it)
-
setAllowUnknownContent
public IParser setAllowUnknownContent(boolean allowUnknownContent)
- Specified by:
setAllowUnknownContent
in interfaceIParser
- Parameters:
allowUnknownContent
- Whether to throw an exception if unknown content is found (or just skip it)
-
isAllowComments
public boolean isAllowComments()
-
setAllowComments
public void setAllowComments(boolean allowComments)
-
getOutputStyle
public IParser.OutputStyle getOutputStyle()
Description copied from interface:IParser
Writing:- Specified by:
getOutputStyle
in interfaceIParser
-
setOutputStyle
public IParser setOutputStyle(IParser.OutputStyle style)
- Specified by:
setOutputStyle
in interfaceIParser
-
parseIntegerPrimitive
protected int parseIntegerPrimitive(String value)
-
parseIntegerPrimitive
protected int parseIntegerPrimitive(Long value)
-
parseCodePrimitive
protected String parseCodePrimitive(String value)
-
parseTimePrimitive
protected String parseTimePrimitive(String value) throws ParseException
- Throws:
ParseException
-
parseDecimalPrimitive
protected BigDecimal parseDecimalPrimitive(BigDecimal value)
-
parseDecimalPrimitive
protected BigDecimal parseDecimalPrimitive(String value)
-
parseUriPrimitive
protected String parseUriPrimitive(String value)
-
parseBase64BinaryPrimitive
protected byte[] parseBase64BinaryPrimitive(String value)
-
parseOidPrimitive
protected String parseOidPrimitive(String value)
-
parseBooleanPrimitive
protected Boolean parseBooleanPrimitive(String value)
-
parseBooleanPrimitive
protected Boolean parseBooleanPrimitive(Boolean value)
-
parseIdPrimitive
protected String parseIdPrimitive(String value)
-
parseStringPrimitive
protected String parseStringPrimitive(String value)
-
parseUuidPrimitive
protected String parseUuidPrimitive(String value)
-
-