public class JsonDataWriterEngine extends java.lang.Object implements DataWriterEngine
DataWriterEngine.FooterMessage
Constructor and Description |
---|
JsonDataWriterEngine(java.io.OutputStream out,
SdmxSuperBeanRetrievalManager superBeanRetrievalManager) |
Modifier and Type | Method and Description |
---|---|
void |
close(DataWriterEngine.FooterMessage... footer)
Writes the footer message (if supported by the writer implementation), and then completes the XML document, closes off all the tags, closes any resources.
|
void |
startDataset(ProvisionAgreementBean provision,
DataflowBean dataflow,
DataStructureBean dataStructureBean,
DatasetHeaderBean header,
AnnotationBean... annotations)
Starts a dataset with the data conforming to the DSD.
|
void |
startGroup(java.lang.String groupId,
AnnotationBean... annotations)
Starts a group with the given id, the subsequent calls to
writeGroupKeyValue will write the id/values to this group. |
void |
startSeries(AnnotationBean... annotations)
Starts a new series, closes off any existing series keys or attribute/observations.
|
void |
writeAttributeValue(java.lang.String id,
java.lang.String value)
Writes an attribute value for the given id.
|
void |
writeGroupKeyValue(java.lang.String id,
java.lang.String value)
Writes a group key value, for example 'Country' is 'France'.
|
void |
writeHeader(HeaderBean header)
(Optional) Writes a header to the message, any missing mandatory attributes are defaulted.
|
void |
writeObservation(java.util.Date obsTime,
java.lang.String obsValue,
TIME_FORMAT sdmxTimeFormat,
AnnotationBean... annotations)
Writes an Observation value against the current series.
|
void |
writeObservation(java.lang.String obsConceptValue,
java.lang.String obsValue,
AnnotationBean... annotations)
Writes an observation, the observation concept is assumed to be that which has been defined to be at the observation level (as declared in the start dataset method DatasetHeaderBean).
|
void |
writeObservation(java.lang.String observationConceptId,
java.lang.String obsConceptValue,
java.lang.String obsValue,
AnnotationBean... annotations)
Writes an Observation value against the current series.
|
void |
writeSeriesKeyValue(java.lang.String id,
java.lang.String value)
Writes a series key value.
|
public JsonDataWriterEngine(java.io.OutputStream out, SdmxSuperBeanRetrievalManager superBeanRetrievalManager)
public void writeHeader(HeaderBean header)
WriterEngine
writeHeader
in interface WriterEngine
public void startDataset(ProvisionAgreementBean provision, DataflowBean dataflow, DataStructureBean dataStructureBean, DatasetHeaderBean header, AnnotationBean... annotations)
DataWriterEngine
startDataset
in interface DataWriterEngine
provision
- agreement (optional) The provision agreement can be provided to give extra information about the datasetdataflow
- (optional) The dataflow can be provided to give extra information about the datasetdataStructureBean
- (mandatory) the data structure is used to know the dimenisonality of the dataheader
- (optional) containing, amongst others, the dataset action, reporting dates, dimension at observation if null then the dimension at observation is
assumed to be TIME_PERIOD and the dataset action is assumed to be INFORMATIONannotations
- (optional) any additional annotations that are attached to the dataset, can be null if no annotations existpublic void startGroup(java.lang.String groupId, AnnotationBean... annotations)
DataWriterEngine
writeGroupKeyValue
will write the id/values to this group. After
the group key is complete writeAttributeValue
may be called to add attributes to this group.
Example Usage
A group 'demo' is made up of 3 concepts (Country/Sex/Status), and has an attribute (Collection).
DataWriterEngine dre = //Create instance
dre.startGroup("demo");
dre.writeGroupKeyValue("Country", "FR");
dre.writeGroupKeyValue("Sex", "M");
dre.writeGroupKeyValue("Status", "U");
dre.writeAttributeValue("Collection", "A");
Any subsequent calls, for example to start a series, or to start a new group, will close off this existing group.startGroup
in interface DataWriterEngine
groupId
- the id of the groupannotations
- any additional annotations that are attached to the group, can be null if no annotations existpublic void writeGroupKeyValue(java.lang.String id, java.lang.String value)
DataWriterEngine
startGroup
method must be called before calling this method to add the first id/value, as the WriterEngine needs to know what group to assign the id/values to.writeGroupKeyValue
in interface DataWriterEngine
id
- the id of the concept or dimensionvalue
- the value of the group keypublic void startSeries(AnnotationBean... annotations)
DataWriterEngine
startSeries
in interface DataWriterEngine
annotations
- any additional annotations that are attached to the series, can be null if no annotations existpublic void writeSeriesKeyValue(java.lang.String id, java.lang.String value)
DataWriterEngine
writeSeriesKeyValue
in interface DataWriterEngine
id
- the id of the value for example 'Country'value
- the value for the given id for example 'FR'public void writeAttributeValue(java.lang.String id, java.lang.String value)
DataWriterEngine
writeSeriesKeyValue
method call then it will write
the attribute at the series level. If it is called after a writeGroupKeyValue
it will write the attribute against the group.
If this method is called immediately after a writeObservation
method call then it will write the attribute at the observation level.writeAttributeValue
in interface DataWriterEngine
id
- the id of the given value for example 'OBS_STATUS'value
- the value for the given id for example 'M'public void writeObservation(java.lang.String obsConceptValue, java.lang.String obsValue, AnnotationBean... annotations)
DataWriterEngine
writeObservation
in interface DataWriterEngine
obsConceptValue
- may be the observation time, or the cross section valueobsValue
- the observation value - can be numericalannotations
- any additional annotations that are attached to the observation, can be null if no annotations existpublic void writeObservation(java.lang.String observationConceptId, java.lang.String obsConceptValue, java.lang.String obsValue, AnnotationBean... annotations)
DataWriterEngine
writeObservation
in interface DataWriterEngine
observationConceptId
- the concept id for the observation, for example 'COUNTRY'. If this is a Time Series, then the id will be DimensionBean.TIME_DIMENSION_FIXED_ID.obsValue
- the observation value - can be numericalannotations
- any additional annotations that are attached to the observation, can be null if no annotations existpublic void writeObservation(java.util.Date obsTime, java.lang.String obsValue, TIME_FORMAT sdmxTimeFormat, AnnotationBean... annotations)
DataWriterEngine
writeObservation
in interface DataWriterEngine
obsTime
- the time of the observationobsValue
- the observation value - can be numericalsdmxTimeFormat
- the time format to format the obsTime in when converting to a stringpublic void close(DataWriterEngine.FooterMessage... footer)
DataWriterEngine
close
in interface DataWriterEngine