KickJava   Java API By Example, From Geeks To Geeks.

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


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

34 public class TJMElement implements TSAXDocument, TSAXElement {
35     private final InoObject element;
36
37     public TJMElement(InoObject pElement) {
38         element = pElement;
39     }
40
41     public InoObject getJMElement() {
42         return element;
43     }
44
45     public TSAXElement getRootElement() {
46         return this;
47     }
48
49     public void writeTo(Writer JavaDoc pWriter) {
50         try {
51             TaminoAPI4JPm.getJAXBContext().createMarshaller().marshal(getJMElement(), pWriter);
52         } catch (JAXBException e) {
53             throw new UndeclaredThrowableException JavaDoc(e);
54         }
55     }
56
57     public void setDocname(String JavaDoc pDocname) {
58         element.setInoDocname(pDocname);
59     }
60
61     public void setId(String JavaDoc pId) {
62         element.setInoId(pId);
63     }
64
65     public String JavaDoc getDoctype() {
66         QName JavaDoc qName = element.getQName();
67         String JavaDoc prefix = qName.getPrefix();
68         if (prefix == null || prefix.length() == 0) {
69             return qName.getLocalPart();
70         } else {
71             return prefix + ':' + qName.getLocalPart();
72         }
73     }
74
75     public String JavaDoc getDocname() {
76         String JavaDoc result = element.getInoDocname();
77         return result == null ? "" : result;
78     }
79
80     public String JavaDoc getId() {
81         String JavaDoc result = element.getInoId();
82         return result == null ? "" : result;
83     }
84 }
85
Popular Tags