Custom Task Guide

Custom Task Guide

Create the Getter and Setter Methods

Create the Getter and Setter Methods

Create getter and setter methods for each attribute we have defined in the Copy Task’s XML. The setter and getter methods must follow the following naming conventions so the
Managed File Transfer
Compiler/Runtime can work with the objects.
The setter methods must meet the following criteria:
  • Scope must be public
  • Return type must be void
  • Must take one argument of type java.lang.String
  • Must not be static
  • The name of the method must begin with “set”, followed by the attribute name (with the first letter of the attribute name converted to upper case), then followed by the word “attribute”.
The getter method must meet the following criteria:
  • Scope must be public
  • Return type must be of type java.lang.String
  • Must not have any arguments
  • Must not be static
  • The name of the method must begin with “get”, followed by the attribute name (with the first letter of the attribute name converted to upper case), then followed by the word “attribute”.
Refer to the code shown below in how the sourceFile and destinationDirectory attributes are added:
Please note that the red text denotes the new source added to the example.
package com.example; import com.linoma.ga.projects.CustomTask; import com.linoma.ga.projects.TaskContainer; public class CopyTask extends CustomTask { private static final String TAG_NAME = "example:copy"; private String sourceFileAttribute = null; private String destinationDirectoryAttribute = null; public CopyTask(TaskContainer parent) { super(parent); label = TAG_NAME; } @Override public String getTagName() { return TAG_NAME; } @Override public String getDisplayString() { return label; } @Override public String getVersion() { return "1.0"; } @Override public String getVendor() { return "Example, Inc."; } public String getSourceFileAttribute() { return sourceFileAttribute; } public void setSourceFileAttribute(String sourceFileAttribute) { this.sourceFileAttribute = sourceFileAttribute; } public String getDestinationDirectoryAttribute() { return destinationDirectoryAttribute; } public void setDestinationDirectoryAttribute( String destinationDirectoryAttribute) { this.destinationDirectoryAttribute = destinationDirectoryAttribute; } }

0 COMMENTS

We’d like to hear from you!