arcgissamples\geoprocessing\customtool\DFFunctionFactory.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.geoprocessing.customtool; import java.io.IOException; import java.util.UUID; import com.esri.arcgis.geodatabase.IEnumGPName; import com.esri.arcgis.geodatabase.IGPName; import com.esri.arcgis.geoprocessing.EnumGPName; import com.esri.arcgis.geoprocessing.GPFunctionName; import com.esri.arcgis.geoprocessing.IEnumGPEnvironment; import com.esri.arcgis.geoprocessing.IGPFunction; import com.esri.arcgis.geoprocessing.IGPFunctionFactory; import com.esri.arcgis.interop.AutomationException; import com.esri.arcgis.interop.extn.ArcGISCategories; import com.esri.arcgis.interop.extn.ArcGISExtension; import com.esri.arcgis.system.IUID; import com.esri.arcgis.system.UID; import com.esri.arcgis.system.esriProductCode; @ArcGISExtension(categories = { ArcGISCategories.GPFunctionFactories }) public class DFFunctionFactory implements IGPFunctionFactory { private String functionFactoryAlias = "dffunctionfactory"; private String factoryName = "DFFunctionFactory"; private String category = "DeleteFeaturesJavaToolset"; private String deleteFeaturesToolName = "DeleteFeatures"; private String deleteFeaturesToolDisplayName = "Java DeleteFeatures Tool"; /** * Returns the appropriate GPFunction object based on specified tool name */ public IGPFunction getFunction(String name) throws IOException, AutomationException { if (name.equalsIgnoreCase(deleteFeaturesToolName)) { return new DeleteFeatures(); } return null; } /** * Returns a GPFunctionName objects based on specified tool name */ public IGPName getFunctionName(String name) throws IOException, AutomationException { if (name.equalsIgnoreCase(deleteFeaturesToolName)) { GPFunctionName functionName = new GPFunctionName(); functionName.setCategory(category); functionName.setDescription("Deletes features based on expressions - implemented in Java"); functionName.setDisplayName(deleteFeaturesToolDisplayName); functionName.setName(deleteFeaturesToolName); functionName.setMinimumProduct(esriProductCode.esriProductCodeProfessional); functionName.setFactoryByRef(this); return functionName; } return null; } /** * Returns names of all gp tools created by this function factory */ public IEnumGPName getFunctionNames() throws IOException, AutomationException { EnumGPName nameArray = new EnumGPName(); nameArray.add(getFunctionName(deleteFeaturesToolName)); return nameArray; } /** * Returns Alias of the function factory */ public String getAlias() throws IOException, AutomationException { return functionFactoryAlias; } /** * Returns Class ID */ public IUID getCLSID() throws IOException, AutomationException { UID uid = new UID(); uid.setValue("{" + UUID.nameUUIDFromBytes(this.getClass().getName().getBytes()) + "}"); return uid; } /** * Returns Function Environments */ public IEnumGPEnvironment getFunctionEnvironments() throws IOException, AutomationException { return null; } /** * Returns name of the FunctionFactory */ public String getName() throws IOException, AutomationException { return factoryName; } }