@Configurable public class EDIDataWriterEngineImpl extends java.lang.Object implements EDIDataWriterEngine
DataWriterEngine.FooterMessage
Constructor and Description |
---|
EDIDataWriterEngineImpl(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 |
setCrossSectionConcept(java.lang.String concept) |
void |
startDataset(ProvisionAgreementBean prov,
DataflowBean flow,
DataStructureBean dsd,
DatasetHeaderBean datasetHeader,
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 attributeId,
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 |
writeHeader(HeaderBean header)
Writes out the start of the message:
UNA:+.? '
UNB+[metadata such as date of preparation and receiving agency]
UNH+
NAD+MR+[sender acy]
NAD+MS+[rec acy]
DSI+[dataset id]
STS+3 [status code]
DTM [dataset preparation date]
IDE+5+[dsd id]
GIS+AR3
GIS+1
|
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 obsTime,
java.lang.String obsValue,
AnnotationBean... annotations)
Writes an Observation value against the current series.
|
void |
writeSeriesKeyValue(java.lang.String conceptId,
java.lang.String conceptValue)
Writes a series key value.
|
public void writeHeader(HeaderBean header)
writeHeader
in interface WriterEngine
header
- public void startDataset(ProvisionAgreementBean prov, DataflowBean flow, DataStructureBean dsd, DatasetHeaderBean datasetHeader, AnnotationBean... annotations)
DataWriterEngine
startDataset
in interface DataWriterEngine
prov
- agreement (optional) The provision agreement can be provided to give extra information about the datasetflow
- (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 datadatasetHeader
- (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 setCrossSectionConcept(java.lang.String concept) throws SdmxNotImplementedException
SdmxNotImplementedException
public 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 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
conceptId
- the id of the concept or dimensionconceptValue
- 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 conceptId, java.lang.String conceptValue)
DataWriterEngine
writeSeriesKeyValue
in interface DataWriterEngine
conceptId
- the id of the value for example 'Country'conceptValue
- the value for the given id for example 'FR'public void writeAttributeValue(java.lang.String attributeId, 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
attributeId
- the id of the given value for example 'OBS_STATUS'conceptValue
- 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 obsTime, 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