Package com.ibm.fhir.model.parser
Class FHIRAbstractParser
- java.lang.Object
-
- com.ibm.fhir.model.parser.FHIRAbstractParser
-
- All Implemented Interfaces:
FHIRParser
- Direct Known Subclasses:
FHIRJsonParser
,FHIRXMLParser
public abstract class FHIRAbstractParser extends Object implements FHIRParser
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
ignoringUnrecognizedElements
protected Map<String,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(Class<T> parserClass)
Attempt to cast the FHIRParser to a specific subclassObject
getProperty(String name)
<T> T
getProperty(String name, Class<T> type)
Object
getPropertyOrDefault(String name, Object defaultValue)
<T> T
getPropertyOrDefault(String name, T defaultValue, Class<T> type)
boolean
isIgnoringUnrecognizedElements()
Indicates whether this parser is ignoring unrecognized elementsboolean
isPropertySupported(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(InputStream in)
Read a resource from the passed InputStream.abstract <T extends Resource>
Tparse(Reader reader)
Read a resource using the passed Reader.void
setIgnoringUnrecognizedElements(boolean ignoringUnrecognizedElements)
Set the ignoring unrecognized elements indicator for this parservoid
setProperty(String name, 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(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
-
parse
public abstract <T extends Resource> T parse(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
-
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(String name, 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 Object getProperty(String name)
- Specified by:
getProperty
in interfaceFHIRParser
- Returns:
- the property value or
null
if the property has no value
-
getProperty
public <T> T getProperty(String name, Class<T> type)
- Specified by:
getProperty
in interfaceFHIRParser
- Returns:
- the property value or
null
if the property has no value
-
getPropertyOrDefault
public Object getPropertyOrDefault(String name, Object defaultValue)
- Specified by:
getPropertyOrDefault
in interfaceFHIRParser
- Returns:
- the property value or
defaultValue
if the property has no value
-
getPropertyOrDefault
public <T> T getPropertyOrDefault(String name, T defaultValue, Class<T> type)
- Specified by:
getPropertyOrDefault
in interfaceFHIRParser
- Returns:
- the property value or
defaultValue
if the property has no value
-
isPropertySupported
public boolean isPropertySupported(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(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:
-
-