Class FHIRAbstractParser
- java.lang.Object
-
- org.linuxforhealth.fhir.model.parser.FHIRAbstractParser
-
- All Implemented Interfaces:
FHIRParser
- Direct Known Subclasses:
FHIRJsonParser
,FHIRXMLParser
public abstract class FHIRAbstractParser extends java.lang.Object implements FHIRParser
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
ignoringUnrecognizedElements
protected java.util.Map<java.lang.String,java.lang.Object>
properties
protected boolean
validating
-
Constructor Summary
Constructors Constructor Description FHIRAbstractParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T extends FHIRParser>
Tas(java.lang.Class<T> parserClass)
Attempt to cast the FHIRParser to a specific subclassjava.lang.Object
getProperty(java.lang.String name)
<T> T
getProperty(java.lang.String name, java.lang.Class<T> type)
java.lang.Object
getPropertyOrDefault(java.lang.String name, java.lang.Object defaultValue)
<T> T
getPropertyOrDefault(java.lang.String name, T defaultValue, java.lang.Class<T> type)
boolean
isIgnoringUnrecognizedElements()
Indicates whether this parser is ignoring unrecognized elementsboolean
isPropertySupported(java.lang.String name)
Whether the generator supports the property with the passed nameboolean
isValidating()
Indicates whether this parser is a validating parserabstract <T extends Resource>
Tparse(java.io.InputStream in)
Read a resource from the passed InputStream.abstract <T extends Resource>
Tparse(java.io.Reader reader)
Read a resource using the passed Reader.void
setIgnoringUnrecognizedElements(boolean ignoringUnrecognizedElements)
Set the ignoring unrecognized elements indicator for this parservoid
setProperty(java.lang.String name, java.lang.Object value)
Set the property with the given name to the passed valuevoid
setValidating(boolean validating)
Set the validating parser indicator for this parser
-
-
-
Method Detail
-
parse
public abstract <T extends Resource> T parse(java.io.InputStream in) throws FHIRParserException
Description copied from interface:FHIRParser
Read a resource from the passed InputStream. This method does not close the passed InputStream.- Specified by:
parse
in interfaceFHIRParser
- Type Parameters:
T
- The resource type to read- Returns:
- Throws:
FHIRParserException
- if the resource could not be parsed for any reason
-
parse
public abstract <T extends Resource> T parse(java.io.Reader reader) throws FHIRParserException
Description copied from interface:FHIRParser
Read a resource using the passed Reader. This method does not close the passed Reader.- Specified by:
parse
in interfaceFHIRParser
- Type Parameters:
T
- The resource type to read- Returns:
- Throws:
FHIRParserException
- if the resource could not be parsed for any reason
-
setValidating
public void setValidating(boolean validating)
Description copied from interface:FHIRParser
Set the validating parser indicator for this parserA validating parser performs basic validation during parsing / deserialization of the input format including:
- element cardinality checking
- element type checking
- element value checking
- Specified by:
setValidating
in interfaceFHIRParser
- Parameters:
validating
- the validating parser indicator- See Also:
ValidationSupport
-
isValidating
public boolean isValidating()
Description copied from interface:FHIRParser
Indicates whether this parser is a validating parser- Specified by:
isValidating
in interfaceFHIRParser
- Returns:
- true if this parser is a validating parser, false otherwise
-
setIgnoringUnrecognizedElements
public void setIgnoringUnrecognizedElements(boolean ignoringUnrecognizedElements)
Description copied from interface:FHIRParser
Set the ignoring unrecognized elements indicator for this parser- Specified by:
setIgnoringUnrecognizedElements
in interfaceFHIRParser
- Parameters:
ignoringUnrecognizedElements
- the ignoring unrecognized elements indicator
-
isIgnoringUnrecognizedElements
public boolean isIgnoringUnrecognizedElements()
Description copied from interface:FHIRParser
Indicates whether this parser is ignoring unrecognized elements- Specified by:
isIgnoringUnrecognizedElements
in interfaceFHIRParser
- Returns:
- true if this parser is ignoring unrecognized elements, false otherwise
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)
Description copied from interface:FHIRParser
Set the property with the given name to the passed value- Specified by:
setProperty
in interfaceFHIRParser
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getProperty
in interfaceFHIRParser
- Returns:
- the property value or
null
if the property has no value
-
getProperty
public <T> T getProperty(java.lang.String name, java.lang.Class<T> type)
- Specified by:
getProperty
in interfaceFHIRParser
- Returns:
- the property value or
null
if the property has no value
-
getPropertyOrDefault
public java.lang.Object getPropertyOrDefault(java.lang.String name, java.lang.Object defaultValue)
- Specified by:
getPropertyOrDefault
in interfaceFHIRParser
- Returns:
- the property value or
defaultValue
if the property has no value
-
getPropertyOrDefault
public <T> T getPropertyOrDefault(java.lang.String name, T defaultValue, java.lang.Class<T> type)
- Specified by:
getPropertyOrDefault
in interfaceFHIRParser
- Returns:
- the property value or
defaultValue
if the property has no value
-
isPropertySupported
public boolean isPropertySupported(java.lang.String name)
Description copied from interface:FHIRParser
Whether the generator supports the property with the passed name- Specified by:
isPropertySupported
in interfaceFHIRParser
-
as
public <T extends FHIRParser> T as(java.lang.Class<T> parserClass)
Description copied from interface:FHIRParser
Attempt to cast the FHIRParser to a specific subclass- Specified by:
as
in interfaceFHIRParser
- Type Parameters:
T
- The FHIRParser subclass to cast to- Returns:
-
-