Java Doc for Option.java in  » IDE-Netbeans » sendopts » org » netbeans » spi » sendopts » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » sendopts » org.netbeans.spi.sendopts 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.netbeans.spi.sendopts.Option

Option
final public class Option (Code)
Represents possible option that can appear on org.netbeans.api.sendopts.CommandLine and contains factory methods to create them.

An option can have letter short version, long name. It can accept arguments, one argument or an array of additional arguments.
author:
   Jaroslav Tulach



Field Summary
final public static  charNO_SHORT_NAME
     Constant that represents no short name indicator.
final  OptionImplimpl
    

Constructor Summary
 Option(int type, Option[] arr)
    

Method Summary
public static  OptionadditionalArguments(char shortName, String longName)
     Creates an option that can accept additional arguments. For example to have option that opens few files one could write:
 Option openOption = Option.additionalArguments('o', "open");
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(openOption)) {
 for (String fileName : values.get(openOption)) {
 File file = new File(
Env.getCurrentDirectory , fileName);
 // do what is necessary
 }
 }
 }
The values map always contains the openOption if it appeared on the command line.
public static  Optionalways()
     Creates an option that is always present.
public static  OptiondefaultArguments()
     Creates a default option that accepts additional arguments not claimed by any other option.
public static  OptiondisplayName(Option option, String bundleName, String key)
     Associates a name with given option.
public  booleanequals(Object o)
     Options with the same functionality, regardless of their descriptions Option.shortDescription and Option.displayName are always the same.
public  inthashCode()
    
public static  OptionoptionalArgument(char shortName, String longName)
     Factory method for option that may, but does not need to have an argument. For example to have option that increments by one or by specified number one could write:
 Option incrementOption = Option.optionalArgument('i', "increment");
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(incrementOption)) {
 String[] inc = values.get(incrementOption);
 int increment = inc == null ? 1 : Integer.parseInt(inc[0]);
 // do what is necessary
 }
 }
The values map always contains the incrementOption if it appeared on the command line.
public static  OptionrequiredArgument(char shortName, String longName)
     Factory method for option has to be followed by one argument. For example to have option that opens a file one could write:
 Option openOption = Option.optionalArgument('o', "open");
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(openOption)) {
 String fileName = values.get(openOption)[0];
 File file = new File(
Env.getCurrentDirectory , fileName);
 // do what is necessary
 }
 }
The values map always contains the openOption if it appeared on the command line.
public static  OptionshortDescription(Option option, String bundleName, String key)
     Associates a short textual description with given option.
public  StringtoString()
     Programmatic textual representation of the option.
public static  OptionwithoutArgument(char shortName, String longName)
     Factory method that creates an option without any arguments.

Field Detail
NO_SHORT_NAME
final public static char NO_SHORT_NAME(Code)
Constant that represents no short name indicator.



impl
final OptionImpl impl(Code)
implementation of this option




Constructor Detail
Option
Option(int type, Option[] arr)(Code)
Complex option




Method Detail
additionalArguments
public static Option additionalArguments(char shortName, String longName)(Code)
Creates an option that can accept additional arguments. For example to have option that opens few files one could write:
 Option openOption = Option.additionalArguments('o', "open");
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(openOption)) {
 for (String fileName : values.get(openOption)) {
 File file = new File(
Env.getCurrentDirectory , fileName);
 // do what is necessary
 }
 }
 }
The values map always contains the openOption if it appeared on the command line. Its value is then always string array of arbitrary length containing all elements on the command line that were not recognised as options (or their arguments). For example line
 X.java -o Y.java Z.txt
will invoke the OptionProcessor with { "X.java", "Y.java", "Z.txt" }.

Obviously only one such Option.additionalArguments can be used at once on a command line. If there was not only the open but also edit option taking the additional arguments, then command line like:

 --edit X.java --open Y.java Z.txt
would be rejected.
Parameters:
  shortName - the character to be used as a shortname or Option.NO_SHORT_NAME
Parameters:
  longName - the long name or null



always
public static Option always()(Code)
Creates an option that is always present. This can be useful for processors that want to be notified everytime the command line is successfuly parsed. Option always = Option.always(); and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 assert values.contains(always);
 }
the option that always matches correct command line
since:
   2.1



defaultArguments
public static Option defaultArguments()(Code)
Creates a default option that accepts additional arguments not claimed by any other option. For example to have option that opens few files one could write:
 Option openOption = Option.defaultArguments();
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(openOption)) {
 for (fileName : values.get(openOption)) {
 File file = new File(
Env.getCurrentDirectory , fileName);
 // do what is necessary
 }
 }
 }
