Source Code Cross Referenced for LongOpt.java in  » Template-Engine » ostermillerutils » gnu » getopt » 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 » Template Engine » ostermillerutils » gnu.getopt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************
002:        /* LongOpt.java -- Long option object for Getopt
003:        /*
004:        /* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
005:        /*
006:        /* This program is free software; you can redistribute it and/or modify
007:        /* it under the terms of the GNU Library General Public License as published 
008:        /* by  the Free Software Foundation; either version 2 of the License or
009:        /* (at your option) any later version.
010:        /*
011:        /* This program is distributed in the hope that it will be useful, but
012:        /* WITHOUT ANY WARRANTY; without even the implied warranty of
013:        /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:        /* GNU Library General Public License for more details.
015:        /*
016:        /* You should have received a copy of the GNU Library General Public License
017:        /* along with this program; see the file COPYING.LIB.  If not, write to 
018:        /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, 
019:        /* Boston, MA  02111-1307 USA
020:        /**************************************************************************/package gnu.getopt;
021:
022:        import java.util.Locale;
023:        import java.util.ResourceBundle;
024:        import java.util.PropertyResourceBundle;
025:        import java.text.MessageFormat;
026:
027:        /**************************************************************************/
028:
029:        /**
030:         * This object represents the definition of a long option in the Java port
031:         * of GNU getopt.  An array of LongOpt objects is passed to the Getopt
032:         * object to define the list of valid long options for a given parsing
033:         * session.  Refer to the getopt documentation for details on the
034:         * format of long options.
035:         * 
036:         * @version 1.0.5
037:         * @author Aaron M. Renn (arenn@urbanophile.com)
038:         *
039:         * @see Getopt
040:         */
041:        public class LongOpt extends Object {
042:
043:            /**************************************************************************/
044:
045:            /*
046:             * Class Variables
047:             */
048:
049:            /**
050:             * Constant value used for the "has_arg" constructor argument.  This
051:             * value indicates that the option takes no argument.
052:             */
053:            public static final int NO_ARGUMENT = 0;
054:
055:            /** 
056:             * Constant value used for the "has_arg" constructor argument.  This
057:             * value indicates that the option takes an argument that is required.
058:             */
059:            public static final int REQUIRED_ARGUMENT = 1;
060:
061:            /**
062:             * Constant value used for the "has_arg" constructor argument.  This
063:             * value indicates that the option takes an argument that is optional.
064:             */
065:            public static final int OPTIONAL_ARGUMENT = 2;
066:
067:            /**************************************************************************/
068:
069:            /*
070:             * Instance Variables
071:             */
072:
073:            /**
074:             * The name of the long option
075:             */
076:            protected String name;
077:
078:            /**
079:             * Indicates whether the option has no argument, a required argument, or
080:             * an optional argument.
081:             */
082:            protected int has_arg;
083:
084:            /**
085:             * If this variable is not null, then the value stored in "val" is stored
086:             * here when this long option is encountered.  If this is null, the value
087:             * stored in "val" is treated as the name of an equivalent short option.
088:             */
089:            protected StringBuffer flag;
090:
091:            /**
092:             * The value to store in "flag" if flag is not null, otherwise the
093:             * equivalent short option character for this long option.
094:             */
095:            protected int val;
096:
097:            /**
098:             * Localized strings for error messages
099:             */
100:            private ResourceBundle _messages = PropertyResourceBundle
101:                    .getBundle("gnu/getopt/MessagesBundle", Locale.getDefault());
102:
103:            /**************************************************************************/
104:
105:            /*
106:             * Constructors
107:             */
108:
109:            /**
110:             * Create a new LongOpt object with the given parameter values.  If the
111:             * value passed as has_arg is not valid, then an exception is thrown.
112:             *
113:             * @param name The long option String.
114:             * @param has_arg Indicates whether the option has no argument (NO_ARGUMENT), a required argument (REQUIRED_ARGUMENT) or an optional argument (OPTIONAL_ARGUMENT).
115:             * @param flag If non-null, this is a location to store the value of "val" when this option is encountered, otherwise "val" is treated as the equivalent short option character.
116:             * @param val The value to return for this long option, or the equivalent single letter option to emulate if flag is null.
117:             * 
118:             * @exception IllegalArgumentException If the has_arg param is not one of NO_ARGUMENT, REQUIRED_ARGUMENT or OPTIONAL_ARGUMENT.
119:             */
120:            public LongOpt(String name, int has_arg, StringBuffer flag, int val)
121:                    throws IllegalArgumentException {
122:                // Validate has_arg
123:                if ((has_arg != NO_ARGUMENT) && (has_arg != REQUIRED_ARGUMENT)
124:                        && (has_arg != OPTIONAL_ARGUMENT)) {
125:                    Object[] msgArgs = { new Integer(has_arg).toString() };
126:                    throw new IllegalArgumentException(MessageFormat
127:                            .format(_messages.getString("getopt.invalidValue"),
128:                                    msgArgs));
129:                }
130:
131:                // Store off values
132:                this .name = name;
133:                this .has_arg = has_arg;
134:                this .flag = flag;
135:                this .val = val;
136:            }
137:
138:            /**************************************************************************/
139:
140:            /**
141:             * Returns the name of this LongOpt as a String
142:             *
143:             * @return Then name of the long option
144:             */
145:            public String getName() {
146:                return (name);
147:            }
148:
149:            /**************************************************************************/
150:
151:            /**
152:             * Returns the value set for the 'has_arg' field for this long option
153:             *
154:             * @return The value of 'has_arg'
155:             */
156:            public int getHasArg() {
157:                return (has_arg);
158:            }
159:
160:            /**************************************************************************/
161:
162:            /**
163:             * Returns the value of the 'flag' field for this long option
164:             *
165:             * @return The value of 'flag'
166:             */
167:            public StringBuffer getFlag() {
168:                return (flag);
169:            }
170:
171:            /**
172:             * Returns the value of the 'val' field for this long option
173:             *
174:             * @return The value of 'val'
175:             */
176:            public int getVal() {
177:                return (val);
178:            }
179:
180:            /**************************************************************************/
181:
182:        } // Class LongOpt
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.