I use the ArcObjects 10.2 API for Java and I reported several incoherences between the API documentation and what I'm experiencing, especially regarding File GDB relative interface casts:
- The IFeatureClass objects are not castable to IFeatureClassLoad (needed to load data faster) unlike what it's written in the documentation: http://help.arcgis.com/en/sdk/10.0/java_ao_adf/api/arcobjects/com/esri/arcgis/geodatabase/IFeatureClassLoad.html
- The IWorkspace object is not castable to IWorkspace2 (needed to check name existence). I get that com.esri.arcgis.geodatabase.IWorkspaceProxy cannot be cast to com.esri.arcgis.geodatabase.IWorkspace2. However, the documentation says it's for Geodatabase and shapefiles: IWorkspace2 (ArcObjects Java API).
More about how I create or open my file geodatabases, maybe the solution is here:
// creation
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();
IWorkspaceName workspaceName = workspaceFactory.create(parentDirectory, gdbName, null, 0);
IName name = (IName)workspaceName;
IWorkspace workspace = new IWorkspaceProxy(name.open());
// opening
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();
IWorkspace workspace = workspaceFactory.openFromFile(gdbPath, 0);
// feature class creation
String geometryShapeFieldName = "Shape";
GeometryDef geometryDef = new GeometryDef();
geometryDef.setGeometryType(geometryType);
geometryDef.setSpatialReferenceByRef(spatialReference);
Field idField = new Field();
idField.setName("OBJECTID");
idField.setAliasName("OBJECTID");
idField.setType(esriFieldType.esriFieldTypeOID);
Field geometryShapeField = new Field();
geometryShapeField.setName(geometryShapeFieldName);
geometryShapeField.setType(esriFieldType.esriFieldTypeGeometry);
geometryShapeField.setGeometryDefByRef(geometryDef);
Fields fields = new Fields();
fields.addField(idField);
fields.addField(geometryShapeField);
IFeatureClassDescription fcDesc = new FeatureClassDescription();
IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;
IFeatureWorkspace featureWorkspace = new IFeatureWorkspaceProxy(workspace);
IFeatureDataset featureDataset = featureWorkspace.openFeatureDataset(name);
IFeatureClass featureClass = featureDataset.createFeatureClass(featureClassName, fields, ocDesc.getInstanceCLSID(), ocDesc.getClassExtensionCLSID(), esriFeatureType.esriFTSimple, geometryShapeFieldName, "");
// feature class opening
IGPUtilities gpUtilities = new GPUtilities();
IFeatureClass featureClass = gpUtilities.openFeatureClassFromString(featureClassFullPath);
boolean exists = ((IWorkspace2)workspace).isNameExists(esriDatasetType.esriDTFeatureClass, name); // don't work, cast exception
IFeatureClassLoad featureClassLoad = (IFeatureClassLoad)featureClass; // don't work either
featureClassLoad.setLoadOnlyMode(true);