Standalone Tool Adapter |

### Operator structure

Simply put, an adapter operator has the following folder structure:

ADAPTER_FOLDER

- META-INF
  - MANIFEST.MF
  - descriptor.xml
- org
  - esa
    - snap
      - ui
        - tooladapter
          - layer.xml
      - utils
        - ModuleInstaller.class
- adapter-template.vm
- version.txt

This folder should be copied in the location defined by user.module.path property in the configuration file snap.properties

#### Quick Overview

This is a listing of the elements directly under the descriptor's operator root element:

XML Element | Required | Description
--- | --- | ---
Operator descriptive parameters
name | Yes | The name of the adapter. Must be unique among the set of adapters. Sample value: org.esa.snap.core.gpf.operators.tooladapter.MyAdapter
operatorClass | Yes | The implementing Java class. It is always org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterOp
alias | Yes | The alias of the adapter. This is should be the same as the name of the adapter folder. Sample value: MyAdapter
label | Yes | The tag of the adapter. This will be used for creating the menu action for the adapter. Sample value: My Adapter
version | No | The version of the adapter. Even though it is not mandatory, it is recommended to set it to a value. Sample value: 1.0.0
description | No | Descriptive text for the adapter. Sample value: This is my first adapter
authors | No | The author(s) of the adapter. Sample value: John Doe
copyright | No | Any copyright information of the adapter. Sample value: (C)2015 Zulu
internal | No | Not used Possible values: true, false
autoWriteSuppressed | No | Not used Possible values: true, false
menuLocation | Yes | The menu path, in SNAP Desktop, where the action for the adapter will be placed. Value must be a valid NetBeans path. Sample value: Menu/Tools/External Tools
source | Yes | Specifies if the adapter comes from a NBM module, or is created by the user. Possible values: user, package
isHandlingOutputName | No | Specifies if the tool handles the output product name by itself. If false, targetProductFile has to be provided at execution time. Possible values: true, false
isSystem | No | Deprecated. Possible values: true, false
Pre-processing parameters
preprocessTool | Yes | Specifies if the adapter should execute another operator before its execution. Possible values: false, true
writeForProcessing | Yes | Specifies if the input product of the adapter should be converted to another format before execution. Possible values: false, true
processingWriter | Yes | Specifies to what format the input product of the adapter should be converted to. Possible values: BEAM-DIMAP, CSV, ENVI, GeoTIFF, GeoTIFF-BigTIFF, HDF5, NetCDF-BEAM, NetCDF-CF, NetCDF4-BEAM, NetCDF4-CF
Execution parameters
mainToolFileLocation | Yes | The path to the tool executable. Variables defined in the variables section can be used. Sample values: C:\ToolBin\tool.exe, /usr/var/tool/bin/tool, $TOOL_PATH/$TOOL_BINARY
workingDir | Yes | The working directory. Variables defined in the variables section can be used. Sample values: C:\ToolBin\SomeFolder, /usr/var/wdir, $WORK_DIR
template | Yes | The path of the main Velocity template file, relative to the adapter folder. Should be on the same level as the META-INF directory. Sample value: MyAdapter-template.vm
progressPattern | No | If specified, the regular expression to capture the progress from the tool output stream. Sample value: (?:.+): (\d{1,3})% (?:.+)
errorPattern | No | If specified, the regular expression to capture tool errors from its output stream. Sample value: ERROR: (.+)
numSourceProducts | Yes | The number of input source products. This is to be set in conjuction with the number of DefaultSourceProductDescriptor elements. Sample value: 1
System variables
variables | No | See variables section.
Operator parameters
parameters | Yes | See parameters section.

##### Variables Section

The element variables has one or more child elements variable (simple values) or osvariable (platform-dependent values):

XML Element | Required | Description
--- | --- | ---
variable
key | Yes | The variable key (or name). This value can be used as indicated above by prefixing the key with $ Sample value: BIN_PATH
value | Yes | The variable value. If the variable represents an OS environment variable, the value element can be empty (the OS value will be read at run-time). Sample value: /usr/var/tool/bin
osvariable
key | Yes | The variable key (or name). This value can be used as indicated above by prefixing the key with $ Sample value: BIN_PATH
windows | Yes | The Windows-specific value. Sample value: C:\Program Files\Tool\bin
linux | Yes | The Linux-specific value. Sample value: /usr/var/tool/bin
macosx | Yes | The Mac OSX-specific value. May be similar to the Linux one. Sample value: /usr/var/tool/bin

##### Parameters Section

The element variables has one or more child elements parameter with the following structure:

XML Element | Required | Description
--- | --- | ---
name | Yes | The parameter name. This value can be used in templates by prefixing the key with $ Sample value: inputFile
alias | No | The parameter alias. Sample value: in
alias | No | The parameter alias. In a future version this will be the command line flag of the parameter. Sample value: in
dataType | Yes | The parameter type. Can be one of the following: Boolean: defaultValue may be true or false Integer: defaultValue may be an integer Decimal: defaultValue may be a float String: defaultValue may be a text value File: defaultValue may be a File object List: defaultValue may be list of string values TemplateBeforeExecution: defaultValue should be the name of the before-execution Velocity template TemplateAfterExecution: defaultValue should be the name of the after-execution Velocity template
defaultValue | No | The parameter default value. Sample value: see the above element.
valueSet | No | For all types except File or List, this specifies the set of accepted values for the parameter. The values are specified by string child elements. Example: for an Integer data type, the valueSet elements would have the children: < string>1< /string>< string>2< /string>< string>3< /string>
notNull | Yes | Specifies if the parameter's defaultValue can be null. Possible values: true or false
notEmpty | Yes | Specifies if the parameter's defaultValue can be empty. Possible values: true or false
parameterType | Yes | Specifies the type of the parameter. Possible values: RegularParameter, FolderParameter, TemplateParameter, TemplateBeforeExecution, TemplateAfterExecution

##### Source Products Descriptors section

The element sourceProductDescriptors has one or more child elements org.esa.snap.core.gpf.descriptor.DefaultSourceProductDescriptor with the following structure:

XML Element | Required | Description
--- | --- | ---
name | Yes | The conventional name of the source product name. The convention is sourceProduct.n where n is the product number Sample value: sourceProduct.1

Please remember that the number of org.esa.snap.core.gpf.descriptor.DefaultSourceProductDescriptor elements should match the value of the numSourceProducts element