KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > generator > sg > impl > LocalContext


1 /*
2  * Copyright 2003, 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  */

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 JavaDoc;
27
28
29 /**
30  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
31  */

32 public class LocalContext extends AbstractContext {
33   /** <p>Creates a new instance of LocalClassContext.java.</p>
34    */

35   public LocalContext(Context pContext, String JavaDoc pName, XSObject pJAXBClassOwner,
36                        String JavaDoc pPrefix, String JavaDoc pSuffix, SchemaSG pSchemaSG) throws SAXException JavaDoc {
37     if (pJAXBClassOwner == null) {
38       throw new NullPointerException JavaDoc("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 JavaDoc 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 JavaDoc 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