1 17 package org.apache.ws.jaxme.generator.sg.impl; 18 19 import org.apache.ws.jaxme.generator.sg.SchemaSG; 20 import org.apache.ws.jaxme.js.JavaQName; 21 import org.apache.ws.jaxme.js.JavaQNameImpl; 22 import org.apache.ws.jaxme.xs.XSObject; 23 import org.apache.ws.jaxme.xs.XSType; 24 import org.apache.ws.jaxme.xs.jaxb.JAXBClass; 25 import org.apache.ws.jaxme.xs.jaxb.JAXBClassOwner; 26 import org.apache.ws.jaxme.xs.jaxb.JAXBSchemaBindings; 27 import org.apache.ws.jaxme.xs.xml.XsQName; 28 import org.xml.sax.Locator ; 29 import org.xml.sax.SAXException ; 30 31 34 public class GlobalContext extends AbstractContext { 35 37 public GlobalContext(XsQName pQName, XSObject pJAXBClassOwner, 38 String pPrefix, String pSuffix, SchemaSG pSchemaSG) 39 throws SAXException { 40 Locator locator; 41 if (pJAXBClassOwner instanceof XSType) { 42 XSType type = (XSType) pJAXBClassOwner; 43 if (type.isBuiltin()) { 44 locator = null; 45 } else { 46 locator = type.getLocator(); 47 } 48 } else { 49 locator = pJAXBClassOwner.getLocator(); 50 } 51 52 if (pQName == null) { 53 throw new NullPointerException ("The XsQName argument must not be null."); 54 } 55 setName(pQName); 56 if (pJAXBClassOwner == null) { 57 throw new NullPointerException ("The XSObject argument must not be null."); 58 } 59 60 JAXBClassOwner jaxbClassOwner = null; 61 JAXBSchemaBindings schemaBindings = null; 62 63 if (pJAXBClassOwner instanceof JAXBClassOwner) { 64 jaxbClassOwner = (JAXBClassOwner) pJAXBClassOwner; 65 schemaBindings = jaxbClassOwner.getJAXBSchemaBindings(); 66 } 67 68 String packageName = getPackageName(pSchemaSG, schemaBindings, locator, pQName); 69 String className = null, implementationName = null; 70 JAXBClass jaxbClass = (jaxbClassOwner == null) ? null : jaxbClassOwner.getJAXBClass(); 71 if (jaxbClass != null) { 72 className = jaxbClass.getName(); 73 implementationName = jaxbClass.getImplClass(); 74 } 75 76 if (className == null) { 77 String prefix = null, suffix = null; 78 className = getClassNameFromLocalName(locator, pQName.getLocalName(), pSchemaSG); 79 if (prefix == null) { prefix = pPrefix; } 80 if (prefix != null) className = prefix + className; 81 if (suffix == null) { suffix = pSuffix; } 82 if (suffix != null) className += suffix; 83 } 84 if (className.equals("EmailDetailsType")) { 85 throw new IllegalStateException (); 86 } 87 88 JavaQName xmlInterfaceName = JavaQNameImpl.getInstance(packageName, className); 89 setXMLInterfaceName(xmlInterfaceName); 90 91 if (implementationName == null) { 92 setXMLImplementationName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 93 xmlInterfaceName.getClassName() + "Impl")); 94 } else { 95 setXMLImplementationName(JavaQNameImpl.getInstance(implementationName, true)); 96 } 97 setXMLHandlerName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 98 xmlInterfaceName.getClassName() + "Handler")); 99 setXMLSerializerName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 100 xmlInterfaceName.getClassName() + "Driver")); 101 setXMLValidatorName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 102 xmlInterfaceName.getClassName() + "Validator")); 103 setPMName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 104 xmlInterfaceName.getClassName() + "PM")); 105 } 106 107 public boolean isGlobal() { return true; } 108 } 109 | Popular Tags |