001 /* 002 Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public 015 License along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 017 USA */ 018 019 package org.objectweb.jac.ide; 020 021 import java.io.IOException; 022 import java.io.Writer; 023 import java.util.Iterator; 024 025 /** 026 * Abstract base class for aspect config file plugins 027 */ 028 029 public abstract class AbstractPlugin implements AspectPlugin { 030 AccGenState state; 031 032 public void genConfig(Writer output, Project project) 033 throws IOException 034 { 035 Iterator it = project.getPackages().iterator(); 036 while (it.hasNext()) { 037 Package pkg = (Package)it.next(); 038 genPackageConfig(output,project,pkg); 039 } 040 } 041 042 /** 043 * Generate default rtti config code for a package 044 */ 045 public void genPackageConfig(Writer output, 046 Project project, Package pkg) 047 throws IOException 048 { 049 Iterator it = pkg.getSubPackages().iterator(); 050 while (it.hasNext()) { 051 Package subPkg = (Package)it.next(); 052 genPackageConfig(output,project,subPkg); 053 } 054 it = pkg.getClasses().iterator(); 055 while (it.hasNext()) { 056 Class cl = (Class)it.next(); 057 if (!(cl instanceof Interface)) { 058 state = new AccGenState(output); 059 genClassConfig(output,project,pkg,cl); 060 state.closeClass(); 061 } 062 } 063 } 064 065 /** 066 * Generate default rtti config code for a class 067 */ 068 public void genClassConfig(Writer output, 069 Project project, Package pkg, Class cl) 070 throws IOException 071 { 072 Iterator it = cl.getFields().iterator(); 073 while (it.hasNext()) { 074 Field field = (Field)it.next(); 075 genFieldConfig(output,project,pkg,cl,field); 076 state.closeMember(); 077 } 078 079 it = cl.getMethods().iterator(); 080 while (it.hasNext()) { 081 Method method = (Method)it.next(); 082 genMethodConfig(output,project,pkg,cl,method); 083 state.closeMember(); 084 } 085 086 it = cl.getRelationRoles().iterator(); 087 while (it.hasNext()) { 088 RelationRole role = (RelationRole)it.next(); 089 genRoleConfig(output,project,pkg,cl,role); 090 state.closeMember(); 091 } 092 } 093 094 /** 095 * Generate default rtti config code for a field 096 */ 097 public void genFieldConfig(Writer output, Project project, 098 Package pkg, Class cl, Field field) 099 throws IOException 100 {} 101 102 /** 103 * Generate default rtti config code for a method 104 */ 105 public void genMethodConfig(Writer output, Project project, 106 Package pkg, Class cl, Method method) 107 throws IOException 108 {} 109 110 111 /** 112 * Generate default rtti config code for a relation role 113 */ 114 public void genRoleConfig(Writer output, Project project, 115 Package pkg, Class cl, RelationRole role) 116 throws IOException 117 {} 118 }