org.netbeans.modules.sendopts/2 2.22

org.netbeans.spi.sendopts
Annotation Type Arg


@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface Arg

Marks a non-static field in a class as an option and assigns it a short, or long name. Usually used together with Description which provides human readable explanation of the option's behavior. The field should be public and the class should have public default constructor. It is suggested the class implements ArgsProcessor or at least Runnable - its methods will be called after successful assignment of argument fields. Here is an example:

 public final class YourOptions implements ArgsProcessor {
   // Defines an option without any arguments
   public @Arg(shortName='p', longName="") public boolean usedWithO;
   // if such option is present on the command line, the value of the 
   // usedWithO field is set to true. Otherwise its
   // value remains unchanged (e.g. false).
 
 
   // One can also annotate a String field which then becomes 
   // an option with a required argument:
   public @Arg(shortName='r', longName="") public String requiredArg;
 
   // If one annotates a field where an array of strings can be 
   // assigned, such option will then contain all 
   // additional arguments
   // made available:
   public @Arg(longName="additional") public String[] additionalArgs;
 
   // To define an option with optional argument
   // one can annotate string field and provide its default value:
   @Arg(shortName='o', longName="", defaultValue="used-but-no-argument-provided") public String optionArg;
 
   public void process(Env env) {
     // when this method is called, above defined fields are initialized
   }
 }
 

Since:
2.20

Required Element Summary
 String longName
          Multi character name.
 
Optional Element Summary
 String defaultValue
          Some fields may require no argument and still be present.
 boolean implicit
          Specifies whether this field should be implicit/default.
 char shortName
          One character name of the option.
 

Element Detail

longName

public abstract String longName
Multi character name. Needs to be prefixed with -- on the command line. Use "" to assign no long name to the option.

shortName

public abstract char shortName
One character name of the option. Will be prefixed with single - when used on command line.

Default:
65535

implicit

public abstract boolean implicit
Specifies whether this field should be implicit/default. There may be only one implicit option in the system. If there are arguments not consumed by any other option, they are passed to it. The implicit options may annotate only fields of type String[].

Returns:
return true, if this option should be implicit
Default:
false

defaultValue

public abstract String defaultValue
Some fields may require no argument and still be present. For those one needs to specify default value which will be assigned to the field, if the option is present without any argument.

Default:
"\u0000"

org.netbeans.modules.sendopts/2 2.22

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.