Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

This is a simple configuration object example from the DTK examples. The example shows a Disk Collection agent configuration including a directory field and a fileNamePrefix field.

@DRStorableId("devkitexamples.DiskCollectionConfig")
@DRConfigTypeInfo(version = 10f, section = "Disk Collection")
public class DiskCollectionConfig extends DRAbstractConfigObject {

    public static final String DIRECTORY = "Directory";
    public static final String FILENAME_PREFIX = "Filename Prefix";
    private String _directory = "";
    private String _fileNamePrefix = "";

    public DiskCollectionConfig() {}

    @DRConfigFieldInfo(title = DIRECTORY, description = "The path to the source directory")
    public void setDirectory(String directory) { _directory = directory; }
    public String getDirectory() { return _directory; }

    @DRConfigFieldInfo(title = FILENAME_PREFIX, description = "The filename prefix")
    public void setFileNamePrefix(String fileNamePrefix) { _fileNamePrefix = fileNamePrefix; }
    public String getFileNamePrefix() { return _fileNamePrefix; }

    @Override
    public String validateField(String fieldName, Object fieldValue, DREnvironment env) throws DRException {
        if (fieldName.equalsIgnoreCase("directory")) {
            if (fieldValue == null || ((String) fieldValue).length() < 1)
                return "Directory may not be empty";
        }

        return null;
    }
}
  • No labels