1   /***
2   * Copyright 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  package org.apache.ws.jaxme.examples.misc.address.impl;
17  
18  public class AddressTypeHandler extends org.apache.ws.jaxme.impl.JMHandlerImpl {
19    public static class NameTypeHandler extends org.apache.ws.jaxme.impl.JMHandlerImpl {
20      /*** The current level of nested elements. 0, if outside the root element.
21       * 
22       */
23      private int __level;
24    
25      /*** The current state. The following values are valid states:
26       *  0 = Before parsing the element
27       *  1 = Parsing an unknown element
28       *  2 = After parsing the element
29       *  3 = While parsing the child element {http://ws.apache.org/jaxme/examples/misc/address}First
30       *  4 = While parsing the child element {http://ws.apache.org/jaxme/examples/misc/address}Middle
31       *  5 = While parsing the child element {http://ws.apache.org/jaxme/examples/misc/address}Last
32       *  6 = While parsing the child element {http://ws.apache.org/jaxme/examples/misc/address}Initials
33       * 
34       */
35      private int __state;
36    
37      /*** The current handler for parsing child elements or simple content.
38       * 
39       */
40      private org.apache.ws.jaxme.JMHandler __handler;
41    
42    
43      public void startDocument() throws org.xml.sax.SAXException {
44        __level = 0;
45        __state = 0;
46        __state = 0;
47        __handler = null;
48      }
49    
50      protected org.apache.ws.jaxme.examples.misc.address.AddressType.NameType newResult() throws org.xml.sax.SAXException {
51        return new org.apache.ws.jaxme.examples.misc.address.impl.AddressTypeImpl.NameTypeImpl();
52      }
53    
54      public void startElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName, org.xml.sax.Attributes pAttr) throws org.xml.sax.SAXException {
55        switch (__level++) {
56          case 0:
57            setResult(newResult());
58            if (pAttr != null) {
59              for (int _1 = 0;  _1 < pAttr.getLength();  _1++) {
60                super.addAttribute(pAttr.getURI(_1), pAttr.getLocalName(_1), pAttr.getValue(_1));
61              }
62            }
63            break;
64          case 1:
65            if ("http://ws.apache.org/jaxme/examples/misc/address".equals(pNamespaceURI)) {
66              if ("First".equals(pLocalName)) {
67                switch (__state) {
68                  case 0:
69                    __state = 3;
70                    __handler = getData().getAtomicHandler();
71                    __handler.startDocument();
72                    __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
73                    break;
74                  default:
75                    validationEvent(javax.xml.bind.ValidationEvent.WARNING, "The element " + pQName + " was unexpected at this place.", org.apache.ws.jaxme.ValidationEvents.EVENT_UNEXPECTED_CHILD_STATE);
76                    break;
77                }
78              } else if ("Middle".equals(pLocalName)) {
79                switch (__state) {
80                  case 3:
81                  case 4:
82                    __state = 4;
83                    __handler = getData().getAtomicHandler();
84                    __handler.startDocument();
85                    __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
86                    break;
87                  default:
88                    validationEvent(javax.xml.bind.ValidationEvent.WARNING, "The element " + pQName + " was unexpected at this place.", org.apache.ws.jaxme.ValidationEvents.EVENT_UNEXPECTED_CHILD_STATE);
89                    break;
90                }
91              } else if ("Last".equals(pLocalName)) {
92                switch (__state) {
93                  case 3:
94                  case 4:
95                    __state = 5;
96                    __handler = getData().getAtomicHandler();
97                    __handler.startDocument();
98                    __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
99                    break;
100                 default:
101                   validationEvent(javax.xml.bind.ValidationEvent.WARNING, "The element " + pQName + " was unexpected at this place.", org.apache.ws.jaxme.ValidationEvents.EVENT_UNEXPECTED_CHILD_STATE);
102                   break;
103               }
104             } else if ("Initials".equals(pLocalName)) {
105               switch (__state) {
106                 case 5:
107                   __state = 6;
108                   __handler = getData().getAtomicHandler();
109                   __handler.startDocument();
110                   __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
111                   break;
112                 default:
113                   validationEvent(javax.xml.bind.ValidationEvent.WARNING, "The element " + pQName + " was unexpected at this place.", org.apache.ws.jaxme.ValidationEvents.EVENT_UNEXPECTED_CHILD_STATE);
114                   break;
115               }
116             }
117           }
118           break;
119         default:
120           if (__handler == null) {
121             super.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
122           } else {
123             __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
124           }
125       }
126     }
127   
128     public void endElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName) throws org.xml.sax.SAXException {
129       if (__handler == null) {
130         if (__level > 1) {
131           super.endElement(pNamespaceURI, pLocalName, pQName);
132         }
133       } else {
134         __handler.endElement(pNamespaceURI, pLocalName, pQName);
135       }
136       switch (--__level) {
137         case 0:
138           break;
139         case 1:
140           org.apache.ws.jaxme.examples.misc.address.AddressType.NameType _1 = (org.apache.ws.jaxme.examples.misc.address.AddressType.NameType) getResult();
141           switch (__state) {
142             case 3:
143               if (__handler != null) {
144                 __handler.endDocument();
145               }
146               _1.setFirst(((java.lang.String) __handler.getResult()));
147               break;
148             case 4:
149               if (__handler != null) {
150                 __handler.endDocument();
151               }
152               _1.getMiddle().add(__handler.getResult());
153               break;
154             case 5:
155               if (__handler != null) {
156                 __handler.endDocument();
157               }
158               _1.setLast(((java.lang.String) __handler.getResult()));
159               break;
160             case 6:
161               if (__handler != null) {
162                 __handler.endDocument();
163               }
164               _1.setInitials(((java.lang.String) __handler.getResult()));
165               break;
166             default:
167               throw new java.lang.IllegalStateException("Illegal state: " + __state);
168           }
169       }
170     }
171   
172     public void characters(char[] pChars, int pOffset, int pLen) throws org.xml.sax.SAXException {
173       if (__handler == null) {
174         super.characters(pChars, pOffset, pLen);
175       } else {
176         __handler.characters(pChars, pOffset, pLen);
177       }
178     }
179   
180   }
181 
182   /*** The current level of nested elements. 0, if outside the root element.
183    * 
184    */
185   private int __level;
186 
187   /*** The current state. The following values are valid states:
188    *  0 = Before parsing the element
189    *  1 = Parsing an unknown element
190    *  2 = After parsing the element
191    *  3 = While parsing the child element {http://ws.apache.org/jaxme/examples/misc/address}Name
192    * 
193    */
194   private int __state;
195 
196   /*** The current handler for parsing child elements or simple content.
197    * 
198    */
199   private org.apache.ws.jaxme.JMHandler __handler;
200 
201   private org.apache.ws.jaxme.JMHandler __handler_Name;
202 
203 
204   public void startDocument() throws org.xml.sax.SAXException {
205     __level = 0;
206     __state = 0;
207     __state = 0;
208     __handler = null;
209   }
210 
211   public void addAttribute(java.lang.String pURI, java.lang.String pLocalName, java.lang.String pValue) throws org.xml.sax.SAXException {
212     if (pURI == null) {
213       pURI = "";
214     }
215     org.apache.ws.jaxme.examples.misc.address.AddressType _1 = (org.apache.ws.jaxme.examples.misc.address.AddressType) getResult();
216     if ("".equals(pURI)) {
217       if ("id".equals(pLocalName)) {
218         _1.setId(pValue);
219         return;
220       }
221     }
222     super.addAttribute(pURI, pLocalName, pValue);
223   }
224 
225   protected org.apache.ws.jaxme.examples.misc.address.AddressType newResult() throws org.xml.sax.SAXException {
226     try {
227       return (org.apache.ws.jaxme.examples.misc.address.AddressType) getData().getFactory().getElement(org.apache.ws.jaxme.examples.misc.address.AddressType.class);
228     } catch (javax.xml.bind.JAXBException _1) {
229       throw new org.xml.sax.SAXException(_1);
230     }
231   }
232 
233   public void startElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName, org.xml.sax.Attributes pAttr) throws org.xml.sax.SAXException {
234     switch (__level++) {
235       case 0:
236         setResult(newResult());
237         if (pAttr != null) {
238           for (int _1 = 0;  _1 < pAttr.getLength();  _1++) {
239             addAttribute(pAttr.getURI(_1), pAttr.getLocalName(_1), pAttr.getValue(_1));
240           }
241         }
242         break;
243       case 1:
244         if ("http://ws.apache.org/jaxme/examples/misc/address".equals(pNamespaceURI)) {
245           if ("Name".equals(pLocalName)) {
246             switch (__state) {
247               case 0:
248                 __state = 3;
249                 __handler = getHandlerForName();
250                 __handler.startDocument();
251                 __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
252                 break;
253               default:
254                 validationEvent(javax.xml.bind.ValidationEvent.WARNING, "The element " + pQName + " was unexpected at this place.", org.apache.ws.jaxme.ValidationEvents.EVENT_UNEXPECTED_CHILD_STATE);
255                 break;
256             }
257           }
258         }
259         break;
260       default:
261         if (__handler == null) {
262           super.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
263         } else {
264           __handler.startElement(pNamespaceURI, pLocalName, pQName, pAttr);
265         }
266     }
267   }
268 
269   public void endElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName) throws org.xml.sax.SAXException {
270     if (__handler == null) {
271       if (__level > 1) {
272         super.endElement(pNamespaceURI, pLocalName, pQName);
273       }
274     } else {
275       __handler.endElement(pNamespaceURI, pLocalName, pQName);
276     }
277     switch (--__level) {
278       case 0:
279         break;
280       case 1:
281         org.apache.ws.jaxme.examples.misc.address.AddressType _1 = (org.apache.ws.jaxme.examples.misc.address.AddressType) getResult();
282         switch (__state) {
283           case 3:
284             if (__handler != null) {
285               __handler.endDocument();
286             }
287             _1.setName(((org.apache.ws.jaxme.examples.misc.address.AddressType.NameType) __handler.getResult()));
288             break;
289           default:
290             throw new java.lang.IllegalStateException("Illegal state: " + __state);
291         }
292     }
293   }
294 
295   public void characters(char[] pChars, int pOffset, int pLen) throws org.xml.sax.SAXException {
296     if (__handler == null) {
297       super.characters(pChars, pOffset, pLen);
298     } else {
299       __handler.characters(pChars, pOffset, pLen);
300     }
301   }
302 
303   public void init(org.apache.ws.jaxme.JMHandler.Data pData) throws javax.xml.bind.JAXBException {
304     super.init(pData);
305     if (__handler_Name != null) {
306       __handler_Name.init(pData);
307     }
308   }
309 
310   protected org.apache.ws.jaxme.JMHandler getHandlerForName() throws org.xml.sax.SAXException {
311     if (__handler_Name == null) {
312       try {
313         __handler_Name = new org.apache.ws.jaxme.examples.misc.address.impl.AddressTypeHandler.NameTypeHandler();
314         __handler_Name.init(getData());
315       } catch (javax.xml.bind.JAXBException _1) {
316         throw new org.xml.sax.SAXException(_1);
317       }
318     }
319     return __handler_Name;
320   }
321 
322 }