KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > visitorIDL3 > common > Generator


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Mathieu Vadet.
23 Contributor(s): .
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.visitorIDL3.common;
28
29 /**
30  * .
31  *
32  * @author <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
33  *
34  * @version 0.3
35  */

36
37 public class Generator
38 {
39     // ==================================================================
40
//
41
// Internal state.
42
//
43
// ==================================================================
44

45     /**
46      **
47      **/

48     private Printer printer_;
49
50     /**
51      **
52      **/

53     private org.objectweb.ccm.IDL3.Repository repository_;
54
55     /**
56      **
57      **/

58     private java.lang.String JavaDoc template_location_;
59
60     // ==================================================================
61
//
62
// Constructor.
63
//
64
// ==================================================================
65

66     /**
67      ** The default constructor.
68      **/

69     public
70     Generator(org.objectweb.ccm.IDL3.Repository repository)
71     {
72         // init internal state.
73
repository_ = repository;
74         printer_ = null;
75         //
76
// TODO : change the system property name.
77
//
78
template_location_ = System.getProperty("ccm.templates");
79     }
80
81     // ==================================================================
82
//
83
// Internal methods.
84
//
85
// ==================================================================
86

87     // ==================================================================
88
//
89
// Public methods.
90
//
91
// ==================================================================
92

93     /**
94      **
95      **/

96     public void
97     setPrinter(Printer printer)
98     {
99         printer_ = printer;
100     }
101
102     /**
103      **
104      **/

105     public java.lang.String JavaDoc
106     getTemplateLocation()
107     {
108         return template_location_;
109     }
110
111     /**
112      **
113      **/

114     public java.lang.String JavaDoc
115     visitObj(java.lang.String JavaDoc name)
116     {
117         org.objectweb.ccm.IDL3.Declaration decl = null;
118
119         if (name.equals("::"))
120             decl = repository_;
121         else
122             decl = repository_.lookup(name);
123
124         if (decl==null)
125         {
126             java.lang.String JavaDoc msg =
127                 "error in class org.objectweb.ccm.visitorIDL3.Generator\n"+
128                 " operation : visit_obj\n"+
129                 " message : object " + name + " not found : aborting generation !";
130             throw new Error JavaDoc(msg);
131         }
132
133         java.lang.String JavaDoc[] aliases = { "obj" };
134         java.lang.Object JavaDoc[] objs = { decl };
135         printer_.map("OBJECT", aliases, objs);
136
137         return "";
138     }
139 }
140
Popular Tags