1 17 package org.apache.ws.jaxme.generator.sg.impl; 18 19 import org.apache.ws.jaxme.generator.sg.Context; 20 import org.apache.ws.jaxme.generator.sg.SchemaSG; 21 import org.apache.ws.jaxme.js.JavaQName; 22 import org.apache.ws.jaxme.js.JavaQNameImpl; 23 import org.apache.ws.jaxme.xs.XSObject; 24 import org.apache.ws.jaxme.xs.jaxb.JAXBClass; 25 import org.apache.ws.jaxme.xs.jaxb.JAXBClassOwner; 26 import org.xml.sax.SAXException ; 27 28 29 32 public class LocalContext extends AbstractContext { 33 35 public LocalContext(Context pContext, String pName, XSObject pJAXBClassOwner, 36 String pPrefix, String pSuffix, SchemaSG pSchemaSG) throws SAXException { 37 if (pJAXBClassOwner == null) { 38 throw new NullPointerException ("The XSObject argument must not be null."); 39 } 40 41 JAXBClassOwner jaxbClassOwner = null; 42 if (pJAXBClassOwner instanceof JAXBClassOwner) { 43 jaxbClassOwner = (JAXBClassOwner) pJAXBClassOwner; 44 } 45 46 String className = null, implementationName = null; 47 JAXBClass jaxbClass = (jaxbClassOwner == null) ? null : jaxbClassOwner.getJAXBClass(); 48 if (jaxbClass != null) { 49 className = jaxbClass.getName(); 50 implementationName = jaxbClass.getImplClass(); 51 } 52 53 if (className == null) { 54 String prefix = null, suffix = null; 55 className = getClassNameFromLocalName(pJAXBClassOwner.getLocator(), pName, pSchemaSG); 56 if (prefix == null) { prefix = pPrefix; } 57 if (prefix != null) className = prefix + className; 58 if (suffix == null) { suffix = pSuffix; } 59 if (suffix != null) className += suffix; 60 } 61 JavaQName xmlInterfaceName = JavaQNameImpl.getInnerInstance(pContext.getXMLInterfaceName(), className); 62 setXMLInterfaceName(xmlInterfaceName); 63 64 if (implementationName == null) { 65 setXMLImplementationName(JavaQNameImpl.getInnerInstance(pContext.getXMLImplementationName(), 66 className + "Impl")); 67 } else { 68 setXMLImplementationName(JavaQNameImpl.getInstance(implementationName, true)); 69 } 70 setXMLHandlerName(JavaQNameImpl.getInnerInstance(pContext.getXMLHandlerName(), className + "Handler")); 71 setXMLSerializerName(JavaQNameImpl.getInnerInstance(pContext.getXMLSerializerName(), className + "Driver")); 72 setXMLValidatorName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 73 xmlInterfaceName.getClassName() + "Validator")); 74 setPMName(JavaQNameImpl.getInstance(xmlInterfaceName.getPackageName() + ".impl", 75 xmlInterfaceName.getClassName() + "PM")); 76 } 77 78 public boolean isGlobal() { return false; } 79 } 80 | Popular Tags |