Package org.hl7.fhir.dstu2.formats
Class ParserBase
- java.lang.Object
-
- org.hl7.fhir.dstu2.formats.FormatUtilities
-
- org.hl7.fhir.dstu2.formats.ParserBase
-
- All Implemented Interfaces:
IParser
- Direct Known Subclasses:
JsonParserBase,XmlParserBase
public abstract class ParserBase extends FormatUtilities implements IParser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hl7.fhir.dstu2.formats.IParser
IParser.OutputStyle
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowUnknownContentWhether to throw an exception if unknown content is found (or just skip it)protected booleanhandleCommentsprotected Map<String,Object>idMapprotected IParser.OutputStylestyleprotected StringxhtmlMessage-
Fields inherited from class org.hl7.fhir.dstu2.formats.FormatUtilities
FHIR_NS, ID_REGEX, XHTML_NS
-
-
Constructor Summary
Constructors Constructor Description ParserBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 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.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 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.booleangetHandleComments()Whether to parse or ignore comments - either reading or writingIParser.OutputStylegetOutputStyle()Writing:booleanisAllowUnknownContent()Resourceparse(byte[] bytes)parse content that is known to be a resourceResourceparse(String input)parse content that is known to be a resourceprotected byte[]parseBase64BinaryPrimitive(String value)protected BooleanparseBooleanPrimitive(Boolean value)protected BooleanparseBooleanPrimitive(String value)protected StringparseCodePrimitive(String value)protected BigDecimalparseDecimalPrimitive(String value)protected BigDecimalparseDecimalPrimitive(BigDecimal value)protected StringparseIdPrimitive(String value)protected intparseIntegerPrimitive(Long value)protected intparseIntegerPrimitive(String value)protected StringparseOidPrimitive(String value)protected StringparseStringPrimitive(String value)protected StringparseTimePrimitive(String value)TypeparseType(byte[] bytes, String typeName)This is used to parse a type - a fragment of a resource.TypeparseType(String input, String typeName)This is used to parse a type - a fragment of a resource.protected StringparseUriPrimitive(String value)protected StringparseUuidPrimitive(String value)IParsersetAllowUnknownContent(boolean allowUnknownContent)IParsersetHandleComments(boolean value)IParsersetOutputStyle(IParser.OutputStyle style)IParsersetSuppressXhtml(String message)This method is used by the publication tooling to stop the xhrtml narrative being generated.-
Methods inherited from class org.hl7.fhir.dstu2.formats.FormatUtilities
isValidId, 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)
-
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:IParserparse content that is known to be a resource- Specified by:
parsein interfaceIParser- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorUnsupportedEncodingExceptionIOException
-
parse
public Resource parse(byte[] bytes) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParserparse content that is known to be a resource- Specified by:
parsein interfaceIParser- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
parseType
public Type parseType(String input, String typeName) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParserThis 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:
parseTypein interfaceIParsertypeName- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorUnsupportedEncodingExceptionIOException
-
parseType
public Type parseType(byte[] bytes, String typeName) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
Description copied from interface:IParserThis 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:
parseTypein interfaceIParsertypeName- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
composeString
public String composeString(Resource resource) throws IOException
Description copied from interface:IParserCompose 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:
composeStringin interfaceIParser- Throws:
IOException
-
composeBytes
public byte[] composeBytes(Resource resource) throws IOException
Description copied from interface:IParserCompose 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:
composeBytesin interfaceIParser- Throws:
IOException
-
composeString
public String composeString(Type type, String typeName) throws IOException
Description copied from interface:IParserCompose 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:
composeStringin interfaceIParser- Throws:
IOException
-
composeBytes
public byte[] composeBytes(Type type, String typeName) throws IOException
Description copied from interface:IParserCompose 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:
composeBytesin interfaceIParser- Throws:
IOException
-
setSuppressXhtml
public IParser setSuppressXhtml(String message)
Description copied from interface:IParserThis 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:
setSuppressXhtmlin interfaceIParser
-
getHandleComments
public boolean getHandleComments()
Description copied from interface:IParserWhether to parse or ignore comments - either reading or writing- Specified by:
getHandleCommentsin interfaceIParser
-
setHandleComments
public IParser setHandleComments(boolean value)
- Specified by:
setHandleCommentsin interfaceIParser
-
isAllowUnknownContent
public boolean isAllowUnknownContent()
- Specified by:
isAllowUnknownContentin interfaceIParser- Returns:
- Whether to throw an exception if unknown content is found (or just skip it)
-
setAllowUnknownContent
public IParser setAllowUnknownContent(boolean allowUnknownContent)
- Specified by:
setAllowUnknownContentin interfaceIParser- Parameters:
allowUnknownContent- Whether to throw an exception if unknown content is found (or just skip it)
-
getOutputStyle
public IParser.OutputStyle getOutputStyle()
Description copied from interface:IParserWriting:- Specified by:
getOutputStylein interfaceIParser
-
setOutputStyle
public IParser setOutputStyle(IParser.OutputStyle style)
- Specified by:
setOutputStylein 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)
-
-