// get local name
String localName = getLocalName(xPath);
String typedLocalName = localName;
if (annotated instanceof ElementDecl) {
ElementDecl element = (ElementDecl) annotated;
String typexPath = XPathHelper.getSchemaLocation(element.getType());
xPath += "[" + typexPath + "]";
typedLocalName += "[" + typexPath + "]";
} else if (annotated instanceof Group) {
Group group = (Group) annotated;
if (group.getOrder() == Order.choice
&& !_globalElements.contains("/" + localXPath)) {
xPath += "/#choice";
}
}
ExtendedBinding binding = component.getBinding();
if (binding != null) {
// deal with explicit exclusions
if (binding.existsExclusion(typedLocalName)) {
Exclude exclusion = binding.getExclusion(typedLocalName);
if (exclusion.getClassName() != null) {
LOG.info("Dealing with exclusion for local element " + xPath
+ " as per binding file.");
jClass.changeLocalName(exclusion.getClassName());
}
return;
}
// deal with explicit forces
if (binding.existsForce(localName)) {
List<String> localNamesList = _localNames.get(localName);
memorizeCollision(xPath, localName, localNamesList);
LOG.info("Changing class name for local element " + xPath
+ " as per binding file (force).");
checkAndChange(jClass, annotated, untypedXPath, typedLocalName);
return;
}
}
String jClassLocalName = jClass.getLocalName();
String expectedClassNameDerivedFromXPath = _javaNaming.toJavaClassName(localName);
if (!jClassLocalName.equals(expectedClassNameDerivedFromXPath)) {
if (component.createGroupItem()) {
xPath += "/#item";
}
_xpathToJClass.put(xPath, jClass);
return;
}
if (mode.equals("field")) {
if (annotated instanceof ModelGroup) {
ModelGroup group = (ModelGroup) annotated;
final boolean isReference = group.isReference();
if (isReference) {
return;
}
}
if (annotated instanceof ElementDecl) {
ElementDecl element = (ElementDecl) annotated;
final boolean isReference = element.isReference();
if (isReference) {
ElementDecl referredElement = element.getReference();
// if that global element definition is a substitution head,
// we now
// need to do work out the global element's type, and use
// its
// JClass instance to defer the type of the member currently
// processed
Enumeration<?> possibleSubstitutes = referredElement
.getSubstitutionGroupMembers();
if (possibleSubstitutes.hasMoreElements()) {
XMLType referredType = referredElement.getType();
String xPathType = XPathHelper.getSchemaLocation(referredType);
JClass typeJClass = _xpathToJClass.get(xPathType);
if (typeJClass != null) {
jClass.changeLocalName(typeJClass.getLocalName());
} else {
// manually deriving class name for referenced type
XMLBindingComponent temp = component;
temp.setView(referredType);
jClass.changeLocalName(temp.getJavaClassName());
component.setView(annotated);
}
// String typeXPath = XPathHelper
// .getSchemaLocation(referredElement);
// JClass referredJClass = (JClass) _xpathToJClass
// .get(typeXPath + "_class");
// jClass.changeLocalName(referredJClass.getSuperClass()
// .getLocalName());
}
return;
}
}
}
final boolean alreadyProcessed = _xpathToJClass.containsKey(xPath);
// if already processed, change the JClass instance accordingly
if (alreadyProcessed) {
JClass jClassAlreadyProcessed = _xpathToJClass.get(xPath);
jClass.changeLocalName(jClassAlreadyProcessed.getLocalName());
return;
}
// register JClass instance for XPATH
_xpathToJClass.put(xPath, jClass);
if (LOG.isDebugEnabled()) {
LOG.debug("Binding JClass[" + jClass.getName() + "] for XML schema structure " + xPath);
}
// global elements don't need to change
final boolean isGlobalElement = _globalElements.contains(untypedXPath);
if (isGlobalElement) {
return;
}
// resolve references to global elements
if (mode.equals("field") && annotated instanceof ElementDecl) {
ElementDecl element = (ElementDecl) annotated;
final boolean isReference = element.isReference();
if (isReference) {
ElementDecl referredElement = element.getReference();
// if that global element definition is a substitution head, we
// now
// need to do work out the global element's type, and use its
// JClass instance to defer the type of the member currently
// processed
Enumeration<?> possibleSubstitutes = referredElement
.getSubstitutionGroupMembers();
if (possibleSubstitutes.hasMoreElements()) {
String typeXPath = XPathHelper
.getSchemaLocation(referredElement);
JClass referredJClass = _xpathToJClass