KickJava   Java API By Example, From Geeks To Geeks.

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


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.ObjectSG;
20 import org.apache.ws.jaxme.generator.sg.PropertySG;
21 import org.apache.ws.jaxme.js.JavaField;
22 import org.apache.ws.jaxme.js.JavaMethod;
23 import org.apache.ws.jaxme.js.JavaSource;
24 import org.apache.ws.jaxme.js.Parameter;
25 import org.apache.ws.jaxme.xs.XSAny;
26 import org.xml.sax.SAXException JavaDoc;
27
28 /**
29  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
30  */

31 public class AnyElementPropertySG extends JAXBPropertySG {
32     protected AnyElementPropertySG(ObjectSG pObjectSG, XSAny pAny) {
33         super("any", pObjectSG.getSchema(), pAny, null, null);
34     }
35
36     public JavaField getXMLField(PropertySG pController, JavaSource pSource) throws SAXException JavaDoc {
37         String JavaDoc fieldName = pController.getXMLFieldName();
38         JavaField result = pSource.newJavaField(fieldName, Object JavaDoc.class, JavaSource.PRIVATE);
39         return result;
40     }
41
42     public JavaMethod getXMLGetMethod(PropertySG pController, JavaSource pSource) throws SAXException JavaDoc {
43         String JavaDoc fieldName = pController.getXMLFieldName();
44         String JavaDoc methodName = pController.getXMLGetMethodName();
45         JavaMethod result = pSource.newJavaMethod(methodName, Object JavaDoc.class, JavaSource.PUBLIC);
46         result.addLine("return ", fieldName, ";");
47         return result;
48     }
49
50     public JavaMethod getXMLSetMethod(PropertySG pController, JavaSource pSource) throws SAXException JavaDoc {
51         String JavaDoc fieldName = pController.getXMLFieldName();
52         String JavaDoc methodName = pController.getXMLSetMethodName();
53         JavaMethod result = pSource.newJavaMethod(methodName, void.class, JavaSource.PUBLIC);
54         Parameter param = result.addParam(Object JavaDoc.class, "p" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1));
55         result.addLine(fieldName, " = ", param, ";");
56         return result;
57     }
58 }
59
Popular Tags