The values map always contains the openOption if there were some arguments on the command line that were not parsed by any other option. Its value is then always string array of arbitrary length containing all elements on the command line that were not recognised as options (or their arguments). For example line
 X.java Y.java Z.txt
will invoke the OptionProcessor with { "X.java", "Y.java", "Z.txt" }.

Obviously only one such Option.defaultArguments can defined. If there are two, then an error is reported when one tries to parse any command line with arguments not claimed by any other option. That is why it is always good idea to not define just Option.defaultArguments option, but also appropriate Option.additionalArguments one:

 Option openOption1 = Option.defaultArguments();
 Option openOption2 = Option.additionalArguments('o', "open");
and handle both of them in the OptionProcessor . Then if the command line:
 X.java Y.java Z.txt
is rejected due to ambiguities one can use
 X.java Y.java --open Z.txt
to invoke the same functionality.



displayName
public static Option displayName(Option option, String bundleName, String key)(Code)
Associates a name with given option. By default the option display name is generated by the infrastructure from the short and long name plus generic description of options arguments, this method allows to completely replace the default behaviour.
Parameters:
  option - the option to add description for
Parameters:
  bundleName - name of a bundle to create
Parameters:
  key - the bundle key to get the message from option with same behaviour as the old one plus with associated display name



equals
public boolean equals(Object o)(Code)
Options with the same functionality, regardless of their descriptions Option.shortDescription and Option.displayName are always the same.



hashCode
public int hashCode()(Code)



optionalArgument
public static Option optionalArgument(char shortName, String longName)(Code)
Factory method for option that may, but does not need to have an argument. For example to have option that increments by one or by specified number one could write:
 Option incrementOption = Option.optionalArgument('i', "increment");
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(incrementOption)) {
 String[] inc = values.get(incrementOption);
 int increment = inc == null ? 1 : Integer.parseInt(inc[0]);
 // do what is necessary
 }
 }
The values map always contains the incrementOption if it appeared on the command line. If it had associated value, then the map.get(incrementOption) returns array of length one, with item on position 0 being the value of the option. However if the option appeared without argument, then the value associated with the option is null.

If registered into to system using OptionProcessor then users could use command lines like -i=5 or --increment=5 to increase the value by five or just -i and --increment to increment by default - e.g. one.
Parameters:
  shortName - the character to be used as a shortname or Option.NO_SHORT_NAME
Parameters:
  longName - the long name or null




requiredArgument
public static Option requiredArgument(char shortName, String longName)(Code)
Factory method for option has to be followed by one argument. For example to have option that opens a file one could write:
 Option openOption = Option.optionalArgument('o', "open");
and inside of the OptionProcessor declaring this option use:
 public void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(openOption)) {
 String fileName = values.get(openOption)[0];
 File file = new File(
Env.getCurrentDirectory , fileName);
 // do what is necessary
 }
 }
The values map always contains the openOption if it appeared on the command line. Its value is then always string array of length one and its 0 element contains the argument for the option.

If registered into to system using OptionProcessor then users could use command lines like -oX.java or --open Y.java to invoke the open functionality.
Parameters:
  shortName - the character to be used as a shortname or Option.NO_SHORT_NAME
Parameters:
  longName - the long name or null




shortDescription
public static Option shortDescription(Option option, String bundleName, String key)(Code)
Associates a short textual description with given option. This message is going to be printed during org.netbeans.api.sendopts.CommandLine.usage next to the option name. Usually should be one liner comment.
Parameters:
  option - the option to add description for
Parameters:
  bundleName - name of a bundle to create
Parameters:
  key - the bundle key to get the message from option with same behaviour as the old one plus with associated short description message



toString
public String toString()(Code)
Programmatic textual representation of the option. Format is subject to change in future. textual description of the option



withoutArgument
public static Option withoutArgument(char shortName, String longName)(Code)
Factory method that creates an option without any arguments. For example to create an option that handles --help or -h one can create it using:
 Option helpOption = Option.withoutArgument('h', "help");
and inside of the OptionProcessor declaring this option use:
 protected void process(Env env, Map<Option,String[]> values) throws CommandException {
 if (values.containsKey(helpOption)) {
 printHelp(env.getErrorStream());
 }
 }
The values.get(helpOption) is always null to signal that this options does not have any associated value.
Parameters:
  shortName - character code or Option.NO_SHORT_NAME
Parameters:
  longName - long name or null option representing the created definition



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.