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


001:        /*
002:         * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * [See end of file]
004:         */
005:
006:        /**
007:         * @author   Andy Seaborne
008:         * @version  $Id: juuid.java,v 1.4 2008/01/02 12:08:16 andy_seaborne Exp $
009:         */package jena;
010:
011:        import com.hp.hpl.jena.shared.uuid.*;
012:
013:        import arq.cmdline.ArgDecl;
014:        import arq.cmdline.CmdArgModule;
015:        import arq.cmdline.CmdGeneral;
016:        import arq.cmdline.ModBase;
017:
018:        public class juuid extends CmdGeneral {
019:            ModJUUID modJUUID = new ModJUUID();
020:            int number = 1;
021:            boolean resetEachTime = false;
022:            int uuidType = 0;
023:            boolean asURN = false;
024:            boolean asURI = false;
025:            boolean asPlain = false;
026:
027:            public static void main(String[] argv) {
028:                new juuid(argv).mainAndExit();
029:            }
030:
031:            private juuid(String argv[]) {
032:                super (argv);
033:                super .addModule(modJUUID);
034:            }
035:
036:            protected String getSummary() {
037:                return getCommandName() + " [--num=N] [--reset] [--type={1|4}]";
038:            }
039:
040:            protected void exec() {
041:                if (uuidType == UUID_V1.version)
042:                    JenaUUID.setFactory(new UUID_V1_Gen());
043:                if (uuidType == UUID_V4.version)
044:                    JenaUUID.setFactory(new UUID_V4_Gen());
045:
046:                for (int i = 0; i < number; i++) {
047:                    if (resetEachTime && i != 0)
048:                        JenaUUID.reset();
049:                    JenaUUID uuid = JenaUUID.generate();
050:                    String str = null;
051:                    if (asURN)
052:                        str = uuid.asURN();
053:                    else if (asURN)
054:                        str = uuid.asURI();
055:                    else if (asPlain)
056:                        str = uuid.asString();
057:                    if (str == null)
058:                        str = uuid.asString();
059:                    System.out.println(str);
060:                }
061:            }
062:
063:            protected String getCommandName() {
064:                return "uuid";
065:            }
066:
067:            protected void processModulesAndArgs() {
068:
069:            }
070:
071:            static ArgDecl argDeclNum = new ArgDecl(ArgDecl.HasValue, "num",
072:                    "n");
073:            static ArgDecl argDeclReset = new ArgDecl(ArgDecl.NoValue, "reset");
074:            static ArgDecl argDeclGen = new ArgDecl(ArgDecl.HasValue, "gen",
075:                    "scheme");
076:            static ArgDecl argDeclURN = new ArgDecl(ArgDecl.NoValue, "urn");
077:            static ArgDecl argDeclURI = new ArgDecl(ArgDecl.NoValue, "uri");
078:            static ArgDecl argDeclPlain = new ArgDecl(ArgDecl.NoValue, "plain");
079:
080:            class ModJUUID extends ModBase {
081:                public void registerWith(CmdGeneral cmdLine) {
082:                    cmdLine.add(argDeclNum);
083:                    cmdLine.add(argDeclReset);
084:                    cmdLine.add(argDeclGen);
085:                    cmdLine.add(argDeclURN);
086:                    cmdLine.add(argDeclURI);
087:                    cmdLine.add(argDeclPlain);
088:                }
089:
090:                public void processArgs(CmdArgModule cmdLine) {
091:                    String numStr = null;
092:
093:                    if (getNumPositional() > 1)
094:                        cmdError("Too many positional arguments");
095:
096:                    if (cmdLine.contains(argDeclNum)) {
097:                        if (getNumPositional() != 0)
098:                            cmdError("--num and positional arguments don't go together");
099:                        numStr = getValue(argDeclNum);
100:                    }
101:
102:                    if (numStr == null && cmdLine.getNumPositional() == 1)
103:                        numStr = cmdLine.getPositionalArg(0);
104:
105:                    if (numStr != null) {
106:                        try {
107:                            number = Integer.parseInt(numStr);
108:                            if (number < 0 || number > 10000)
109:                                cmdLine.cmdError("Number out of range:"
110:                                        + numStr);
111:                        } catch (NumberFormatException e) {
112:                            cmdLine.cmdError("Bad argument: " + numStr);
113:                        }
114:                    }
115:
116:                    resetEachTime = cmdLine.contains(argDeclReset);
117:
118:                    if (contains(argDeclGen)) {
119:                        String s = getValue(argDeclGen);
120:                        if (s.equalsIgnoreCase("time")
121:                                || s.equalsIgnoreCase("1"))
122:                            uuidType = UUID_V1.version;
123:                        else if (s.equalsIgnoreCase("random")
124:                                || s.equalsIgnoreCase("rand")
125:                                || s.equalsIgnoreCase("4"))
126:                            uuidType = UUID_V4.version;
127:                        else
128:                            cmdError("Unrecognized UUID scheme: " + s);
129:                    }
130:
131:                    if (contains(argDeclURN) || contains(argDeclURI)
132:                            || contains(argDeclPlain)) {
133:                        asURN = contains(argDeclURN);
134:                        asURI = contains(argDeclURI);
135:                        asPlain = contains(argDeclPlain);
136:                    } else {
137:                        // Defaults
138:                        asURN = true;
139:                        asURI = false;
140:                        asPlain = false;
141:                    }
142:                }
143:            }
144:        }
145:
146:        /*
147:         *  (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
148:         *  All rights reserved.
149:         *
150:         * Redistribution and use in source and binary forms, with or without
151:         * modification, are permitted provided that the following conditions
152:         * are met:
153:         * 1. Redistributions of source code must retain the above copyright
154:         *    notice, this list of conditions and the following disclaimer.
155:         * 2. Redistributions in binary form must reproduce the above copyright
156:         *    notice, this list of conditions and the following disclaimer in the
157:         *    documentation and/or other materials provided with the distribution.
158:         * 3. The name of the author may not be used to endorse or promote products
159:         *    derived from this software without specific prior written permission.
160:         *
161:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
162:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
163:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
164:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
165:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
166:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
167:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
168:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
169:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
170:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
171:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.