KickJava   Java API By Example, From Geeks To Geeks.

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


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.js.JavaMethod;
20 import org.apache.ws.jaxme.js.JavaSource;
21 import org.xml.sax.SAXException JavaDoc;
22
23
24 /** Creates an instance of
25  * {@link org.apache.ws.jaxme.impl.JMSAXElementParser},
26  * which parses an empty element, aka empty group.
27  */

28 public class EmptyElementHandlerSG extends HandlerSGImpl {
29     /** Creates a new instance, which generates a handler
30      * for the given complex type.
31      */

32     public EmptyElementHandlerSG(ComplexTypeSG pType, JavaSource pJs) {
33         super(pType, pJs);
34     }
35
36     public JavaMethod newStartElementMethod() throws SAXException JavaDoc {
37         JavaMethod result = super.newStartElementMethod();
38         result.addLine("return false;");
39         return result;
40     }
41
42     public JavaMethod newIsFinishedMethod() throws SAXException JavaDoc {
43         JavaMethod jm = super.newIsFinishedMethod();
44         jm.addLine("return true;");
45         return jm;
46     }
47
48     public JavaMethod newIsEmptyMethod() throws SAXException JavaDoc {
49         JavaMethod jm = super.newIsEmptyMethod();
50         jm.addLine("return ", ctSG.hasSimpleContent() ? "false" : "true", ";");
51         return jm;
52     }
53     
54     public JavaMethod newIsAtomicMethod() throws SAXException JavaDoc {
55         JavaMethod jm = super.newIsAtomicMethod();
56         jm.addLine("return ", ctSG.hasSimpleContent() ? "true" : "false", ";");
57         return jm;
58     }
59 }
60
Popular Tags