Search in sources :

Example 1 with EnumerationDataType

use of com.revolsys.datatype.EnumerationDataType in project com.revolsys.open by revolsys.

the class OsnSerializer method serializeAttributes.

public void serializeAttributes(final Record object) throws IOException {
    final RecordDefinition type = object.getRecordDefinition();
    final int attributeCount = type.getFieldCount();
    for (int i = 0; i < attributeCount; i++) {
        final Object value = object.getValue(i);
        if (value != null) {
            final String name = type.getFieldName(i);
            final DataType dataType = type.getFieldType(i);
            if (dataType instanceof EnumerationDataType) {
                fieldName(name);
                write(value.toString());
                endAttribute();
            } else {
                serializeAttribute(name, value);
            }
            if (this.indentEnabled) {
                endLine();
            }
            if (!this.endElement) {
                if (i < attributeCount - 1) {
                    endLine();
                } else if (type.getName().equals("/Coord3D")) {
                    for (final Object parent : this.scope) {
                        if (parent instanceof Record) {
                            final Record parentObject = (Record) parent;
                            if (parentObject.getRecordDefinition().getName().equals(SaifConstants.TEXT_ON_CURVE)) {
                                endLine();
                            }
                        }
                    }
                } else {
                    endLine();
                }
            }
        }
    }
}
Also used : EnumerationDataType(com.revolsys.datatype.EnumerationDataType) EnumerationDataType(com.revolsys.datatype.EnumerationDataType) DataType(com.revolsys.datatype.DataType) Record(com.revolsys.record.Record) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

DataType (com.revolsys.datatype.DataType)1 EnumerationDataType (com.revolsys.datatype.EnumerationDataType)1 LineString (com.revolsys.geometry.model.LineString)1 Point (com.revolsys.geometry.model.Point)1 Record (com.revolsys.record.Record)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1