KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > wsdl > toJava > GeneratedFileInfo


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis.wsdl.toJava;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21
22 /**
23  * File info available after emit to describe what
24  * exactly was created by the Emitter.
25  *
26  * @author Tom Jordahl (tomj@macromedia.com)
27  */

28 public class GeneratedFileInfo {
29
30     /** Field list */
31     protected ArrayList JavaDoc list = new ArrayList JavaDoc();
32
33     /**
34      * Structure to hold entries.
35      * There are three public data members:
36      * <ul>
37      * <li><code>fileName</code> - A relative path of the generated file.</li>
38      * <li><code>className</code> - The name of the class in the file.</li>
39      * <li><code>type</code> - The type of the file.<br>
40      * Valid types are:<br>
41      * <code>
42      * stub, interface, complexType, enumType, fault, holder, skeleton,
43      * skeletonImpl, service, deploy, undeploy, testCase
44      * </code></li>
45      * </ul>
46      */

47     public class Entry {
48
49         // relative path of the emitted file
50

51         /** Field fileName */
52         public String JavaDoc fileName;
53
54         // name of emitted class
55

56         /** Field className */
57         public String JavaDoc className;
58
59         // function of the emitted class
60

61         /** Field type */
62         public String JavaDoc type;
63
64         /**
65          * Constructor Entry
66          *
67          * @param name
68          * @param className
69          * @param type
70          */

71         public Entry(String JavaDoc name, String JavaDoc className, String JavaDoc type) {
72
73             this.fileName = name;
74             this.className = className;
75             this.type = type;
76         }
77
78         /**
79          * Method toString
80          *
81          * @return
82          */

83         public String JavaDoc toString() {
84             return "Name: " + fileName + " Class: " + className + " Type: "
85                     + type;
86         }
87     } // Entry
88

89     /**
90      * Construct an empty file info list.
91      */

92     public GeneratedFileInfo() {
93     }
94
95     /**
96      * Return the entire list of generated files
97      *
98      * @return
99      */

100     public List JavaDoc getList() {
101         return list;
102     }
103
104     /**
105      * Add an entry
106      *
107      * @param name
108      * @param className
109      * @param type
110      */

111     public void add(String JavaDoc name, String JavaDoc className, String JavaDoc type) {
112         list.add(new Entry(name, className, type));
113     }
114
115     /**
116      * Lookup an entry by type.
117      * <br>
118      * Valid type values are:
119      * stub, interface, complexType, enumType, fault, holder, skeleton,
120      * skeletonImpl, service, deploy, undeploy, testCase
121      *
122      * @param type of objects you want info about
123      * @return A list of <code>org.apache.axis.wsdl.toJava.GeneratedFileInfo.Entry</code> objects. Null if no objects found.
124      */

125     public List JavaDoc findType(String JavaDoc type) {
126
127         // look at each entry for the type we want
128
ArrayList JavaDoc ret = null;
129
130         for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
131             Entry e = (Entry) i.next();
132
133             if (e.type.equals(type)) {
134                 if (ret == null) {
135                     ret = new ArrayList JavaDoc();
136                 }
137
138                 ret.add(e);
139             }
140         }
141
142         return ret;
143     }
144
145     /**
146      * Lookup an entry by file name
147      *
148      * @param file name you want info about
149      * @param fileName
150      * @return The entry for the file name specified. Null if not found
151      */

152     public Entry findName(String JavaDoc fileName) {
153
154         // look at each entry for the type we want
155
for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
156             Entry e = (Entry) i.next();
157
158             if (e.fileName.equals(fileName)) {
159                 return e;
160             }
161         }
162
163         return null;
164     }
165
166     /**
167      * Lookup an entry by class name
168      *
169      * @param class name you want info about
170      * @param className
171      * @return The entry for the class specified. Null if not found
172      */

173     public Entry findClass(String JavaDoc className) {
174
175         // look at each entry for the type we want
176
for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
177             Entry e = (Entry) i.next();
178
179             if (e.className.equals(className)) {
180                 return e;
181             }
182         }
183
184         return null;
185     }
186
187     /**
188      * Get the list of generated classes
189      *
190      * @return
191      */

192     public List JavaDoc getClassNames() {
193
194         // is there a better way to do this?
195
ArrayList JavaDoc ret = new ArrayList JavaDoc(list.size());
196
197         for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
198             Entry e = (Entry) i.next();
199
200             ret.add(e.className);
201         }
202
203         return ret;
204     }
205
206     /**
207      * Get the list of generated filenames
208      *
209      * @return
210      */

211     public List JavaDoc getFileNames() {
212
213         // is there a better way to do this?
214
ArrayList JavaDoc ret = new ArrayList JavaDoc(list.size());
215
216         for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
217             Entry e = (Entry) i.next();
218
219             ret.add(e.fileName);
220         }
221
222         return ret;
223     }
224
225     /**
226      * Convert all entries in the list to a string
227      *
228      * @return
229      */

230     public String JavaDoc toString() {
231
232         String JavaDoc s = "";
233
234         for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
235             Entry entry = (Entry) i.next();
236
237             s += entry.toString() + "\n";
238         }
239
240         return s;
241     }
242 }
243
Popular Tags