resolve = false; // Assume false
String name = null;
for (int i = 0; (i < v.size()) && !resolve; ++i) {
SymTabEntry entry = (SymTabEntry) v.elementAt(i);
if ((entry instanceof MessageEntry)
|| (entry instanceof BindingEntry)) {
; // Don't process these
} else if (name == null) {
name = entry.getName();
} else if (name.equals(entry.getName())) {
resolve = true; // Need to do resolution
}
}
}
// Full Mangle if resolution is necessary.
if (resolve) {
boolean firstType = true;
for (int i = 0; i < v.size(); ++i) {
SymTabEntry entry = (SymTabEntry) v.elementAt(i);
if (entry instanceof Element) {
entry.setName(mangleName(entry.getName(),
"_ElemType"));
// If this global element was defined using
// an anonymous type, then need to change the
// java name of the anonymous type to match.
QName anonQName =
new QName(entry.getQName().getNamespaceURI(),
SymbolTable.ANON_TOKEN
+ entry.getQName().getLocalPart());
TypeEntry anonType =
symbolTable.getType(anonQName);
if (anonType != null) {
anonType.setName(entry.getName());
anonTypes.add(anonType);
}
} else if (entry instanceof TypeEntry) {
// Search all other types for java names that match this one.
// The sameJavaClass method returns true if the java names are
// the same (ignores [] ).
if (firstType) {
firstType = false;
Iterator types =
symbolTable.getTypeIndex().values().iterator();
while (types.hasNext()) {
TypeEntry type = (TypeEntry) types.next();
if ((type != entry)
&& (type.getBaseType() == null)
&& sameJavaClass(entry.getName(),
type.getName())) {
v.add(type);
}
}
}
// If this is an anonymous type, it's name was resolved in
// the previous if block. Don't reresolve it.
if (!anonTypes.contains(entry)) {
entry.setName(mangleName(entry.getName(),
"_Type"));
}
} else if (entry instanceof PortTypeEntry) {
entry.setName(mangleName(entry.getName(), "_Port"));
} else if (entry instanceof ServiceEntry) {
entry.setName(mangleName(entry.getName(),
"_Service"));
}
// else if (entry instanceof MessageEntry) {
// we don't care about messages
// }
else if (entry instanceof BindingEntry) {
BindingEntry bEntry = (BindingEntry) entry;
// If there is no literal use, then we never see a
// class named directly from the binding name. They
// all have suffixes: Stub, Skeleton, Impl.
// If there IS literal use, then the SDI will be
// named after the binding name, so there is the
// possibility of a name clash.
if (bEntry.hasLiteral()) {
entry.setName(mangleName(entry.getName(),
"_Binding"));
}
}
}
}