001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.tools.internal.ws.processor.model;
026:
027: import java.util.HashSet;
028: import java.util.Iterator;
029: import java.util.Set;
030: import java.util.TreeSet;
031:
032: import javax.xml.namespace.QName;
033:
034: import com.sun.tools.internal.ws.processor.generator.GeneratorUtil;
035: import com.sun.tools.internal.ws.processor.model.java.JavaException;
036: import com.sun.codemodel.internal.JClass;
037:
038: /**
039: *
040: * @author WS Development Team
041: */
042: public class Fault extends ModelObject {
043:
044: public Fault() {
045: }
046:
047: public Fault(String name) {
048: this .name = name;
049: parentFault = null;
050: }
051:
052: public String getName() {
053: return name;
054: }
055:
056: public void setName(String s) {
057: name = s;
058: }
059:
060: public Block getBlock() {
061: return block;
062: }
063:
064: public void setBlock(Block b) {
065: block = b;
066: }
067:
068: public JavaException getJavaException() {
069: return javaException;
070: }
071:
072: public void setJavaException(JavaException e) {
073: javaException = e;
074: }
075:
076: public void accept(ModelVisitor visitor) throws Exception {
077: visitor.visit(this );
078: }
079:
080: public Fault getParentFault() {
081: return parentFault;
082: }
083:
084: public void setParentFault(Fault parentFault) {
085: if (this .parentFault != null && parentFault != null
086: && !this .parentFault.equals(parentFault)) {
087:
088: throw new ModelException("model.parent.fault.already.set",
089: new Object[] { getName(),
090: this .parentFault.getName(),
091: parentFault.getName() });
092: }
093: this .parentFault = parentFault;
094: }
095:
096: public void addSubfault(Fault fault) {
097: subfaults.add(fault);
098: fault.setParentFault(this );
099: }
100:
101: public Iterator getSubfaults() {
102: if (subfaults.size() == 0) {
103: return null;
104: }
105: return subfaults.iterator();
106: }
107:
108: public Iterator getSortedSubfaults() {
109: Set sortedFaults = new TreeSet(
110: new GeneratorUtil.FaultComparator());
111: sortedFaults.addAll(subfaults);
112: return sortedFaults.iterator();
113: }
114:
115: /* serialization */
116: public Set getSubfaultsSet() {
117: return subfaults;
118: }
119:
120: /* serialization */
121: public void setSubfaultsSet(Set s) {
122: subfaults = s;
123: }
124:
125: public Iterator getAllFaults() {
126: Set allFaults = getAllFaultsSet();
127: if (allFaults.size() == 0) {
128: return null;
129: }
130: return allFaults.iterator();
131: }
132:
133: public Set getAllFaultsSet() {
134: Set transSet = new HashSet();
135: Iterator iter = subfaults.iterator();
136: while (iter.hasNext()) {
137: transSet.addAll(((Fault) iter.next()).getAllFaultsSet());
138: }
139: transSet.addAll(subfaults);
140: return transSet;
141: }
142:
143: public QName getElementName() {
144: return elementName;
145: }
146:
147: public void setElementName(QName elementName) {
148: this .elementName = elementName;
149: }
150:
151: public String getJavaMemberName() {
152: return javaMemberName;
153: }
154:
155: public void setJavaMemberName(String javaMemberName) {
156: this .javaMemberName = javaMemberName;
157: }
158:
159: /**
160: * @return Returns the wsdlFault.
161: */
162: public boolean isWsdlException() {
163: return wsdlException;
164: }
165:
166: /**
167: * @param wsdlFault The wsdlFault to set.
168: */
169: public void setWsdlException(boolean wsdlFault) {
170: this .wsdlException = wsdlFault;
171: }
172:
173: public void setExceptionClass(JClass ex) {
174: exceptionClass = ex;
175: }
176:
177: public JClass getExceptionClass() {
178: return exceptionClass;
179: }
180:
181: private boolean wsdlException = true;
182: private String name;
183: private Block block;
184: private JavaException javaException;
185: private Fault parentFault;
186: private Set subfaults = new HashSet();
187: private QName elementName = null;
188: private String javaMemberName = null;
189: private JClass exceptionClass;
190: }
|