Source Code Cross Referenced for OPPHelper.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » tools » OPP » 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 » Database DBMS » Ozone 1.1 » org.ozoneDB.tools.OPP 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Library License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: OPPHelper.java,v 1.2 2002/04/17 09:29:39 per_nyfelt Exp $
008:
009:        package org.ozoneDB.tools.OPP;
010:
011:        import java.lang.reflect.*;
012:        import org.apache.regexp.*;
013:        import org.ozoneDB.core.*;
014:        import org.ozoneDB.DxLib.*;
015:
016:        /**
017:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
018:         * @version $Revision: 1.2 $Date: 2002/04/17 09:29:39 $
019:         */
020:        public class OPPHelper {
021:
022:            public static void progressMsg(String msg, boolean quiet) {
023:                if (!quiet) {
024:                    System.out.println(msg);
025:                }
026:            }
027:
028:            public static void warnMsg(String filename, int line, String msg) {
029:                System.out.println(filename + ":" + line + ": warning: " + msg
030:                        + ".");
031:            }
032:
033:            public static void warnMsg(Class cl, String msg) {
034:                System.out.println(cl.getName() + ": warning:" + msg);
035:            }
036:
037:            public static void error(String filename, int line, String msg) {
038:                System.out.println(filename + ":" + line + ": error: " + msg);
039:                System.exit(1);
040:            }
041:
042:            public static void error(Class cl, String msg) {
043:                System.out.println(cl.getName() + ": error:" + msg);
044:                System.exit(1);
045:            }
046:
047:            public static String typecodeForPrimitive(char ch) throws Exception {
048:                String ret;
049:                switch (ch) {
050:                case 'B':
051:                    ret = "byte";
052:                    break;
053:                case 'C':
054:                    ret = "char";
055:                    break;
056:                case 'D':
057:                    ret = "double";
058:                    break;
059:                case 'F':
060:                    ret = "float";
061:                    break;
062:                case 'I':
063:                    ret = "int";
064:                    break;
065:                case 'J':
066:                    ret = "long";
067:                    break;
068:                case 'S':
069:                    ret = "short";
070:                    break;
071:                case 'Z':
072:                    ret = "boolean";
073:                    break;
074:                default:
075:                    throw new Exception("Unknown type code '" + ch + "'.");
076:                }
077:                return ret;
078:            }
079:
080:            public static String wrappercodeForPrimitive(Class cl)
081:                    throws Exception {
082:                String ret;
083:                String name = cl.getName();
084:                if (name.equals("int")) {
085:                    ret = "Integer";
086:                } else if (name.equals("char")) {
087:                    ret = "Character";
088:                } else {
089:                    ret = name.substring(0, 1).toUpperCase()
090:                            + name.substring(1);
091:                }
092:                return ret;
093:            }
094:
095:            /**
096:             * For all primitive types in cl return a string like '<varName>.intValue()'.
097:             */
098:            public static String returncodeForPrimitive(Class cl, String varName)
099:                    throws Exception {
100:                String ret;
101:                String name = cl.getName();
102:                if (name.equals("int")) {
103:                    ret = "((Integer)" + varName + ").intValue()";
104:                } else if (name.equals("boolean")) {
105:                    ret = "((Boolean)" + varName + ").booleanValue()";
106:                } else if (name.equals("char")) {
107:                    ret = "((Character)" + varName + ").charValue()";
108:                } else if (name.equals("long")) {
109:                    ret = "((Long)" + varName + ").longValue()";
110:                } else if (name.equals("float")) {
111:                    ret = "((Float)" + varName + ").floatValue()";
112:                } else if (name.equals("double")) {
113:                    ret = "((Double)" + varName + ").doubleValue()";
114:                } else if (name.equals("byte")) {
115:                    ret = "((Byte)" + varName + ").byteValue()";
116:                } else if (name.equals("short")) {
117:                    ret = "((Short)" + varName + ").shortValue()";
118:                } else {
119:                    throw new Exception("unknown type: '" + name + "'");
120:                }
121:                return ret;
122:            }
123:
124:            public static String signature(Class[] args) {
125:                String result = new String();
126:                for (int i = 0; i < args.length; i++) {
127:                    result = i > 0 ? result + OPP.SIGNATURE_DELIMITER : result;
128:                    result = result + args[i].getName();
129:                }
130:                return "\"" + result + "\"";
131:            }
132:
133:            public static String packageName(Class c) {
134:                String name = c.getName();
135:                int index = name.lastIndexOf('.');
136:                return index != -1 ? name.substring(0, index) : "";
137:            }
138:
139:            public static String simpleClassName(Class c) {
140:                return simpleClassName(c.getName());
141:            }
142:
143:            public static String simpleClassName(String name) {
144:                int index = name.lastIndexOf('.');
145:                return index != -1 ? name.substring(index + 1) : name;
146:            }
147:
148:            public static String classFileBasename(Class c) {
149:                return classFileBasename(c.getName());
150:            }
151:
152:            public static String classFileBasename(String name) {
153:                return name.replace('.', java.io.File.separatorChar);
154:            }
155:
156:            /**
157:             * Returns the array index of the specified method within the array
158:             * of methods of this class.
159:             */
160:            public static int methodArrayIndex(Method[] methods, Method m) {
161:                String mName = m.getName();
162:                String mSig = OPPHelper.signature(m.getParameterTypes());
163:
164:                for (int i = 0; i < methods.length; i++) {
165:                    String cName = methods[i].getName();
166:                    String cSig = OPPHelper.signature(methods[i]
167:                            .getParameterTypes());
168:                    if (mName.equals(cName) && mSig.equals(cSig)) {
169:                        return i;
170:                    }
171:                }
172:                throw new RuntimeException(m
173:                        + ": Unable to find method in class.");
174:            }
175:
176:            public static Method[] methodsOfClass(Class cl) {
177:                Method[] methods = cl.getMethods();
178:
179:                DxTreeSet set = new DxTreeSet();
180:
181:                for (int i = 0; i < methods.length; i++) {
182:                    String name = methods[i].getName();
183:                    String sig = OPPHelper.signature(methods[i]
184:                            .getParameterTypes());
185:                    set.add(new MethodKey(cl.getName(), name, sig, methods[i]));
186:                }
187:
188:                DxIterator it = set.iterator();
189:                for (int i = 0; it.next() != null; i++) {
190:                    MethodKey key = (MethodKey) it.object();
191:                    methods[i] = key.method();
192:                }
193:                return methods;
194:            }
195:
196:            public static Object newRE(String s, boolean ignoreCase)
197:                    throws Exception {
198:                int flags = ignoreCase ? RE.MATCH_CASEINDEPENDENT
199:                        : RE.MATCH_NORMAL;
200:                return new RE(s, flags);
201:            }
202:
203:            public static boolean reMatch(Object re, String s) {
204:                return ((RE) re).match(s);
205:            }
206:
207:            //   public static int reSearch (Object re, String s, int start) {
208:            //       for (int i=start; i < s.length(); i++) {
209:            //           if (((RE)re).match (s, i))
210:            //               return i;
211:            //           }
212:            //       return -1;
213:            //       }
214:
215:            public static String reSearch(Object re, String s, int start,
216:                    int paren) {
217:                for (int i = start; i < s.length(); i++) {
218:                    if (((RE) re).match(s, i)) {
219:                        return ((RE) re).getParen(paren);
220:                    }
221:                }
222:                return null;
223:            }
224:
225:            public static void main(String[] av) throws Exception {
226:                System.out.println(av[0]);
227:
228:                Object re = newRE(av[0], false);
229:                System.out.println(reSearch(re, av[1], 0, 0));
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.