Source Code Cross Referenced for IfHelper.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: IfHelper.java,v 1.2 2002/04/17 09:29:39 per_nyfelt Exp $
008:
009:        package org.ozoneDB.tools.OPP;
010:
011:        import java.io.*;
012:        import java.lang.reflect.*; //import org.apache.regexp.*;
013:        import org.ozoneDB.DxLib.*;
014:
015:        /**
016:         * Helper class that allows to parse the Java source code of interface files
017:         * to find out extra class information.
018:         * 
019:         * 
020:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
021:         * @version $Revision: 1.2 $Date: 2002/04/17 09:29:39 $
022:         */
023:        class IfHelper {
024:
025:            protected Class cl;
026:
027:            protected Class dbInterface;
028:
029:            protected boolean quiet;
030:
031:            protected Object re;
032:
033:            protected String outputDir;
034:
035:            /**
036:             * Names of update methods as Strings.
037:             */
038:            protected DxHashMap updateMethodsIf = new DxHashMap();
039:
040:            public IfHelper(Class _cl, String _outputDir, boolean _quiet) {
041:                cl = _cl;
042:                outputDir = _outputDir;
043:                quiet = _quiet;
044:            }
045:
046:            /**
047:             * Recursivly search all remote interfaces (implement OzoneRemote) for
048:             * update methods.
049:             */
050:            public void searchUpdateMethods(DxHashMap updateMethodsIf)
051:                    throws Exception {
052:                Class dbRemote = Class.forName("org.ozoneDB.OzoneRemote");
053:
054:                java.util.Vector stack = new java.util.Vector();
055:                stack.addElement(cl);
056:
057:                while (!stack.isEmpty()) {
058:                    Class dbInterface = (Class) stack.lastElement();
059:                    stack.removeElementAt(stack.size() - 1);
060:                    // System.out.println( "search: " + dbInterface );
061:
062:                    if (dbRemote.isAssignableFrom(dbInterface)
063:                            && !dbRemote.equals(dbInterface)) {
064:                        Class[] ifs = dbInterface.getInterfaces();
065:                        for (int i = 0; i < ifs.length; i++) {
066:                            stack.addElement(ifs[i]);
067:                        }
068:                        if (dbInterface.isInterface()) {
069:                            searchUpdateMethods2(dbInterface, updateMethodsIf);
070:                        }
071:                    }
072:                }
073:            }
074:
075:            /**
076:             * Search all methods that are marked in the source code of the remote
077:             * Java interface.
078:             */
079:            protected void searchUpdateMethods2(Class dbInterface,
080:                    DxHashMap updateMethodsIf) throws Exception {
081:
082:                // method name regexp
083:                Object re = OPPHelper.newRE(OPP.UPDATE_SIGN, true);
084:                // method comment regexp
085:                Object mre = OPPHelper.newRE(OPP.METHOD_PATTERN, false);
086:                // javadoc regexp
087:                Object jre = OPPHelper.newRE(OPP.JAVADOC_PATTERN, false);
088:                // javadoc comemnt start
089:                Object docstart = OPPHelper.newRE("/\\*\\*", false);
090:
091:                //search *.java source in current and in output directory
092:                String sourceName = OPP.sourceDirName
093:                        + OPPHelper.classFileBasename(dbInterface) + ".java";
094:
095:                if (!quiet) {
096:                    System.out.print("      trying to process " + sourceName
097:                            + "... ");
098:                }
099:
100:                if (!new File(sourceName).exists()) {
101:                    sourceName = outputDir
102:                            + OPPHelper.classFileBasename(dbInterface)
103:                            + ".java";
104:                    if (!new File(sourceName).exists()) {
105:                        if (!quiet) {
106:                            System.out
107:                                    .println(" no source file for this interface found.");
108:                        }
109:                        return;
110:                    }
111:                }
112:
113:                if (!quiet) {
114:                    System.out.println("(" + sourceName + ")");
115:                }
116:
117:                LineNumberReader in = new LineNumberReader(new FileReader(
118:                        sourceName));
119:                String line = in.readLine();
120:                // to support multi line method signatures
121:                // the regexp for update must match on the method signature line
122:                //      or one the followings
123:                boolean isJavadocUpdate = false;
124:                String lastMatchedMethod = null;
125:                while (line != null) {
126:                    // System.out.println (line);
127:                    boolean isUpdate = OPPHelper.reSearch(re, line, 0, 0) != null;
128:                    // before each method stands his appropriate javadoc comment
129:                    String match = OPPHelper.reSearch(docstart, line, 0, 0);
130:                    if (match != null) {
131:                        lastMatchedMethod = null;
132:                        isJavadocUpdate = false;
133:                    }
134:
135:                    match = OPPHelper.reSearch(mre, line, 0, 1);
136:                    if (match != null) {
137:                        lastMatchedMethod = match;
138:                    }
139:                    match = OPPHelper.reSearch(jre, line, 0, 0);
140:                    if (match != null) {
141:                        isJavadocUpdate = true;
142:                    }
143:                    if (lastMatchedMethod != null
144:                            && (isUpdate || isJavadocUpdate)) {
145:                        String methodName = lastMatchedMethod;
146:                        /*System.out.println (this.getClass().getName() + " method: "
147:                                 + methodName + " matched per update regexp in interface ");*/
148:                        updateMethodsIf.addForKey(methodName, methodName);
149:                        lastMatchedMethod = null;
150:                        isJavadocUpdate = false;
151:                    } else if (lastMatchedMethod == null && isUpdate) {
152:                        OPPHelper.warnMsg(OPPHelper
153:                                .classFileBasename(dbInterface)
154:                                + ".java", in.getLineNumber(),
155:                                "Unable to determine the method name for the "
156:                                        + " found update definition in line "
157:                                        + in.getLineNumber() + ".");
158:                    } else {
159:                        if (lastMatchedMethod != null && !isUpdate
160:                                && !isJavadocUpdate) {
161:                            String methodName = lastMatchedMethod;
162:                            if (updateMethodsIf.contains(methodName)) {
163:                                OPPHelper
164:                                        .warnMsg(
165:                                                OPPHelper
166:                                                        .classFileBasename(dbInterface)
167:                                                        + ".java",
168:                                                in.getLineNumber(),
169:                                                "All '"
170:                                                        + methodName
171:                                                        + "' methods will be marked as update methods.");
172:                            }
173:                        }
174:                    }
175:                    line = in.readLine();
176:                }
177:                in.close();
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.