Source Code Cross Referenced for ArgDecl.java in  » RSS-RDF » Jena-2.5.5 » jena » cmdline » 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 » RSS RDF » Jena 2.5.5 » jena.cmdline 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * [See end of file]
004:         */
005:
006:        package jena.cmdline;
007:
008:        import java.util.*;
009:
010:        /** A command line argument specification.
011:         *
012:         * @author  Andy Seaborne
013:         * @version $Id: ArgDecl.java,v 1.10 2008/01/02 12:09:55 andy_seaborne Exp $
014:         */
015:        public class ArgDecl {
016:            boolean takesValue;
017:            Set names = new HashSet();
018:            boolean takesArg = false;
019:            List argHooks = new ArrayList();
020:            public static final boolean HasValue = true;
021:            public static final boolean NoValue = false;
022:
023:            /** Create a declaration for a command argument.
024:             *
025:             * @param hasValue  Does it take a value or not?
026:             */
027:
028:            public ArgDecl(boolean hasValue) {
029:                takesValue = hasValue;
030:            }
031:
032:            /** Create a declaration for a command argument.
033:             *
034:             * @param hasValue  Does it take a value or not?
035:             * @param name      Name of argument
036:             */
037:
038:            public ArgDecl(boolean hasValue, String name) {
039:                this (hasValue);
040:                addName(name);
041:            }
042:
043:            /** Create a declaration for a command argument.
044:             *
045:             * @param hasValue  Does it take a value or not?
046:             * @param name      Name of argument
047:             * @param handler   ArgHandler
048:             */
049:
050:            public ArgDecl(boolean hasValue, String name, ArgHandler handler) {
051:                this (hasValue);
052:                addName(name);
053:                addHook(handler);
054:            }
055:
056:            /** Create a declaration for a command argument.
057:             *
058:             * @param hasValue  Does it take a value or not?
059:             * @param name1      Name of argument
060:             * @param name2      Name of argument
061:             */
062:
063:            public ArgDecl(boolean hasValue, String name1, String name2) {
064:                this (hasValue);
065:                addName(name1);
066:                addName(name2);
067:            }
068:
069:            /** Create a declaration for a command argument.
070:             *
071:             * @param hasValue  Does it take a value or not?
072:             * @param name1      Name of argument
073:             * @param name2      Name of argument
074:             * @param handler   ArgHandler
075:             */
076:
077:            public ArgDecl(boolean hasValue, String name1, String name2,
078:                    ArgHandler handler) {
079:                this (hasValue);
080:                addName(name1);
081:                addName(name2);
082:                addHook(handler);
083:            }
084:
085:            /** Create a declaration for a command argument.
086:             *
087:             * @param hasValue  Does it take a value or not?
088:             * @param name1      Name of argument
089:             * @param name2      Name of argument
090:             * @param name3      Name of argument
091:             */
092:
093:            public ArgDecl(boolean hasValue, String name1, String name2,
094:                    String name3) {
095:                this (hasValue);
096:                addName(name1);
097:                addName(name2);
098:                addName(name3);
099:            }
100:
101:            /** Create a declaration for a command argument.
102:             *
103:             * @param hasValue  Does it take a value or not?
104:             * @param name1      Name of argument
105:             * @param name2      Name of argument
106:             * @param name3      Name of argument
107:             * @param handler   ArgHandler
108:             */
109:
110:            public ArgDecl(boolean hasValue, String name1, String name2,
111:                    String name3, ArgHandler handler) {
112:                this (hasValue);
113:                addName(name1);
114:                addName(name2);
115:                addName(name3);
116:                addHook(handler);
117:            }
118:
119:            /** Create a declaration for a command argument.
120:             *
121:             * @param hasValue  Does it take a value or not?
122:             * @param name1      Name of argument
123:             * @param name2      Name of argument
124:             * @param name3      Name of argument
125:             * @param name4      Name of argument
126:             */
127:
128:            public ArgDecl(boolean hasValue, String name1, String name2,
129:                    String name3, String name4) {
130:                this (hasValue);
131:                addName(name1);
132:                addName(name2);
133:                addName(name3);
134:                addName(name4);
135:            }
136:
137:            /** Create a declaration for a command argument.
138:             *
139:             * @param hasValue  Does it take a value or not?
140:             * @param name1      Name of argument
141:             * @param name2      Name of argument
142:             * @param name3      Name of argument
143:             * @param name4      Name of argument
144:             * @param handler    ArgHandler
145:             */
146:
147:            public ArgDecl(boolean hasValue, String name1, String name2,
148:                    String name3, String name4, ArgHandler handler) {
149:                this (hasValue);
150:                addName(name1);
151:                addName(name2);
152:                addName(name3);
153:                addName(name4);
154:                addHook(handler);
155:            }
156:
157:            /** Create a declaration for a command argument.
158:             *
159:             * @param hasValue  Does it take a value or not?
160:             * @param name1      Name of argument
161:             * @param name2      Name of argument
162:             * @param name3      Name of argument
163:             * @param name4      Name of argument
164:             * @param name5      Name of argument
165:             * @param handler    ArgHandler
166:             */
167:
168:            public ArgDecl(boolean hasValue, String name1, String name2,
169:                    String name3, String name4, String name5, ArgHandler handler) {
170:                this (hasValue);
171:                addName(name1);
172:                addName(name2);
173:                addName(name3);
174:                addName(name4);
175:                addName(name5);
176:                addHook(handler);
177:            }
178:
179:            public void addName(String name) {
180:                name = canonicalForm(name);
181:                names.add(name);
182:            }
183:
184:            public Set getNames() {
185:                return names;
186:            }
187:
188:            public Iterator names() {
189:                return names.iterator();
190:            }
191:
192:            // Callback model
193:
194:            public void addHook(ArgHandler argHandler) {
195:                argHooks.add(argHandler);
196:            }
197:
198:            protected void trigger(Arg arg) {
199:                for (Iterator iter = argHooks.iterator(); iter.hasNext();) {
200:                    ArgHandler handler = (ArgHandler) iter.next();
201:                    handler.action(arg.getName(), arg.getValue());
202:                }
203:            }
204:
205:            public boolean takesValue() {
206:                return takesValue;
207:            }
208:
209:            public boolean matches(Arg a) {
210:                for (Iterator iter = names.iterator(); iter.hasNext();) {
211:                    String n = (String) iter.next();
212:                    if (a.getName().equals(n))
213:                        return true;
214:                }
215:                return false;
216:            }
217:
218:            public boolean matches(String arg) {
219:                arg = canonicalForm(arg);
220:                return names.contains(arg);
221:            }
222:
223:            static String canonicalForm(String str) {
224:                if (str.startsWith("--"))
225:                    return str.substring(2);
226:
227:                if (str.startsWith("-"))
228:                    return str.substring(1);
229:
230:                return str;
231:            }
232:        }
233:
234:        /*
235:         *  (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
236:         *  All rights reserved.
237:         *
238:         * Redistribution and use in source and binary forms, with or without
239:         * modification, are permitted provided that the following conditions
240:         * are met:
241:         * 1. Redistributions of source code must retain the above copyright
242:         *    notice, this list of conditions and the following disclaimer.
243:         * 2. Redistributions in binary form must reproduce the above copyright
244:         *    notice, this list of conditions and the following disclaimer in the
245:         *    documentation and/or other materials provided with the distribution.
246:         * 3. The name of the author may not be used to endorse or promote products
247:         *    derived from this software without specific prior written permission.
248:         *
249:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
250:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
251:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
252:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
253:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
254:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
258:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
259:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.