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


001:        // Copyright 1997-@year@ by SMB GmbH. All rights reserved.
002:        // Copyright Tim Brown <Tim.Brown@incenter.org>. All rights reserved.
003:        //
004:        // You can redistribute this software and/or modify it under the terms of
005:        // the Ozone Library License version 1 published by ozone-db.org.
006:        //
007:        // $Id: OIG.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
008:
009:        package org.ozoneDB.tools;
010:
011:        import java.lang.*;
012:        import java.util.*;
013:        import java.io.*;
014:
015:        /**
016:         * Ozone Interface Generator
017:         * 
018:         * <p>This class is meant to be run statically only. It will generate an
019:         * OzoneRemote interface for your OzoneObject (s)
020:         * 
021:         * <p>USAGE:
022:         * 
023:         * <p>&nbsp;java OzoneInterfaceGenerator your_OzoneObject
024:         * 
025:         * <p>CONVENTIONS:
026:         * 
027:         * <p>&nbsp;Class Names
028:         * 
029:         * <p>&nbsp;OzoneObject classes must be named like *Impl.java. Interfaces
030:         * are generated with a _Int inserted into the name.
031:         * 
032:         * <p>File Naming:
033:         * 
034:         * <p>OzoneObjects must have names like: CarImpl.java The interface generated
035:         * will be: CarImpl_Int.java
036:         * 
037:         * <p>You do not have to use "Impl". Any name will do. I use a standard because
038:         * it is then easy to write makefile rules like:
039:         * 
040:         * <p>%.class: %.java
041:         * <br>&nbsp;&nbsp;&nbsp; javac $(JFLAGS) -classpath $(CPATH) $&lt;
042:         * <p>%Impl_Proxy.class: %Impl.java
043:         * <br>&nbsp;&nbsp;&nbsp;/projects/ozone/bin/opp $*Impl
044:         * <p>%Impl_Int.java: %Impl.java
045:         * <br>&nbsp;&nbsp;&nbsp;java -Djava.compiler=tya -classpath $(CPATH) OzoneInterfaceGenerator $*Impl
046:         * <p>javasrc = $(wildcard *.java)
047:         * <br>classes = $(javasrc:.java=.class)
048:         * <br>htmlobjs = $(javasrc:.java=.html)
049:         * <br>IntSrc = $(wildcard *Impl.java)
050:         * <br>IntObjs = $(IntSrc:Impl.java=Impl_Int.java)
051:         * <br>proxies = $(IntSrc:Impl.java=Impl_Proxy.class)
052:         * <br>proxysrc = $(IntSrc:Impl.java=Impl.class)
053:         * 
054:         * <p>Coding Style
055:         * 
056:         * <p>&nbsp;Public methods must have ALL parameters on one line. Infact
057:         * everything up to and including the open curly brace must be on the first
058:         * line.
059:         * 
060:         * <p>Patterns for identifying methods which should be locked are stored in
061:         * a file called int_config. This file should be in the same directory as
062:         * the .java files. You need to list one pattern per line. Like:
063:         * <br>&nbsp;set
064:         * <br>&nbsp;update
065:         * <br>&nbsp;reset
066:         * <br>&nbsp;delete
067:         * <br>&nbsp;modify
068:         * <br>&nbsp;
069:         * <br>&nbsp;
070:         * 
071:         * <p>OzoneInterfaceGenerator looks for and reads these in. If the first line
072:         * of your public method contains any of these strings it appends //update
073:         * to the end signaling OPP to make that method a locked() method.
074:         * 
075:         * <p>If you do not provide a int_config file OIG uses my favorites, listed
076:         * above.
077:         * 
078:         * <p>Public Method Examples:
079:         * <p>public void setName(String _name) { this.name = _name; }
080:         * <br>&nbsp;in the generated interface it produces:
081:         * <br>&nbsp;public void setName(String _name);//update
082:         * <br>&nbsp;
083:         * <br>&nbsp;
084:         * 
085:         * <p>In the following example I use a comment to identify the update method.
086:         * One of the patterns just has to be on the first line.
087:         * <br>&nbsp;
088:         * <br>&nbsp;
089:         * <br>public void killMe() { // update
090:         * <br>&nbsp;Produces:
091:         * <br>&nbsp;public void killMe();//update
092:         * <br>&nbsp;
093:         * <br>&nbsp;
094:         * <p>NOTE:
095:         * <p>&nbsp;OIG will handle this:
096:         * <p>&nbsp;public static final String x = new String("test");
097:         * <br>&nbsp;
098:         * <br>&nbsp;
099:         * <p>BUT not this: (working on this :) It will get mistaken for a method.
100:         * <p>&nbsp;public String x = new String("test");
101:         * <br>&nbsp;
102:         * <br>&nbsp;
103:         * <p>
104:         * 
105:         * 
106:         */
107:        public class OIG {
108:
109:            public static void main(String[] args) {
110:                Vector updatePatterns = null;
111:                BufferedReader in = null;
112:                PrintWriter out = null;
113:
114:                updatePatterns = getPatterns();
115:
116:                try {
117:                    // first try to use args
118:                    in = new BufferedReader(new FileReader(args[0] + ".java"),
119:                            1024);
120:                    out = new PrintWriter(new FileWriter(args[0] + "_Int.java"));
121:                } catch (Exception e) {
122:                    System.err.println("Using stdin");
123:                    in = new BufferedReader(new InputStreamReader(System.in),
124:                            1024);
125:                    out = new PrintWriter(System.out);
126:                }
127:                try {
128:                    String buf;
129:                    String tbuf;
130:                    StringTokenizer tok;
131:                    boolean fndOpen = false;
132:                    boolean fndConst = false;
133:                    String classname = null;
134:                    String intname = null;
135:
136:                    while ((buf = in.readLine()) != null) {
137:                        if (buf.startsWith("{")) {
138:                            out.println(buf);
139:                            fndOpen = true;
140:                        }
141:
142:                        if (!fndOpen) {
143:                            if (buf.startsWith("import")
144:                                    || buf.startsWith("package")) {
145:                                out.println(buf);
146:                            } else {
147:
148:                                if (buf.startsWith("public class")
149:                                        || buf
150:                                                .startsWith("public abstract class")) {
151:                                    int beg;
152:                                    int end;
153:                                    beg = buf.indexOf("class") + 6;
154:                                    end = buf.indexOf(" ", beg);
155:                                    classname = buf.substring(beg, end);
156:                                    intname = classname + "_Int";
157:
158:                                    out
159:                                            .print("import org.ozoneDB.OzoneRemote;\n"
160:                                                    + "import org.ozoneDB.DxLib.*;\n"
161:                                                    + "\npublic interface "
162:                                                    + intname
163:                                                    + " extends OzoneRemote\n");
164:
165:                                }
166:                            }
167:                        } else {
168:                            if (buf.indexOf("static") == -1) {
169:                                buf = remove(buf, "synchronized");
170:                                tok = new StringTokenizer(buf);
171:                                if (tok.hasMoreTokens()) {
172:                                    tbuf = tok.nextToken();
173:                                    if (tbuf.startsWith("public")
174:                                            && (buf.indexOf("(") > 0
175:                                                    && buf.indexOf("{") > 0 || buf
176:                                                    .indexOf(");") > 0)) {
177:                                        if (!fndConst) {
178:                                            fndConst = true;
179:                                        } else {
180:                                            tbuf = tok.nextToken();
181:                                            if (!tbuf.startsWith(classname)) {
182:                                                out.print(buf.substring(0, buf
183:                                                        .indexOf(")") + 1)
184:                                                        + ";");
185:                                                Enumeration en = updatePatterns
186:                                                        .elements();
187:                                                while (en.hasMoreElements()) {
188:                                                    String s = (String) en
189:                                                            .nextElement();
190:                                                    if (buf.indexOf(s) != -1) {
191:                                                        out.println("//update");
192:                                                        break;
193:                                                    }
194:                                                }
195:                                                out.print("\n");
196:                                            }
197:                                        }
198:                                    }
199:                                }
200:                            }
201:                        }
202:                    }
203:                    out.println("}");
204:                    out.close();
205:
206:                } catch (Exception e) {
207:                    System.out.flush();
208:                    System.err.println(e);
209:                }
210:            }
211:
212:            private static Vector getPatterns() {
213:                BufferedReader in = null;
214:                Vector lst = new Vector();
215:                try {
216:                    in = new BufferedReader(new FileReader("int_config"), 1024);
217:                    String buf = null;
218:                    while ((buf = in.readLine()) != null) {
219:                        lst.addElement(buf);
220:                    }
221:                    in.close();
222:                    return lst;
223:                } catch (Exception e) {
224:                    lst.addElement("delete");
225:                    lst.addElement("set");
226:                    lst.addElement("update");
227:                    lst.addElement("modify");
228:                    lst.addElement("reset");
229:                    return lst;
230:                }
231:            }
232:
233:            private static String remove(String buf, String rem) {
234:                try {
235:                    int beg;
236:                    int end;
237:
238:                    beg = buf.indexOf(rem);
239:                    if (beg == -1) {
240:                        return buf;
241:                    }
242:                    end = buf.indexOf(" ", beg);
243:                    if (end == -1) {
244:                        return buf;
245:                    }
246:                    return buf.substring(0, beg - 1) + buf.substring(end);
247:                } catch (Exception e) {
248:                    return buf;
249:                }
250:
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.