KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2005 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 package org.apache.ws.jaxme.generator.sg.impl.ccsg;
17
18 import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
19 import org.apache.ws.jaxme.generator.sg.SimpleContentSG;
20 import org.apache.ws.jaxme.js.JavaMethod;
21 import org.apache.ws.jaxme.js.JavaQName;
22 import org.apache.ws.jaxme.js.JavaSource;
23 import org.apache.ws.jaxme.js.LocalJavaField;
24 import org.apache.ws.jaxme.js.TypedValue;
25 import org.xml.sax.SAXException JavaDoc;
26
27
28 /** Creates an instance of
29  * {@link org.apache.ws.jaxme.impl.JMSAXElementParser},
30  * which parses a complex element with simple content.
31  */

32 public class SimpleContentHandlerSG extends EmptyElementHandlerSG {
33     /** Creates a new instance, which generates a handler
34      * for the given complex type.
35      */

36     public SimpleContentHandlerSG(ComplexTypeSG pType, JavaSource pJs) {
37         super(pType, pJs);
38     }
39
40     public JavaMethod newEndElementMethod() throws SAXException JavaDoc {
41         JavaMethod result = super.newEndElementMethod();
42         JavaQName elementInterface = ctSG.getClassContext().getXMLInterfaceName();
43         LocalJavaField element = result.newJavaField(elementInterface);
44         element.addLine("(", elementInterface, ") result");
45         SimpleContentSG scSG = ctSG.getSimpleContentSG();
46         TypedValue tv = createSimpleTypeConversion(result, scSG.getContentTypeSG(),
47                                                    getParamResult(), scSG.getPropertySG().getPropertyName());
48         scSG.getPropertySG().addValue(result, element, tv, null);
49         return result;
50     }
51 }
52
Popular Tags