Source Code Cross Referenced for CmdLnResult.java in  » Template-Engine » ostermillerutils » com » Ostermiller » util » 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 » com.Ostermiller.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2007 Stephen Ostermiller
003:         * http://ostermiller.org/contact.pl?regarding=Java+Utilities
004:         *
005:         * This program is free software; you can redistribute it and/or modify
006:         * it under the terms of the GNU General Public License as published by
007:         * the Free Software Foundation; either version 2 of the License, or
008:         * (at your option) any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         *
015:         * See COPYING.TXT for details.
016:         */
017:        package com.Ostermiller.util;
018:
019:        import java.util.*;
020:
021:        /**
022:         * Result when a command line option is found.
023:         * Contains the original option and all of its arguments.
024:         *
025:         * More information about this class and code samples for suggested use are
026:         * available from <a target="_top" href=
027:         * "http://ostermiller.org/utils/CmdLn.html">ostermiller.org</a>.
028:         *
029:         * @author Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
030:         * @since ostermillerutils 1.07.00
031:         */
032:        public class CmdLnResult {
033:            /**
034:             * The option that caused this result
035:             *
036:             * @since ostermillerutils 1.07.00
037:             */
038:            private CmdLnOption option;
039:
040:            /**
041:             * The arguments that have been found
042:             * for the option.
043:             *
044:             * @since ostermillerutils 1.07.00
045:             */
046:            private ArrayList<String> arguments;
047:
048:            /**
049:             * New command line result
050:             *
051:             * @param option Option that caused this result
052:             *
053:             * @since ostermillerutils 1.07.00
054:             */
055:            CmdLnResult(CmdLnOption option) {
056:                this .option = option;
057:            }
058:
059:            /**
060:             * @return the option that caused this result
061:             *
062:             * @since ostermillerutils 1.07.00
063:             */
064:            public CmdLnOption getOption() {
065:                return option;
066:            }
067:
068:            /**
069:             * @param argument add an argument to this result
070:             * @throws IllegalStateException if too many arguments have been added
071:             *
072:             * @since ostermillerutils 1.07.00
073:             */
074:            void addArgument(String argument) {
075:                if (hasAllArguments()) {
076:                    throw new IllegalStateException(
077:                            "Too many arguments to option");
078:                }
079:                if (arguments == null) {
080:                    arguments = new ArrayList<String>(Math.min(option
081:                            .getMaxArguments(), 16));
082:                }
083:                arguments.add(argument);
084:            }
085:
086:            /**
087:             * @return true iff enough arguments have been added (max not exceeded)
088:             *
089:             * @since ostermillerutils 1.07.00
090:             */
091:            boolean hasAllArguments() {
092:                return (getArgumentCount() >= option.getMaxArguments());
093:            }
094:
095:            /**
096:             * @return true iff more arguments need to be added (min not satisfied)
097:             *
098:             * @since ostermillerutils 1.07.00
099:             */
100:            boolean requiresMoreArguments() {
101:                return (getArgumentCount() < option.getMinArguments());
102:            }
103:
104:            /**
105:             * Get the argument count for this option
106:             * @return number of arguments
107:             *
108:             * @since ostermillerutils 1.07.00
109:             */
110:            public int getArgumentCount() {
111:                if (arguments == null)
112:                    return 0;
113:                return arguments.size();
114:            }
115:
116:            /**
117:             * Get all the arguments, in the order that
118:             * they were specified.
119:             * @return unmodifiable list of arguments or null if none
120:             *
121:             * @since ostermillerutils 1.07.00
122:             */
123:            public List<String> getArguments() {
124:                if (getArgumentCount() == 0)
125:                    return null;
126:                return Collections.unmodifiableList(arguments);
127:            }
128:
129:            /**
130:             * get the first argument, or null if no arguments
131:             * @return first argument
132:             *
133:             * @since ostermillerutils 1.07.00
134:             */
135:            public String getArgument() {
136:                if (getArgumentCount() == 0)
137:                    return null;
138:                return arguments.get(0);
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.