KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > pm > ino > api4j > DocumentDefaultHandler


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.pm.ino.api4j;
18
19 import java.lang.reflect.UndeclaredThrowableException JavaDoc;
20
21 import javax.xml.bind.JAXBException;
22
23 import org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl;
24 import org.apache.ws.jaxme.pm.ino.InoObject;
25 import org.xml.sax.Attributes JavaDoc;
26 import org.xml.sax.Locator JavaDoc;
27 import org.xml.sax.SAXException JavaDoc;
28
29 import com.softwareag.tamino.db.api.objectModel.sax.TSAXDocument;
30 import com.softwareag.tamino.db.api.objectModel.sax.TSAXDocumentDefaultHandler;
31
32
33 /**
34  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
35  */

36 public class DocumentDefaultHandler extends TSAXDocumentDefaultHandler {
37     private static final ThreadLocal JavaDoc handler = new ThreadLocal JavaDoc();
38
39     static JMUnmarshallerHandlerImpl getUnmarshallerHandler() {
40         return (JMUnmarshallerHandlerImpl) handler.get();
41     }
42
43     static void setUnmarshallerHandler(JMUnmarshallerHandlerImpl pHandler) {
44         handler.set(pHandler);
45     }
46     
47     public DocumentDefaultHandler() {
48     }
49
50     public void startDocument() throws SAXException JavaDoc {
51         getUnmarshallerHandler().startDocument();
52     }
53
54     public void endDocument() throws SAXException JavaDoc {
55         getUnmarshallerHandler().endDocument();
56     }
57
58     public void startElement(String JavaDoc pNamespaceURI, String JavaDoc pLocalName, String JavaDoc pQName,
59                              Attributes JavaDoc pAttr) throws SAXException JavaDoc {
60         getUnmarshallerHandler().startElement(pNamespaceURI, pLocalName, pQName, pAttr);
61     }
62
63     public void endElement(String JavaDoc pNamespaceURI, String JavaDoc pLocalName, String JavaDoc pQName)
64             throws SAXException JavaDoc {
65         getUnmarshallerHandler().endElement(pNamespaceURI, pLocalName, pQName);
66     }
67
68     public void characters(char[] pBuffer, int pOffset, int pLen) throws SAXException JavaDoc {
69         getUnmarshallerHandler().characters(pBuffer, pOffset, pLen);
70     }
71
72     public void ignorableWhitespace(char[] pBuffer, int pOffset, int pLen) throws SAXException JavaDoc {
73         getUnmarshallerHandler().ignorableWhitespace(pBuffer, pOffset, pLen);
74     }
75
76     public void processingInstruction(String JavaDoc pTarget, String JavaDoc pData) throws SAXException JavaDoc {
77         getUnmarshallerHandler().processingInstruction(pTarget, pData);
78     }
79
80     public void skippedEntity(String JavaDoc pEntity) throws SAXException JavaDoc {
81         getUnmarshallerHandler().skippedEntity(pEntity);
82     }
83
84     public void endPrefixMapping(String JavaDoc pPrefix) throws SAXException JavaDoc {
85         getUnmarshallerHandler().endPrefixMapping(pPrefix);
86     }
87
88     public void startPrefixMapping(String JavaDoc pPrefix, String JavaDoc pNamespaceURI) throws SAXException JavaDoc {
89         getUnmarshallerHandler().startPrefixMapping(pPrefix, pNamespaceURI);
90     }
91
92     public void setDocumentLocator(Locator JavaDoc pLocator) {
93         getUnmarshallerHandler().setDocumentLocator(pLocator);
94     }
95
96     public TSAXDocument getDocument() {
97         try {
98             return new TJMElement((InoObject) getUnmarshallerHandler().getResult());
99         } catch (JAXBException e) {
100             throw new UndeclaredThrowableException JavaDoc(e);
101         }
102     }
103 }
104
Popular Tags