Package com.ibm.fhir.model.generator
Interface FHIRGenerator
-
- All Known Implementing Classes:
FHIRAbstractGenerator,FHIRJsonGenerator,FHIRXMLGenerator
public interface FHIRGeneratorGenerate FHIR resource representations from fhir-model objects
-
-
Field Summary
Fields Modifier and Type Field Description static StringPROPERTY_INDENT_AMOUNTProperty name for a property that controls the amount of indentation to use for each indentation "level"
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends FHIRGenerator>
Tas(Class<T> generatorClass)voidgenerate(Visitable visitable, OutputStream out)Writevisitableto the passed OutputStream.voidgenerate(Visitable visitable, Writer writer)Writevisitableusing the passed Writer.static FHIRGeneratorgenerator(Format format)Create a FHIRGenerator (without pretty-printing) for the given format.static FHIRGeneratorgenerator(Format format, boolean prettyPrinting)Create a FHIRGenerator for the given format.ObjectgetProperty(String name)<T> TgetProperty(String name, Class<T> type)ObjectgetPropertyOrDefault(String name, Object defaultValue)<T> TgetPropertyOrDefault(String name, T defaultValue, Class<T> type)booleanisPrettyPrinting()booleanisPropertySupported(String name)Whether the generator supports the property with the passed namevoidsetProperty(String name, Object value)Set the property with the given name to the passed value
-
-
-
Field Detail
-
PROPERTY_INDENT_AMOUNT
static final String PROPERTY_INDENT_AMOUNT
Property name for a property that controls the amount of indentation to use for each indentation "level"- See Also:
- Constant Field Values
-
-
Method Detail
-
generate
void generate(Visitable visitable, OutputStream out) throws FHIRGeneratorException
Writevisitableto the passed OutputStream. This method does not close the passed OutputStream. Forvisitableof type Resource, this serializes the resource in accordance with the specification. Forvisitableof type Element, this serializes the element content using a suitable wrapper for the configured format.- Parameters:
visitable- The visitable Resource or Element to serializeout-- Throws:
FHIRGeneratorException
-
generate
void generate(Visitable visitable, Writer writer) throws FHIRGeneratorException
Writevisitableusing the passed Writer. This method does not close the passed Writer. Forvisitableof type Resource, this serializes the resource in accordance with the specification. Forvisitableof type Element, this serializes the element content using a suitable wrapper for the configured format.- Parameters:
visitable- The visitable Resource or Element to serializewriter-- Throws:
FHIRGeneratorException
-
isPrettyPrinting
boolean isPrettyPrinting()
- Returns:
- whether this FHIRGenerator is configured to pretty-print its output
-
setProperty
void setProperty(String name, Object value)
Set the property with the given name to the passed value- Throws:
IllegalArgumentException- if the propertynameis unknown or unsupported
-
getProperty
Object getProperty(String name)
- Returns:
- the property value or
nullif the property has no value
-
getPropertyOrDefault
Object getPropertyOrDefault(String name, Object defaultValue)
- Returns:
- the property value or
defaultValueif the property has no value
-
getProperty
<T> T getProperty(String name, Class<T> type)
- Returns:
- the property value or
nullif the property has no value
-
getPropertyOrDefault
<T> T getPropertyOrDefault(String name, T defaultValue, Class<T> type)
- Returns:
- the property value or
defaultValueif the property has no value
-
isPropertySupported
boolean isPropertySupported(String name)
Whether the generator supports the property with the passed name
-
as
<T extends FHIRGenerator> T as(Class<T> generatorClass)
-
generator
static FHIRGenerator generator(Format format)
Create a FHIRGenerator (without pretty-printing) for the given format.- Parameters:
format-- Returns:
- Throws:
IllegalArgumentException- ifformatis not supported
-
generator
static FHIRGenerator generator(Format format, boolean prettyPrinting)
Create a FHIRGenerator for the given format.- Parameters:
format-prettyPrinting- whether the returned FHIRGenerator should pretty-print its output- Returns:
- Throws:
IllegalArgumentException- ifformatis not supported
-
-