Source code: org/apache/axis/deployment/wsdd/WSDDFault.java
1 /*
2 * Copyright 2002-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 /**
18 * @author Glen Daniels (gdaniels@apache.org)
19 */
20 package org.apache.axis.deployment.wsdd;
21
22 import org.apache.axis.description.FaultDesc;
23 import org.apache.axis.encoding.SerializationContext;
24 import org.apache.axis.utils.XMLUtils;
25 import org.w3c.dom.Element;
26 import org.xml.sax.helpers.AttributesImpl;
27
28 import javax.xml.namespace.QName;
29 import java.io.IOException;
30
31 public class WSDDFault extends WSDDElement {
32 FaultDesc desc;
33
34 public WSDDFault(FaultDesc desc) {
35 this.desc = desc;
36 }
37
38 /**
39 * Construct a WSDDFault from a DOM Element
40 * @param e the <fault> Element
41 * @throws WSDDException
42 */
43 public WSDDFault(Element e) throws WSDDException {
44 super(e);
45
46 desc = new FaultDesc();
47
48 String nameStr = e.getAttribute(ATTR_NAME);
49 if (nameStr != null && !nameStr.equals(""))
50 desc.setName(nameStr);
51
52 String qNameStr = e.getAttribute(ATTR_QNAME);
53 if (qNameStr != null && !qNameStr.equals(""))
54 desc.setQName(XMLUtils.getQNameFromString(qNameStr, e));
55
56 String classNameStr = e.getAttribute(ATTR_CLASS);
57 if (classNameStr != null && !classNameStr.equals(""))
58 desc.setClassName(classNameStr);
59
60 String xmlTypeStr = e.getAttribute(ATTR_TYPE);
61 if (xmlTypeStr != null && !xmlTypeStr.equals(""))
62 desc.setXmlType(XMLUtils.getQNameFromString(xmlTypeStr, e));
63 }
64
65 /**
66 * Return the element name of a particular subclass.
67 */
68 protected QName getElementName() {
69 return QNAME_FAULT;
70 }
71
72 /**
73 * Write this element out to a SerializationContext
74 */
75 public void writeToContext(SerializationContext context)
76 throws IOException {
77 AttributesImpl attrs = new AttributesImpl();
78
79 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME,
80 "CDATA",
81 context.qName2String(desc.getQName()));
82
83 attrs.addAttribute("", ATTR_CLASS, ATTR_CLASS,
84 "CDATA", desc.getClassName());
85
86 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE,
87 "CDATA",
88 context.qName2String(desc.getXmlType()));
89
90 context.startElement(getElementName(), attrs);
91 context.endElement();
92 }
93
94 public FaultDesc getFaultDesc() {
95 return desc;
96 }
97
98 public void setFaultDesc(FaultDesc desc) {
99 this.desc = desc;
100 }
101 }