KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55 package org.jboss.axis.wsdl.toJava;
56
57 import java.util.ArrayList JavaDoc;
58 import java.util.Iterator JavaDoc;
59 import java.util.List JavaDoc;
60
61 /**
62  * File info available after emit to describe what
63  * exactly was created by the Emitter.
64  *
65  * @author Tom Jordahl (tomj@macromedia.com)
66  */

67 public class GeneratedFileInfo
68 {
69
70    protected ArrayList JavaDoc list = new ArrayList JavaDoc();
71
72    /**
73     * Structure to hold entries.
74     * There are three public data members:
75     * <ul>
76     * <li><code>fileName</code> - A relative path of the generated file.</li>
77     * <li><code>className</code> - The name of the class in the file.</li>
78     * <li><code>type</code> - The type of the file.<br>
79     * Valid types are:<br>
80     * <code>
81     * stub, interface, complexType, enumType, fault, holder, skeleton,
82     * skeletonImpl, service, deploy, undeploy, testCase
83     * </code></li>
84     * </ul>
85     */

86    public class Entry
87    {
88       // relative path of the emitted file
89
public String JavaDoc fileName;
90       // name of emitted class
91
public String JavaDoc className;
92       // function of the emitted class
93
public String JavaDoc type;
94
95       public Entry(String JavaDoc name, String JavaDoc className, String JavaDoc type)
96       {
97          this.fileName = name;
98          this.className = className;
99          this.type = type;
100       }
101
102       public String JavaDoc toString()
103       {
104          return "Name: " + fileName +
105                  " Class: " + className +
106                  " Type: " + type;
107       }
108
109
110    } // Entry
111

112
113    /**
114     * Construct an empty file info list.
115     */

116    public GeneratedFileInfo()
117    {
118    }
119
120    /**
121     * Return the entire list of generated files
122     */

123    public List JavaDoc getList()
124    {
125       return list;
126    }
127
128    /**
129     * Add an entry
130     */

131    public void add(String JavaDoc name, String JavaDoc className, String JavaDoc type)
132    {
133       list.add(new Entry(name, className, type));
134    }
135
136    /**
137     * Lookup an entry by type.
138     * <br>
139     * Valid type values are:
140     * stub, interface, complexType, enumType, fault, holder, skeleton,
141     * skeletonImpl, service, deploy, undeploy, testCase
142     *
143     * @param type of objects you want info about
144     * @return A list of <code>org.jboss.axis.wsdl.toJava.GeneratedFileInfo.Entry</code> objects. Null if no objects found.
145     */

146    public List JavaDoc findType(String JavaDoc type)
147    {
148       // look at each entry for the type we want
149
ArrayList JavaDoc ret = null;
150       for (Iterator JavaDoc i = list.iterator(); i.hasNext();)
151       {
152          Entry e = (Entry)i.next();
153          if (e.type.equals(type))
154          {
155             if (ret == null)
156                ret = new ArrayList JavaDoc();
157             ret.add(e);
158          }
159       }
160       return ret;
161    }
162
163    /**
164     * Lookup an entry by file name
165     *
166     * @param file name you want info about
167     * @return The entry for the file name specified. Null if not found
168     */

169    public Entry findName(String JavaDoc fileName)
170    {
171       // look at each entry for the type we want
172
for (Iterator JavaDoc i = list.iterator(); i.hasNext();)
173       {
174          Entry e = (Entry)i.next();
175          if (e.fileName.equals(fileName))
176          {
177             return e;
178          }
179       }
180       return null;
181    }
182
183    /**
184     * Lookup an entry by class name
185     *
186     * @param class name you want info about
187     * @return The entry for the class specified. Null if not found
188     */

189    public Entry findClass(String JavaDoc className)
190    {
191       // look at each entry for the type we want
192
for (Iterator JavaDoc i = list.iterator(); i.hasNext();)
193       {
194          Entry e = (Entry)i.next();
195          if (e.className.equals(className))
196          {
197             return e;
198          }
199       }
200       return null;
201    }
202
203    /**
204     * Get the list of generated classes
205     */

206    public List JavaDoc getClassNames()
207    {
208       // is there a better way to do this?
209
ArrayList JavaDoc ret = new ArrayList JavaDoc(list.size());
210       for (Iterator JavaDoc i = list.iterator(); i.hasNext();)
211       {
212          Entry e = (Entry)i.next();
213          ret.add(e.className);
214       }
215       return ret;
216    }
217
218    /**
219     * Get the list of generated filenames
220     */

221    public List JavaDoc getFileNames()
222    {
223       // is there a better way to do this?
224
ArrayList JavaDoc ret = new ArrayList JavaDoc(list.size());
225       for (Iterator JavaDoc i = list.iterator(); i.hasNext();)
226       {
227          Entry e = (Entry)i.next();
228          ret.add(e.fileName);
229       }
230       return ret;
231    }
232
233    /**
234     * Convert all entries in the list to a string
235     */

236    public String JavaDoc toString()
237    {
238       String JavaDoc s = "";
239       for (Iterator JavaDoc i = list.iterator(); i.hasNext();)
240       {
241          Entry entry = (Entry)i.next();
242          s += entry.toString() + "\n";
243       }
244       return s;
245    }
246 }
247
Popular Tags