1 /*
   2  * Copyright (c) 1997, 2010, 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.generator.GeneratorUtil;
  30 import com.sun.tools.internal.ws.processor.model.java.JavaException;
  31 import com.sun.tools.internal.ws.wsdl.framework.Entity;
  32 
  33 import javax.xml.namespace.QName;
  34 import java.util.HashSet;
  35 import java.util.Iterator;
  36 import java.util.Set;
  37 import java.util.TreeSet;
  38 
  39 /**
  40  *
  41  * @author WS Development Team
  42  */
  43 public class Fault extends ModelObject {
  44 
  45     public Fault(Entity entity) {
  46         super(entity);
  47     }
  48 
  49     public Fault(String name, Entity entity) {
  50         super(entity);
  51         this.name = name;
  52         parentFault = null;
  53     }
  54 
  55     public String getName() {
  56         return name;
  57     }
  58 
  59     public void setName(String s) {
  60         name = s;
  61     }
  62 
  63     public Block getBlock() {
  64         return block;
  65     }
  66 
  67     public void setBlock(Block b) {
  68         block = b;
  69     }
  70 
  71     public JavaException getJavaException() {
  72         return javaException;
  73     }
  74 
  75     public void setJavaException(JavaException e) {
  76         javaException = e;
  77     }
  78 
  79     public void accept(ModelVisitor visitor) throws Exception {
  80         visitor.visit(this);
  81     }
  82 
  83     public Fault getParentFault() {
  84         return parentFault;
  85     }
  86 
  87     public Iterator getSubfaults() {
  88         if (subfaults.size() == 0) {
  89             return null;
  90         }
  91         return subfaults.iterator();
  92     }
  93 
  94     /* serialization */
  95     public Set getSubfaultsSet() {
  96         return subfaults;
  97     }
  98 
  99     /* serialization */
 100     public void setSubfaultsSet(Set s) {
 101         subfaults = s;
 102     }
 103 
 104     public Iterator getAllFaults() {
 105         Set allFaults = getAllFaultsSet();
 106         if (allFaults.size() == 0) {
 107             return null;
 108         }
 109         return allFaults.iterator();
 110     }
 111 
 112     public Set getAllFaultsSet() {
 113         Set transSet = new HashSet();
 114         Iterator iter = subfaults.iterator();
 115         while (iter.hasNext()) {
 116             transSet.addAll(((Fault)iter.next()).getAllFaultsSet());
 117         }
 118         transSet.addAll(subfaults);
 119         return transSet;
 120     }
 121 
 122     public QName getElementName() {
 123         return elementName;
 124     }
 125 
 126     public void setElementName(QName elementName) {
 127         this.elementName = elementName;
 128     }
 129 
 130     public String getJavaMemberName() {
 131         return javaMemberName;
 132     }
 133 
 134     public void setJavaMemberName(String javaMemberName) {
 135         this.javaMemberName = javaMemberName;
 136     }
 137 
 138     /**
 139      * @return Returns the wsdlFault.
 140      */
 141     public boolean isWsdlException() {
 142             return wsdlException;
 143     }
 144     /**
 145      * @param wsdlFault The wsdlFault to set.
 146      */
 147     public void setWsdlException(boolean wsdlFault) {
 148             this.wsdlException = wsdlFault;
 149     }
 150 
 151     public void setExceptionClass(JClass ex){
 152         exceptionClass = ex;
 153     }
 154 
 155     public JClass getExceptionClass(){
 156         return exceptionClass;
 157     }
 158 
 159     private boolean wsdlException = true;
 160     private String name;
 161     private Block block;
 162     private JavaException javaException;
 163     private Fault parentFault;
 164     private Set subfaults = new HashSet();
 165     private QName elementName = null;
 166     private String javaMemberName = null;
 167     private JClass exceptionClass;
 168 
 169     public String getWsdlFaultName() {
 170         return wsdlFaultName;
 171     }
 172 
 173     public void setWsdlFaultName(String wsdlFaultName) {
 174         this.wsdlFaultName = wsdlFaultName;
 175     }
 176 
 177     private String wsdlFaultName;
 178 }