KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > xmi > XMI1_1DTDGenerator


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.xmi;
21
22 import org.objectweb.modfact.corba.generator.ZipGenerator;
23 import org.objectweb.modfact.corba.helper.MOFCommon;
24 import org.objectweb.modfact.corba.helper.XMICommon;
25 import org.objectweb.modfact.corba.logging.ModFactLogger;
26
27 import java.io.ByteArrayOutputStream JavaDoc;
28 import java.io.IOException JavaDoc;
29 import org.omg.mof.Reflective.*;
30
31 import org.omg.CORBA.TypeCodePackage.*;
32
33 /**
34  *
35  */

36 public class XMI1_1DTDGenerator extends ZipGenerator {
37
38     private org.omg.mof.Model.Package[] input;
39
40     private MOFCommon mofHelper;
41     private XMICommon xmiHelper;
42
43     private ModFactLogger logger;
44
45     /**
46      * Set Input
47      */

48     public void setInput(org.omg.mof.Model.ModelElement[] elt) {
49         input = new org.omg.mof.Model.Package[elt.length];
50         for (int i = 0; i < input.length; i++) {
51             input[i] = (org.omg.mof.Model.Package) elt[i];
52         }
53     }
54
55     /**
56      * Set Trace
57      */

58     public void setLogger(ModFactLogger log) {
59         logger = log;
60     }
61
62     /**
63      * Generate
64      */

65     public void generate()
66         throws
67             MofError,
68             NotSet,
69             BadKind,
70             org.omg.CORBA.TypeCodePackage.Bounds JavaDoc,
71             IOException JavaDoc {
72
73         for (int i = 0; i < input.length; i++) {
74             org.omg.mof.Model.Package[] apackage =
75                 new org.omg.mof.Model.Package[1];
76             apackage[0] = input[i];
77
78             //Traitement du package
79
PackageGenerator packageGenerator = new PackageGenerator();
80             packageGenerator.setInput(apackage);
81             packageGenerator.setLogger(logger);
82             ByteArrayOutputStream JavaDoc entryOutput1 = new ByteArrayOutputStream JavaDoc();
83             packageGenerator.setOutput(entryOutput1);
84             packageGenerator.setXmiHelper(xmiHelper);
85             packageGenerator.setMofHelper(mofHelper);
86             packageGenerator.generate();
87
88             String JavaDoc entryName =
89                 xmiHelper.format1(input[i].name()) + ".dtd";
90             writeEntry(entryName, entryOutput1);
91             entryOutput1.close();
92             //closeFile();
93
}
94         out.finish();
95
96     }
97
98     /**
99      * Returns the mofHelper.
100      * @return MOFCommon
101      */

102     public MOFCommon getMofHelper() {
103         return mofHelper;
104     }
105
106
107     /**
108      * Sets the mofHelper.
109      * @param mofHelper The mofHelper to set
110      */

111     public void setMofHelper(MOFCommon mofHelper) {
112         this.mofHelper = mofHelper;
113     }
114
115     /**
116      * Returns the xmiHelper.
117      * @return XMICommon
118      */

119     public XMICommon getXmiHelper() {
120         return xmiHelper;
121     }
122
123     /**
124      * Sets the xmiHelper.
125      * @param xmiHelper The xmiHelper to set
126      */

127     public void setXmiHelper(XMICommon xmiHelper) {
128         this.xmiHelper = xmiHelper;
129     }
130
131 }
132
Popular Tags