Package org.hl7.fhir.r4.formats
Class XmlParserBase
- java.lang.Object
-
- org.hl7.fhir.r4.formats.FormatUtilities
-
- org.hl7.fhir.r4.formats.ParserBase
-
- org.hl7.fhir.r4.formats.XmlParserBase
-
- All Implemented Interfaces:
IParser
- Direct Known Subclasses:
XmlParser
public abstract class XmlParserBase extends ParserBase implements IParser
General parser for XML content. You instantiate an XmlParser 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 Modifier and Type Class Description static classXmlParserBase.XmlVersion-
Nested classes/interfaces inherited from interface org.hl7.fhir.r4.formats.IParser
IParser.OutputStyle
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>commentsprotected booleanhtmlPrettyprotected org.hl7.fhir.utilities.xml.IXMLWriterxml-
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 XmlParserBase()XmlParserBase(XmlParserBase.XmlVersion ver)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcompose(OutputStream stream, String rootName, Type type)Compose a type to a stream (used in the spec, for example, but not normally in production)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, Resource resource, boolean htmlPretty)Compose a resource to a stream, possibly using pretty presentation for a human reader, and maybe a different choice in the xhtml narrative (used in the spec in one place, but should not be used 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(org.hl7.fhir.utilities.xml.IXMLWriter writer, Resource resource, boolean htmlPretty)protected voidcomposeDomainResource(String name, DomainResource res)protected voidcomposeElementAttributes(Element element)protected voidcomposeElementClose(Base base)protected abstract voidcomposeResource(String name, Resource res)protected abstract voidcomposeResource(Resource resource)protected voidcomposeString(String name, org.hl7.fhir.instance.model.api.IIdType value)protected abstract voidcomposeString(String name, StringType value)protected abstract voidcomposeType(String prefix, Type type)protected voidcomposeTypeAttributes(Type type)protected voidcomposeXhtml(String name, org.hl7.fhir.utilities.xhtml.XhtmlNode html)ParserTypegetType()check what kind of parser this isprotected org.xmlpull.v1.XmlPullParserloadXml(InputStream stream)protected org.xmlpull.v1.XmlPullParserloadXml(String source)protected intnext(org.xmlpull.v1.XmlPullParser xpp)protected intnextNoWhitespace(org.xmlpull.v1.XmlPullParser xpp)Resourceparse(InputStream input)Parse content that is known to be a resourceResourceparse(org.xmlpull.v1.XmlPullParser xpp)parse xml that is known to be a resource, and that is already being read by an XML Pull Parser This is if a resource is in a bigger piece of XML.TypeparseAnyType(InputStream input, String knownType)protected abstract TypeparseAnyType(org.xmlpull.v1.XmlPullParser xml, String type)protected voidparseBackboneAttributes(org.xmlpull.v1.XmlPullParser xpp, Element e)protected DomainResourceparseDomainResourceContained(org.xmlpull.v1.XmlPullParser xpp)protected voidparseElementAttributes(org.xmlpull.v1.XmlPullParser xpp, Element e)protected voidparseElementClose(Base e)protected abstract ResourceparseResource(org.xmlpull.v1.XmlPullParser xpp)protected ResourceparseResourceContained(org.xmlpull.v1.XmlPullParser xpp)TypeparseType(InputStream input, String knownType)This is used to parse a type - a fragment of a resource.protected abstract TypeparseType(org.xmlpull.v1.XmlPullParser xml, String type)protected voidparseTypeAttributes(org.xmlpull.v1.XmlPullParser xpp, Type t)protected org.hl7.fhir.utilities.xhtml.XhtmlNodeparseXhtml(org.xmlpull.v1.XmlPullParser xpp)protected voidskipElementWithContent(org.xmlpull.v1.XmlPullParser xpp)protected voidskipEmptyElement(org.xmlpull.v1.XmlPullParser xpp)protected voidunknownContent(org.xmlpull.v1.XmlPullParser xpp)-
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
-
xml
protected org.hl7.fhir.utilities.xml.IXMLWriter xml
-
htmlPretty
protected boolean htmlPretty
-
-
Constructor Detail
-
XmlParserBase
public XmlParserBase(XmlParserBase.XmlVersion ver)
-
XmlParserBase
public XmlParserBase()
-
-
Method Detail
-
getType
public ParserType getType()
Description copied from interface:IParsercheck what kind of parser this is
-
parseResource
protected abstract Resource parseResource(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseType
protected abstract Type parseType(org.xmlpull.v1.XmlPullParser xml, String type) throws org.xmlpull.v1.XmlPullParserException, IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseAnyType
protected abstract Type parseAnyType(org.xmlpull.v1.XmlPullParser xml, String type) throws org.xmlpull.v1.XmlPullParserException, IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
composeType
protected abstract void composeType(String prefix, Type type) throws IOException
- Throws:
IOException
-
parse
public Resource parse(InputStream input) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
Parse content that is known to be a resource- Specified by:
parsein interfaceIParser- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parse
public Resource parse(org.xmlpull.v1.XmlPullParser xpp) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError, org.xmlpull.v1.XmlPullParserException
parse xml that is known to be a resource, and that is already being read by an XML Pull Parser This is if a resource is in a bigger piece of XML.- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatErrororg.xmlpull.v1.XmlPullParserException
-
parseType
public Type parseType(InputStream input, String knownType) 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 interfaceIParserknownType- . 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 knownType) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Specified by:
parseAnyTypein interfaceIParser- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
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(OutputStream stream, Resource resource, boolean htmlPretty) throws IOException
Compose a resource to a stream, possibly using pretty presentation for a human reader, and maybe a different choice in the xhtml narrative (used in the spec in one place, but should not be used in production)- Throws:
IOException
-
compose
public void compose(OutputStream stream, String rootName, Type type) throws IOException
Compose a type to a stream (used in the spec, for example, but not normally in production)- 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
-
loadXml
protected org.xmlpull.v1.XmlPullParser loadXml(String source) throws UnsupportedEncodingException, org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
UnsupportedEncodingExceptionorg.xmlpull.v1.XmlPullParserExceptionIOException
-
loadXml
protected org.xmlpull.v1.XmlPullParser loadXml(InputStream stream) throws org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOException
-
next
protected int next(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOException
-
nextNoWhitespace
protected int nextNoWhitespace(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOException
-
skipElementWithContent
protected void skipElementWithContent(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOException
-
skipEmptyElement
protected void skipEmptyElement(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOException
-
parseTypeAttributes
protected void parseTypeAttributes(org.xmlpull.v1.XmlPullParser xpp, Type t)
-
parseElementAttributes
protected void parseElementAttributes(org.xmlpull.v1.XmlPullParser xpp, Element e)
-
parseElementClose
protected void parseElementClose(Base e)
-
parseBackboneAttributes
protected void parseBackboneAttributes(org.xmlpull.v1.XmlPullParser xpp, Element e)
-
unknownContent
protected void unknownContent(org.xmlpull.v1.XmlPullParser xpp) throws org.hl7.fhir.exceptions.FHIRFormatError, org.xmlpull.v1.XmlPullParserException, IOException
- Throws:
org.hl7.fhir.exceptions.FHIRFormatErrororg.xmlpull.v1.XmlPullParserExceptionIOException
-
parseXhtml
protected org.hl7.fhir.utilities.xhtml.XhtmlNode parseXhtml(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException, org.hl7.fhir.exceptions.FHIRFormatError
- Throws:
org.xmlpull.v1.XmlPullParserExceptionIOExceptionorg.hl7.fhir.exceptions.FHIRFormatError
-
parseDomainResourceContained
protected DomainResource parseDomainResourceContained(org.xmlpull.v1.XmlPullParser xpp) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError, org.xmlpull.v1.XmlPullParserException
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatErrororg.xmlpull.v1.XmlPullParserException
-
parseResourceContained
protected Resource parseResourceContained(org.xmlpull.v1.XmlPullParser xpp) throws IOException, org.hl7.fhir.exceptions.FHIRFormatError, org.xmlpull.v1.XmlPullParserException
- Throws:
IOExceptionorg.hl7.fhir.exceptions.FHIRFormatErrororg.xmlpull.v1.XmlPullParserException
-
compose
public void compose(org.hl7.fhir.utilities.xml.IXMLWriter writer, Resource resource, boolean htmlPretty) throws IOException
- Throws:
IOException
-
composeResource
protected abstract void composeResource(Resource resource) throws IOException
- Throws:
IOException
-
composeElementAttributes
protected void composeElementAttributes(Element element) throws IOException
- Throws:
IOException
-
composeElementClose
protected void composeElementClose(Base base) throws IOException
- Throws:
IOException
-
composeTypeAttributes
protected void composeTypeAttributes(Type type) throws IOException
- Throws:
IOException
-
composeXhtml
protected void composeXhtml(String name, org.hl7.fhir.utilities.xhtml.XhtmlNode html) throws IOException
- Throws:
IOException
-
composeString
protected abstract void composeString(String name, StringType value) throws IOException
- Throws:
IOException
-
composeString
protected void composeString(String name, org.hl7.fhir.instance.model.api.IIdType value) throws IOException
- Throws:
IOException
-
composeDomainResource
protected void composeDomainResource(String name, DomainResource res) throws IOException
- Throws:
IOException
-
composeResource
protected abstract void composeResource(String name, Resource res) throws IOException
- Throws:
IOException
-
-