arcgissamples\geoprocessing\customtool\FLFunctionFactory.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 FLFunctionFactory implements IGPFunctionFactory { private String functionFactoryAlias = "flfunctionfactory"; private String factoryName = "FLFunctionFactory"; private String category = "Java Find Locations Toolset"; private String findLocationsToolName = "FindLocations"; private String findLocationsToolDisplayName = "Java Location Finder Tool"; /** * Returns the appropriate GPFunction object based on specified tool name */ public IGPFunction getFunction(String name) throws IOException, AutomationException { if (name.equalsIgnoreCase(findLocationsToolName)) { FindLocations findLocations = new FindLocations(); return findLocations; } return null; } /** * Returns a GPFunctionName objects based on specified tool name */ public IGPName getFunctionName(String name) throws IOException, AutomationException { if (name.equalsIgnoreCase(findLocationsToolName)) { GPFunctionName functionName = new GPFunctionName(); functionName.setCategory(category); functionName.setDescription("Find Locations - implemented in Java"); functionName.setDisplayName(findLocationsToolDisplayName); functionName.setName(findLocationsToolName); 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(findLocationsToolName)); 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; } }