KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > wsdl > symbolTable > UndefinedDelegate


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.symbolTable;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Vector JavaDoc;
20
21 /**
22  * This UndefinedDelegate class implements the common functions of UndefinedType and UndefinedElement.
23  */

24 public class UndefinedDelegate implements Undefined {
25
26     /** Field list */
27     private Vector JavaDoc list;
28
29     /** Field undefinedType */
30     private TypeEntry undefinedType;
31
32     /**
33      * Constructor
34      *
35      * @param te
36      */

37     UndefinedDelegate(TypeEntry te) {
38         list = new Vector JavaDoc();
39         undefinedType = te;
40     }
41
42     /**
43      * Register referrant TypeEntry so that
44      * the code can update the TypeEntry when the Undefined Element or Type is defined
45      *
46      * @param referrant
47      */

48     public void register(TypeEntry referrant) {
49         list.add(referrant);
50     }
51
52     /**
53      * Call update with the actual TypeEntry. This updates all of the
54      * referrant TypeEntry's that were registered.
55      *
56      * @param def
57      * @throws IOException
58      */

59     public void update(TypeEntry def) throws IOException JavaDoc {
60
61         boolean done = false;
62
63         while (!done) {
64             done = true; // Assume this is the last pass
65

66             // Call updatedUndefined for all items on the list
67
// updateUndefined returns true if the state of the te TypeEntry
68
// is changed. The outer loop is traversed until there are no more
69
// state changes.
70
for (int i = 0; i < list.size(); i++) {
71                 TypeEntry te = (TypeEntry) list.elementAt(i);
72
73                 if (te.updateUndefined(undefinedType, def)) {
74                     done = false; // Items still undefined, need another pass
75
}
76             }
77         }
78
79         // It is possible that the def TypeEntry depends on an Undefined type.
80
// If so, register all of the entries with the undefined type.
81
TypeEntry uType = def.getUndefinedTypeRef();
82
83         if (uType != null) {
84             for (int i = 0; i < list.size(); i++) {
85                 TypeEntry te = (TypeEntry) list.elementAt(i);
86
87                 ((Undefined) uType).register(te);
88             }
89         }
90     }
91 }
92
Popular Tags