private static AttributeType readAttributeType(DataInput in, FeatureTypeFactory typeFactory)
throws IOException {
final Name name = readName(in);
final byte typeTag = in.readByte();
final FieldType type = FieldType.valueOf(typeTag);
if (Geometry.class.isAssignableFrom(type.getBinding())) {
final boolean isCRSCode = in.readBoolean(); // as opposed to a raw WKT string
final String crsText = in.readUTF();
final CoordinateReferenceSystem crs;
try {
if (isCRSCode) {
if ("urn:ogc:def:crs:EPSG::0".equals(crsText)) {
crs = null;
} else {
boolean forceLongitudeFirst = crsText.startsWith("EPSG:");
crs = CRS.decode(crsText, forceLongitudeFirst);
}
} else {
crs = CRS.parseWKT(crsText);
}
} catch (FactoryException e) {
throw new RuntimeException(e);
}
return typeFactory.createGeometryType(name, type.getBinding(), crs, false, false,
Collections.<Filter> emptyList(), null, null);
} else {
return typeFactory.createAttributeType(name, type.getBinding(), false, false,
Collections.<Filter> emptyList(), null, null);
}
}