Esri ArcObjects Snippets - Series
Print Field Information of Feature Class
static void displayFields(IFeatureClass featureClass) throws Exception {
IFields fields = featureClass.getFields();
IField field;
for (int i = 0; i < fields.getFieldCount(); i++) {
field = fields.getField(i);
displayFieldInformation(field);
}
}
static void displayFieldInformation(IField field) throws Exception {
// Physical name.
System.out.println("Name : " + field.getName());
// Alias name.
System.out.println("Alias Name : " + field.getAliasName());
// Field type.
String value = "";
switch (field.getType()) {
case esriFieldType.esriFieldTypeSmallInteger:
value = "Small Integer";
break;
case esriFieldType.esriFieldTypeInteger:
value = "Long Integer";
break;
case esriFieldType.esriFieldTypeSingle:
value = "Single-precision floating-point number";
break;
case esriFieldType.esriFieldTypeDouble:
value = "Double-precision floating-point number";
break;
case esriFieldType.esriFieldTypeString:
value = "Character string";
break;
case esriFieldType.esriFieldTypeDate:
value = "Date";
break;
case esriFieldType.esriFieldTypeOID:
value = "Long Integer representing an object identifier";
break;
case esriFieldType.esriFieldTypeGeometry:
value = "Geometry";
break;
case esriFieldType.esriFieldTypeBlob:
value = "Binary Large Object, Blob Storage";
break;
case esriFieldType.esriFieldTypeRaster:
value = "Raster";
break;
case esriFieldType.esriFieldTypeGUID:
value = "Globally Unique Identifier";
break;
case esriFieldType.esriFieldTypeGlobalID:
value = "ESRI Global ID";
break;
case esriFieldType.esriFieldTypeXML:
value = "XML Document";
break;
}
System.out.println("Type : " + value);
// Field length—this is only valid for fields of Type
// esriFieldTypeString.
System.out.println("Length : " + field.getLength());
// Field precision.
System.out.println("Precision : " + field.getPrecision());
// Field scale.
System.out.println("Scale : " + field.getScale());
// Editable.
System.out.println("Editable : " + field.isEditable());
// Default value.
System.out.println("Default Value : " + field.getDefaultValue());
IGeometryDef geomDef = field.getGeometryDef();
if (geomDef != null) {
System.out.println("GeometryDef Properties");
System.out.println("AvgNumPoints : " + geomDef.getAvgNumPoints());
System.out.println("Grid Count : " + geomDef.getGridCount());
for (int i = 0; i < geomDef.getGridCount(); i++) {
System.out.println("Grid Size[" + i + "]="
+ geomDef.getGridSize(i));
}
System.out.println("Has Measures : " + geomDef.isHasM());
System.out.println("Has Z : " + geomDef.isHasZ());
System.out.println("Spatial Ref : "
+ geomDef.getSpatialReference().getName());
}
System.out.println("");
}
This code has been made using ESRI Resources and other Help Content and is provided here just for educational purpose.
No comments:
Post a Comment