Package org.hl7.fhir.r4.formats
Class JsonParserBase
- java.lang.Object
-
- org.hl7.fhir.r4.formats.FormatUtilities
-
- org.hl7.fhir.r4.formats.ParserBase
-
- org.hl7.fhir.r4.formats.JsonParserBase
-
- All Implemented Interfaces:
IParser
- Direct Known Subclasses:
JsonParser
public abstract class JsonParserBase extends ParserBase implements IParser
General parser for JSON content. You instantiate an JsonParser of these, but you actually use parse or parseGeneral defined on this class The two classes are separated to keep generated and manually maintained code apart.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hl7.fhir.r4.formats.IParser
IParser.OutputStyle
-
-
Field Summary
Fields Modifier and Type Field Description protected JsonCreatorjson-
Fields inherited from class org.hl7.fhir.r4.formats.ParserBase
allowComments, allowUnknownContent, handleComments, idMap, style, xhtmlMessage
-
Fields inherited from class org.hl7.fhir.r4.formats.FormatUtilities
FHIR_NS, ID_REGEX, NS_XSI, XHTML_NS
-
-
Constructor Summary
Constructors Constructor Description JsonParserBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleananyHasExtras(List<? extends Element> list)protected voidclose()protected voidcloseArray()protected voidcloseObject()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.voidcompose(JsonCreator writer, Resource resource)Compose a resource using a pre-existing JsonWriterprotected voidcomposeDomainResource(String name, DomainResource e)protected abstract voidcomposeResource(Resource resource)protected voidcomposeStringCore(String name, org.hl7.fhir.instance.model.api.IIdType value, boolean inArray)protected voidcomposeStringExtras(String name, org.hl7.fhir.instance.model.api.IIdType value, boolean inArray)protected abstract voidcomposeType(String prefix, Type type)protected abstract voidcomposeTypeInner(Type type)protected voidcomposeXhtml(String name, org.hl7.fhir.utilities.xhtml.XhtmlNode html)protected com.google.gson.JsonObjectgetJObject(com.google.gson.JsonObject parent, String name)ParserTypegetType()check what kind of parser this isprotected abstract booleanhasTypeName(com.google.gson.JsonObject json, String prefix)protected booleanmakeComments(Element element)protected voidopen(String name)protected voidopenArray(String name)protected voidopenObject(String name)Resourceparse(com.google.gson.JsonObject json)parse xml that is known to be a resource, and that has already been read into a JSON objectResourceparse(InputStream input)parse content that is known to be a resourceprotected abstract TypeparseAnyType(com.google.gson.JsonObject json, String type)TypeparseAnyType(InputStream input, String type)protected DomainResourceparseDomainResource(com.google.gson.JsonObject json)protected voidparseElementProperties(com.google.gson.JsonObject theAsJsonObject, org.hl7.fhir.instance.model.api.IIdType theReferenceElement)protected voidparseElementProperties(com.google.gson.JsonObject json, Element e)protected voidparseElementProperties(com.google.gson.JsonObject theAsJsonObject, IdType theReferenceElement)protected abstract ResourceparseResource(com.google.gson.JsonObject json)protected abstract TypeparseType(com.google.gson.JsonObject json, String type)TypeparseType(InputStream input, String type)This is used to parse a type - a fragment of a resource.protected abstract TypeparseType(String prefix, com.google.gson.JsonObject json)protected org.hl7.fhir.utilities.xhtml.XhtmlNodeparseXhtml(String value)protected voidprop(String name, Boolean value)protected voidprop(String name, Integer value)protected voidprop(String name, String value)protected voidprop(String name, BigDecimal value)protected voidpropNum(String name, String value)protected voidwriteNull(String name)-
Methods inherited from class org.hl7.fhir.r4.formats.ParserBase
composeBytes, composeBytes, composeString, composeString, getHandleComments, getOutputStyle, isAllowComments, isAllowUnknownContent, parse, parse, parseAnyType, parseAnyType, parseBase64BinaryPrimitive, parseBooleanPrimitive, parseBooleanPrimitive, parseCodePrimitive, parseDecimalPrimitive, parseDecimalPrimitive, parseIdPrimitive, parseIntegerPrimitive, parseIntegerPrimitive, parseOidPrimitive, parseStringPrimitive, parseTimePrimitive, parseType, parseType, parseUriPrimitive, parseUuidPrimitive, setAllowComments, setAllowUnknownContent, setHandleComments, setOutputStyle, setSuppressXhtml
-
Methods inherited from class org.hl7.fhir.r4.formats.FormatUtilities
determineFormat, determineFormat, isValidId, loadFile, loadFile, makeId, makeParser, makeParser, toString, toString, toString, toString, toString, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hl7.fhir.r4.formats.IParser
composeBytes, composeBytes, composeString, composeString, getHandleComments, getOutputStyle, isAllowUnknownContent, parse, parse, parseType, parseType, setAllowUnknownContent, setHandleComments, setOutputStyle, setSuppressXhtml
-
-
-
-
Field Detail
-
json
protected JsonCreator json
-
-
Constructor Detail
-
JsonParserBase
public JsonParserBase()
-
-
Method Detail
-
getType
public ParserType getType()
Description copied from interface:IParsercheck what kind of parser this is
-
parseResource
protected abstract Resource parseResource(com.google.gson.JsonObject json) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseType
protected abstract Type parseType(com.google.gson.JsonObject json, String type) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseAnyType
protected abstract Type parseAnyType(com.google.gson.JsonObject json, String type) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseType
protected abstract Type parseType(String prefix, com.google.gson.JsonObject json) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
hasTypeName
protected abstract boolean hasTypeName(com.google.gson.JsonObject json, String prefix)
-
composeResource
protected abstract void composeResource(Resource resource) throws IOException
- Throws:
IOException
-
composeTypeInner
protected abstract void composeTypeInner(Type type) throws IOException
- Throws:
IOException
-
parse
public Resource parse(InputStream input) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
Description copied from interface:IParserparse content that is known to be a resource- Specified by:
parsein interfaceIParser- Throws:
org.hl7.fhir.exceptions.FHIRFormatError- Parse content that is known to be a resourceIOException
-
parse
public Resource parse(com.google.gson.JsonObject json) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
parse xml that is known to be a resource, and that has already been read into a JSON object- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseType
public Type parseType(InputStream input, String type) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
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 interfaceIParsertype- . if this is blank, the parser may try to infer the type (xml only)- Returns:
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseAnyType
public Type parseAnyType(InputStream input, String type) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Specified by:
parseAnyTypein interfaceIParser- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
getJObject
protected com.google.gson.JsonObject getJObject(com.google.gson.JsonObject parent, String name) throws IOException
- Throws:
IOException
-
compose
public 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)- Specified by:
composein interfaceIParser- Throws:
IOException
-
compose
public void compose(JsonCreator writer, Resource resource) throws IOException
Compose a resource using a pre-existing JsonWriter- Throws:
IOException
-
compose
public void compose(OutputStream stream, Type type, String rootName) 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:
composein interfaceIParser- Throws:
IOException
-
parseElementProperties
protected void parseElementProperties(com.google.gson.JsonObject json, Element e) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseXhtml
protected org.hl7.fhir.utilities.xhtml.XhtmlNode parseXhtml(String value) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseDomainResource
protected DomainResource parseDomainResource(com.google.gson.JsonObject json) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
writeNull
protected void writeNull(String name) throws IOException
- Throws:
IOException
-
prop
protected void prop(String name, String value) throws IOException
- Throws:
IOException
-
prop
protected void prop(String name, Boolean value) throws IOException
- Throws:
IOException
-
prop
protected void prop(String name, BigDecimal value) throws IOException
- Throws:
IOException
-
propNum
protected void propNum(String name, String value) throws IOException
- Throws:
IOException
-
prop
protected void prop(String name, Integer value) throws IOException
- Throws:
IOException
-
composeXhtml
protected void composeXhtml(String name, org.hl7.fhir.utilities.xhtml.XhtmlNode html) throws IOException
- Throws:
IOException
-
open
protected void open(String name) throws IOException
- Throws:
IOException
-
close
protected void close() throws IOException
- Throws:
IOException
-
openArray
protected void openArray(String name) throws IOException
- Throws:
IOException
-
closeArray
protected void closeArray() throws IOException
- Throws:
IOException
-
openObject
protected void openObject(String name) throws IOException
- Throws:
IOException
-
closeObject
protected void closeObject() throws IOException
- Throws:
IOException
-
anyHasExtras
protected boolean anyHasExtras(List<? extends Element> list)
-
makeComments
protected boolean makeComments(Element element)
-
composeDomainResource
protected void composeDomainResource(String name, DomainResource e) throws IOException
- Throws:
IOException
-
composeType
protected abstract void composeType(String prefix, Type type) throws IOException
- Throws:
IOException
-
composeStringCore
protected void composeStringCore(String name, org.hl7.fhir.instance.model.api.IIdType value, boolean inArray) throws IOException
- Throws:
IOException
-
composeStringExtras
protected void composeStringExtras(String name, org.hl7.fhir.instance.model.api.IIdType value, boolean inArray) throws IOException
- Throws:
IOException
-
parseElementProperties
protected void parseElementProperties(com.google.gson.JsonObject theAsJsonObject, org.hl7.fhir.instance.model.api.IIdType theReferenceElement) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
parseElementProperties
protected void parseElementProperties(com.google.gson.JsonObject theAsJsonObject, IdType theReferenceElement) throws org.hl7.fhir.exceptions.FHIRFormatError, IOException
- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrorIOException
-
-