Esri ArcObjects Snippets - Series
Print Field Names of Shapefile, Feature Class
// display field properties of each field in detail
static void displayFieldProperties(IFeatureClass featureClass)
throws Exception {
// Get the fields collection for the feature class.
IFields fields = featureClass.getFields();
IField field = null;
for (int i = 0; i < fields.getFieldCount(); i++) {
field = fields.getField(i);
// Get the standard field properties.
System.out.println("Name: " + field.getName());
System.out.println("Alias: " + field.getAliasName());
System.out.println("Type: " + field.getType());
System.out.println("VarType: " + field.getVarType());
System.out.println("Default Value: " + field.getDefaultValue());
System.out.println("Length: " + field.getLength());
System.out.println("Precision: " + field.getPrecision());
System.out.println("Scale: " + field.getScale());
System.out.println("Is Editable: " + field.isEditable());
System.out.println("Is Nullable: " + field.isNullable());
System.out.println("Is Required: " + field.isRequired());
// Check if the field is the shape field.
if (field.getType() == esriFieldType.esriFieldTypeGeometry) {
IGeometryDef geometryDef = field.getGeometryDef();
System.out.println("Geometry Type: "
+ geometryDef.getGeometryType());
System.out.println("Has M Values: " + geometryDef.isHasM());
System.out.println("Has Z Values: " + geometryDef.isHasZ());
}
// Insert an empty line for readability.
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