KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > AbstractPlugin


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.ide;
20
21 import java.io.IOException JavaDoc;
22 import java.io.Writer JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 /**
26  * Abstract base class for aspect config file plugins
27  */

28
29 public abstract class AbstractPlugin implements AspectPlugin {
30     AccGenState state;
31
32     public void genConfig(Writer JavaDoc output, Project project)
33         throws IOException JavaDoc
34     {
35         Iterator JavaDoc it = project.getPackages().iterator();
36         while (it.hasNext()) {
37             Package JavaDoc pkg = (Package JavaDoc)it.next();
38             genPackageConfig(output,project,pkg);
39         }
40     }
41
42     /**
43      * Generate default rtti config code for a package
44      */

45     public void genPackageConfig(Writer JavaDoc output,
46                                  Project project, Package JavaDoc pkg)
47         throws IOException JavaDoc
48     {
49         Iterator JavaDoc it = pkg.getSubPackages().iterator();
50         while (it.hasNext()) {
51             Package JavaDoc subPkg = (Package JavaDoc)it.next();
52             genPackageConfig(output,project,subPkg);
53         }
54         it = pkg.getClasses().iterator();
55         while (it.hasNext()) {
56             Class JavaDoc cl = (Class JavaDoc)it.next();
57             if (!(cl instanceof Interface)) {
58                 state = new AccGenState(output);
59                 genClassConfig(output,project,pkg,cl);
60                 state.closeClass();
61             }
62         }
63     }
64
65     /**
66      * Generate default rtti config code for a class
67      */

68     public void genClassConfig(Writer JavaDoc output,
69                                Project project, Package JavaDoc pkg, Class JavaDoc cl)
70         throws IOException JavaDoc
71     {
72         Iterator JavaDoc it = cl.getFields().iterator();
73         while (it.hasNext()) {
74             Field field = (Field)it.next();
75             genFieldConfig(output,project,pkg,cl,field);
76             state.closeMember();
77         }
78
79         it = cl.getMethods().iterator();
80         while (it.hasNext()) {
81             Method method = (Method)it.next();
82             genMethodConfig(output,project,pkg,cl,method);
83             state.closeMember();
84         }
85
86         it = cl.getRelationRoles().iterator();
87         while (it.hasNext()) {
88             RelationRole role = (RelationRole)it.next();
89             genRoleConfig(output,project,pkg,cl,role);
90             state.closeMember();
91         }
92     }
93
94     /**
95      * Generate default rtti config code for a field
96      */

97     public void genFieldConfig(Writer JavaDoc output, Project project,
98                                Package JavaDoc pkg, Class JavaDoc cl, Field field)
99         throws IOException JavaDoc
100     {}
101
102     /**
103      * Generate default rtti config code for a method
104      */

105     public void genMethodConfig(Writer JavaDoc output, Project project,
106                                 Package JavaDoc pkg, Class JavaDoc cl, Method method)
107         throws IOException JavaDoc
108     {}
109
110
111     /**
112      * Generate default rtti config code for a relation role
113      */

114     public void genRoleConfig(Writer JavaDoc output, Project project,
115                               Package JavaDoc pkg, Class JavaDoc cl, RelationRole role)
116         throws IOException JavaDoc
117     {}
118 }
119
Popular Tags