com.sun.grid.jgdi.util.shell

## Class AnnotatedCommand

- java.lang.Object
- - com.sun.grid.jgdi.util.shell.AbstractCommand
  - - com.sun.grid.jgdi.util.shell.AnnotatedCommand

- Direct Known Subclasses:
    QConfCommandGenerated, QrStatCommand, QrSubCommand, QStatCommand, QSubCommand

      public abstract class AnnotatedCommand
      extends AbstractCommand

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnnotatedCommand()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getCustomExitCode(java.lang.String msgType, java.lang.String cmdName, java.lang.String optionString)`
    `static java.lang.String` | `getDefaultErrorMessage(java.lang.String cmdName, java.lang.String msgType, java.lang.String arg)`
    `protected java.util.List<java.lang.String>` | `getExtraArguments()` Gets the extra arguments for the command.
    `java.util.Map<java.lang.String,OptionDescriptor>` | `getOptionDescriptorMap()` Getter method
    `OptionInfo` | `getOptionInfo(java.lang.String option)` Finds option info based on option name.
    `protected java.util.List<java.util.List<java.lang.String>>` | `getOriginalExtraArguments()` Gets the original extra arguments (List of List of Stirng) for the command.
    `protected boolean` | `hasExtraArguments()` Check if there are extra arguments.
    `static void` | `initOptionDescriptorMap(java.lang.Class<? extends AbstractCommand> cls, java.io.PrintWriter out, java.io.PrintWriter err)` Initialize the option map optionDescriptorMap if not yet created.
    `protected void` | `invokeOptions()` Invoke appropriate methods It calls annotated functions for every recognized option.
    `void` | `listOptions(OptionInfo oi)` Lists all known (registered) options for the command
    `protected void` | `parseAndInvokeOptions(java.lang.String[] args)` Parse all arguments and invoke appropriate methods It calls annotated functions for every recognized option.
    `protected void` | `parseOptions(java.lang.String[] args)`
    `protected java.util.List<java.util.List<java.lang.String>>` | `tokenizeArgs(java.lang.String[] args)` Parse the ergument array to Array list of separated tokens The tokens are then divided by known options

    - ### Methods inherited from class com.sun.grid.jgdi.util.shell.AbstractCommand

      `getExitCode, getShell, getUsage, init, printAnswers, run, setExitCode`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AnnotatedCommand

          public AnnotatedCommand()

  - ### Method Detail

    - #### initOptionDescriptorMap

          public static void initOptionDescriptorMap(java.lang.Class<? extends AbstractCommand> cls,
                                                     java.io.PrintWriter out,
                                                     java.io.PrintWriter err)
                                              throws java.lang.Exception

      Initialize the option map optionDescriptorMap if not yet created. Map is created by scanning all OptionMethod annotated functions. NOTE: Only options in the map will be recognized as implemented
      Throws:
        `java.lang.Exception`

    - #### getOptionInfo

          public OptionInfo getOptionInfo(java.lang.String option)

      Finds option info based on option name. Use to do a lookahead to see if specific option was in the argument list.
      Parameters:
        `option` - String
      Returns:
        OptionInfo associated with the option or null does not exist

    - #### getOptionDescriptorMap

          public java.util.Map<java.lang.String,OptionDescriptor> getOptionDescriptorMap()

      Getter method
      Returns:
        Map<String, OptionDescriptor>

    - #### getExtraArguments

          protected java.util.List<java.lang.String> getExtraArguments()

      Gets the extra arguments for the command. Only certail commands actually need it: qrsub, qsub, qalter
      Returns:
        List<String>

    - #### getOriginalExtraArguments

          protected java.util.List<java.util.List<java.lang.String>> getOriginalExtraArguments()

      Gets the original extra arguments (List of List of Stirng) for the command. Only certail commands actually need it: qrsub, qsub, qalter
      Returns:
        List<List<String>>

    - #### hasExtraArguments

          protected boolean hasExtraArguments()

      Check if there are extra arguments. If command should not support it (not a qrsub, qsub, qalter)
      Returns:
        boolean

    - #### parseOptions

          protected void parseOptions(java.lang.String[] args)
                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### parseAndInvokeOptions

          protected void parseAndInvokeOptions(java.lang.String[] args)
                                        throws java.lang.Exception

      Parse all arguments and invoke appropriate methods It calls annotated functions for every recognized option.
      Parameters:
        `args` - command line options
      Throws:
        `java.lang.Exception` - an exception during the option call or some runnable exception, when the options are wrong

    - #### invokeOptions

          protected void invokeOptions()
                                throws java.lang.Exception

      Invoke appropriate methods It calls annotated functions for every recognized option.
      Throws:
        `java.lang.Exception` - an exception during the option call or some runnable exception, when the options are wrong

    - #### tokenizeArgs

          protected java.util.List<java.util.List<java.lang.String>> tokenizeArgs(java.lang.String[] args)

      Parse the ergument array to Array list of separated tokens The tokens are then divided by known options
      Parameters:
        `args` - command line option
      Returns:
        List of tokens

    - #### listOptions

          public void listOptions(OptionInfo oi)
                           throws JGDIException

      Lists all known (registered) options for the command
      Throws:
        `JGDIException`

    - #### getDefaultErrorMessage

          public static java.lang.String getDefaultErrorMessage(java.lang.String cmdName,
                                                                java.lang.String msgType,
                                                                java.lang.String arg)

    - #### getCustomExitCode

          public static int getCustomExitCode(java.lang.String msgType,
                                              java.lang.String cmdName,
                                              java.lang.String optionString)

Copyright © 2007 Sun Microsystems, Inc. All rights reserved.