Source Code Cross Referenced for Package.java in  » Scripting » Nice » gnu » expr » 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 » Scripting » Nice » gnu.expr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************/
002:        /*                                N I C E                                 */
003:        /*             A high-level object-oriented research language             */
004:        /*                        (c) Daniel Bonniot 2001                         */
005:        /*                                                                        */
006:        /*  This program is free software; you can redistribute it and/or modify  */
007:        /*  it under the terms of the GNU General Public License as published by  */
008:        /*  the Free Software Foundation; either version 2 of the License, or     */
009:        /*  (at your option) any later version.                                   */
010:        /*                                                                        */
011:        /**************************************************************************/package gnu.expr;
012:
013:        import gnu.bytecode.*;
014:
015:        import java.io.File;
016:        import java.io.FileOutputStream;
017:
018:        /**
019:         A set of classes to generate as a java-like package.
020:
021:         Extends expression to make it possible to walk the package.
022:         The walk is performed on each class of the package.
023:
024:         @version $Date: 2002/02/02 12:21:47 $
025:         @author Daniel Bonniot (Daniel.Bonniot@inria.fr)
026:         */
027:
028:        public class Package extends Expression {
029:            /** Create a Bytecode Package.
030:
031:                @param name qualified name of the package (e.g. "my.package")
032:             */
033:            public Package(String name) {
034:                this .name = name;
035:                this .prefix = name.replace('.', '/') + "/";
036:            }
037:
038:            public void print(gnu.mapping.OutPort ps) {
039:                ps.print("Package " + name);
040:            }
041:
042:            public void compile(Compilation comp, Target target) {
043:                throw new Error("A package cannot be evaluated");
044:            }
045:
046:            protected void walkChildren(ExpWalker walker) {
047:                for (LambdaExp c = firstClass; c != null; c = c.nextSibling)
048:                    c.walk(walker);
049:            }
050:
051:            public void addClass(ClassExp classe) {
052:                classe.nextSibling = firstClass;
053:                firstClass = classe;
054:            }
055:
056:            ClassExp firstClass;
057:
058:            void addClass(ClassType c) {
059:                classes.add(c);
060:            }
061:
062:            /** Search this package for a class with a given name.
063:             * @param name the name of the class desired
064:             * @return the matching ClassType, or null if none is found */
065:            public ClassType findNamedClass(String name) {
066:                for (int i = classes.size(); --i >= 0;) {
067:                    if (name.equals(((ClassType) classes.get(i)).getName()))
068:                        return (ClassType) classes.get(i);
069:                }
070:                return null;
071:            }
072:
073:            private java.util.Vector classes = new java.util.Vector(10);
074:
075:            public Package next;
076:
077:            /** Qualified name, e.g. "my.package". */
078:            public final String name;
079:
080:            /** "my/package/" */
081:            public final String prefix;
082:
083:            public File directory;
084:
085:            public void compileToFiles() throws java.io.IOException {
086:                Compilation comp = new Compilation();
087:                comp.compile(this );
088:
089:                for (Package p = this ; p != null; p = p.next)
090:                    p.writeClasses();
091:            }
092:
093:            private void writeClasses() throws java.io.IOException {
094:                for (java.util.Iterator i = classes.iterator(); i.hasNext();) {
095:                    ClassType clas = (ClassType) i.next();
096:                    String name = clas.getName();
097:                    int lastDot = name.lastIndexOf('.');
098:                    if (lastDot != -1) {
099:                        if (!name.substring(0, lastDot).equals(this .name))
100:                            throw new Error(
101:                                    "Class generated in the wrong package: "
102:                                            + name + " was found in package "
103:                                            + this .name);
104:
105:                        name = name.substring(lastDot + 1);
106:                    }
107:
108:                    File out = new File(directory, name + ".class");
109:                    out.getParentFile().mkdirs();
110:                    clas.writeToFile(out);
111:                }
112:            }
113:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.