1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.ws.processor.model;
  27 
  28 import com.sun.codemodel.internal.JClass;
  29 import com.sun.tools.internal.ws.processor.model.java.JavaException;
  30 import com.sun.tools.internal.ws.wsdl.framework.Entity;
  31 
  32 import javax.xml.namespace.QName;
  33 import java.util.HashSet;
  34 import java.util.Iterator;
  35 import java.util.Set;
  36 
  37 /**
  38  *
  39  * @author WS Development Team
  40  */
  41 public class Fault extends ModelObject {
  42 
  43     public Fault(Entity entity) {
  44         super(entity);
  45     }
  46 
  47     public Fault(String name, Entity entity) {
  48         super(entity);
  49         this.name = name;
  50     }
  51 
  52     public String getName() {
  53         return name;
  54     }
  55 
  56     public void setName(String s) {
  57         name = s;
  58     }
  59 
  60     public Block getBlock() {
  61         return block;
  62     }
  63 
  64     public void setBlock(Block b) {
  65         block = b;
  66     }
  67 
  68     public JavaException getJavaException() {
  69         return javaException;
  70     }
  71 
  72     public void setJavaException(JavaException e) {
  73         javaException = e;
  74     }
  75 
  76     public void accept(ModelVisitor visitor) throws Exception {
  77         visitor.visit(this);
  78     }
  79 
  80     public Iterator getSubfaults() {
  81         if (subfaults.isEmpty()) {
  82             return null;
  83         }
  84         return subfaults.iterator();
  85     }
  86 
  87     /* serialization */
  88     public Set getSubfaultsSet() {
  89         return subfaults;
  90     }
  91 
  92     /* serialization */
  93     public void setSubfaultsSet(Set s) {
  94         subfaults = s;
  95     }
  96 
  97     public Iterator getAllFaults() {
  98         Set allFaults = getAllFaultsSet();
  99         if (allFaults.isEmpty()) {
 100             return null;
 101         }
 102         return allFaults.iterator();
 103     }
 104 
 105     public Set getAllFaultsSet() {
 106         Set transSet = new HashSet();
 107         Iterator iter = subfaults.iterator();
 108         while (iter.hasNext()) {
 109             transSet.addAll(((Fault)iter.next()).getAllFaultsSet());
 110         }
 111         transSet.addAll(subfaults);
 112         return transSet;
 113     }
 114 
 115     public QName getElementName() {
 116         return elementName;
 117     }
 118 
 119     public void setElementName(QName elementName) {
 120         this.elementName = elementName;
 121     }
 122 
 123     public String getJavaMemberName() {
 124         return javaMemberName;
 125     }
 126 
 127     public void setJavaMemberName(String javaMemberName) {
 128         this.javaMemberName = javaMemberName;
 129     }
 130 
 131     /**
 132      * @return Returns the wsdlFault.
 133      */
 134     public boolean isWsdlException() {
 135             return wsdlException;
 136     }
 137     /**
 138      * @param wsdlFault The wsdlFault to set.
 139      */
 140     public void setWsdlException(boolean wsdlFault) {
 141             this.wsdlException = wsdlFault;
 142     }
 143 
 144     public void setExceptionClass(JClass ex){
 145         exceptionClass = ex;
 146     }
 147 
 148     public JClass getExceptionClass(){
 149         return exceptionClass;
 150     }
 151 
 152     private boolean wsdlException = true;
 153     private String name;
 154     private Block block;
 155     private JavaException javaException;
 156     private Set subfaults = new HashSet();
 157     private QName elementName = null;
 158     private String javaMemberName = null;
 159     private JClass exceptionClass;
 160 
 161     public String getWsdlFaultName() {
 162         return wsdlFaultName;
 163     }
 164 
 165     public void setWsdlFaultName(String wsdlFaultName) {
 166         this.wsdlFaultName = wsdlFaultName;
 167     }
 168 
 169     private String wsdlFaultName;
 170 }