Search in sources :

Example 1 with GmlFieldType

use of com.revolsys.record.io.format.gml.type.GmlFieldType in project com.revolsys.open by revolsys.

the class GmlRecordWriter method write.

@Override
public void write(final Record record) {
    if (!this.opened) {
        writeHeader();
    }
    this.out.startTag(Gml.FEATURE_MEMBER);
    final RecordDefinition recordDefinition = record.getRecordDefinition();
    QName qualifiedName = recordDefinition.getProperty(RecordProperties.QUALIFIED_NAME);
    if (qualifiedName == null) {
        final String typeName = recordDefinition.getPath();
        final String path = PathUtil.getPath(typeName);
        final String name = PathUtil.getName(typeName);
        qualifiedName = new QName(path, name);
        recordDefinition.setProperty(RecordProperties.QUALIFIED_NAME, qualifiedName);
    }
    this.out.startTag(qualifiedName);
    for (final FieldDefinition fieldDefinition : recordDefinition.getFields()) {
        final String fieldName = fieldDefinition.getName();
        final Object value;
        if (isWriteCodeValues()) {
            value = record.getCodeValue(fieldName);
        } else {
            value = record.getValue(fieldName);
        }
        if (isValueWritable(value)) {
            this.out.startTag(this.namespaceUri, fieldName);
            final DataType dataType = fieldDefinition.getDataType();
            final GmlFieldType fieldType = this.fieldTypes.getFieldType(dataType);
            if (fieldType != null) {
                fieldType.writeValue(this.out, value);
            }
            this.out.endTag();
        }
    }
    this.out.endTag(qualifiedName);
    this.out.endTag(Gml.FEATURE_MEMBER);
}
Also used : GmlFieldType(com.revolsys.record.io.format.gml.type.GmlFieldType) QName(javax.xml.namespace.QName) FieldDefinition(com.revolsys.record.schema.FieldDefinition) DataType(com.revolsys.datatype.DataType) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

DataType (com.revolsys.datatype.DataType)1 GmlFieldType (com.revolsys.record.io.format.gml.type.GmlFieldType)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 QName (javax.xml.namespace.QName)1