public class GenericDataWriterEngine extends SdmxDataWriterEngine
DataWriterEngine.FooterMessage
Constructor and Description |
---|
GenericDataWriterEngine(SDMX_SCHEMA schemaVersion,
java.io.OutputStream out) |
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 dsd,
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 conceptId,
java.lang.String conceptValue)
Writes an attribute value for the given id.
|
void |
writeGroupKeyValue(java.lang.String conceptId,
java.lang.String conceptValue)
Writes a group key value, for example 'Country' is 'France'.
|
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 obsConceptId,
java.lang.String obsConceptValue,
java.lang.String obsValue,
AnnotationBean... annotations)
Writes an Observation value against the current series.
|
void |
writeSeriesKeyValue(java.lang.String dimensionId,
java.lang.String dimensionValue)
Writes a series key value.
|
writeDatasetAttribute, writeHeader, writeObservation
public GenericDataWriterEngine(SDMX_SCHEMA schemaVersion, java.io.OutputStream out)
public void startDataset(ProvisionAgreementBean provision, DataflowBean dataflow, DataStructureBean dsd, DatasetHeaderBean header, AnnotationBean... annotations)
DataWriterEngine
startDataset
in interface DataWriterEngine
startDataset
in class SdmxDataWriterEngine
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 datasetdsd
- (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 startSeries(AnnotationBean... annotations)
DataWriterEngine
startSeries
in interface DataWriterEngine
startSeries
in class SdmxDataWriterEngine
annotations
- any additional annotations that are attached to the series, can be null if no annotations existpublic void close(DataWriterEngine.FooterMessage... footer)
DataWriterEngine
close
in interface DataWriterEngine
close
in class SdmxDataWriterEngine
public void writeAttributeValue(java.lang.String conceptId, java.lang.String conceptValue)
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
writeAttributeValue
in class SdmxDataWriterEngine
conceptId
- the id of the given value for example 'OBS_STATUS'conceptValue
- the value for the given id for example 'M'public void writeGroupKeyValue(java.lang.String conceptId, java.lang.String conceptValue)
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
writeGroupKeyValue
in class SdmxDataWriterEngine
conceptId
- the id of the concept or dimensionconceptValue
- the value of the group keypublic void writeSeriesKeyValue(java.lang.String dimensionId, java.lang.String dimensionValue)
DataWriterEngine
writeSeriesKeyValue
in interface DataWriterEngine
writeSeriesKeyValue
in class SdmxDataWriterEngine
dimensionId
- the id of the value for example 'Country'dimensionValue
- the value for the given id for example 'FR'public void writeObservation(java.lang.String obsConceptValue, java.lang.String obsValue, AnnotationBean... annotations)
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 obsConceptId, java.lang.String obsConceptValue, java.lang.String obsValue, AnnotationBean... annotations)
DataWriterEngine
writeObservation
in interface DataWriterEngine
writeObservation
in class SdmxDataWriterEngine
obsConceptId
- 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 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
startGroup
in class SdmxDataWriterEngine
groupId
- the id of the groupannotations
- any additional annotations that are attached to the group, can be null if no annotations exist