KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > xmiio > common > AbstractXMIIOGenerator


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

20 package org.objectweb.modfact.corba.xmiio.common;
21
22 import org.objectweb.modfact.corba.generator.BracketGenerator;
23 import org.omg.mof.Model.ModelElement;
24 import org.objectweb.modfact.corba.helper.IDLCommon;
25 import org.objectweb.modfact.corba.helper.JavaCommon;
26 import org.objectweb.modfact.corba.helper.MOFCommon;
27 import org.objectweb.modfact.corba.helper.StringHelper;
28 import org.objectweb.modfact.corba.helper.XMIImportCommon;
29 import org.objectweb.modfact.corba.logging.ModFactLogger;
30 import org.objectweb.modfact.corba.logging.Level;
31
32 public abstract class AbstractXMIIOGenerator extends BracketGenerator {
33
34     /** The IDL Helper. */
35     protected IDLCommon idlHelper;
36     
37     /** The MOF Helper. */
38     protected MOFCommon mofHelper;
39     
40     /** The Java Helper. */
41     protected JavaCommon javaHelper;
42     
43     /** The XMI Import Helper. */
44     protected XMIImportCommon xmiImpHelper;
45
46     /** The IDL2Java mapping compliance flag. */
47     protected boolean mappingValid;
48
49     /** The logger. */
50     protected ModFactLogger _logger = ModFactLogger.getLogger("fr.lip6.src.mdafactory.generation.xmiimport.GenerationXMIImportApplication");
51
52     /* (non-Javadoc)
53      * @see org.objectweb.modfact.corba.generator.Generator#setInput(org.omg.mof.Model.ModelElement[])
54      */

55     public void setInput(ModelElement[] elt) throws Exception JavaDoc {
56         // TODO Auto-generated method stub
57
}
58
59     /* (non-Javadoc)
60      * @see org.objectweb.modfact.corba.generator.Generator#setLogger(java.util.logging.Logger)
61      */

62     public void setLogger(ModFactLogger log) throws Exception JavaDoc {
63         _logger = log;
64     }
65
66     /* (non-Javadoc)
67      * @see org.objectweb.modfact.corba.generator.Generator#generate()
68      */

69     public void generate() throws Exception JavaDoc {
70         // TODO Auto-generated method stub
71
}
72
73     /**
74      * Annotation processing.
75      * @param annotation_ The annotation to print.
76      */

77     public void annotationTemplate(String JavaDoc annotation_) throws org.omg.mof.Reflective.MofError {
78         /* !!! Management of the carriage return, the tabulations (and the character \s) */
79         if (annotation_.trim().length() > 0) {
80             String JavaDoc annotation = "/** \n" + StringHelper.replaceAll(annotation_.trim(), "\\\\n", "\n") + "\n/";
81             annotation = StringHelper.replaceAll(annotation, "\\\\s", " ");
82             StringBuffer JavaDoc margin = new StringBuffer JavaDoc();
83             for (int i = 0; i < level; i++)
84                 margin.append(TABULATION);
85             annotation = StringHelper.replaceAll(annotation, "\n", "\n" + margin.toString() + " *");
86             outputln(annotation);
87         }
88     }
89
90     /**
91      * Get the class name.
92      * @param package_name_ The root package name.
93      * @param suffix_ The suffix (i.e. XMIImport, XMIExport)
94      * @return The class name.
95      */

96     protected String JavaDoc getClassName(String JavaDoc package_name_, String JavaDoc suffix_) {
97         _logger.log(Level.FINE, "getClassName(" + package_name_ + ")");
98         String JavaDoc packageName1 = idlHelper.format1(package_name_);
99         String JavaDoc className = filename;
100         if (filename.trim().length() > 0) {
101             while (className.indexOf(java.io.File.separator) != -1)
102                 className = className.substring(className.indexOf(java.io.File.separator) + 1);
103             if (className.lastIndexOf(".java") != -1)
104                 className = className.substring(0, className.lastIndexOf(".java"));
105         } else {
106             className = packageName1 + suffix_;
107         }
108         return className;
109     }
110
111     /**
112      * @param common
113      */

114     public void setIdlHelper(IDLCommon common) {
115         idlHelper = common;
116     }
117
118     /**
119      * @param common
120      */

121     public void setJavaHelper(JavaCommon common) {
122         javaHelper = common;
123     }
124
125     /**
126      * @param b
127      */

128     public void setMappingValid(boolean b) {
129         mappingValid = b;
130     }
131
132     /**
133      * @param common
134      */

135     public void setMofHelper(MOFCommon common) {
136         mofHelper = common;
137     }
138
139     /**
140      * @param common
141      */

142     public void setXmiImpHelper(XMIImportCommon common) {
143         xmiImpHelper = common;
144     }
145
146 }
147
Popular Tags