View Javadoc

    1   package org.codehaus.xfire.service;
    2
    3   import java.util.Iterator;
    4
    5   /***
    6    * Represents the description of a service operation fault.
    7    * <p/>
    8    * Faults are created using the {@link OperationInfo#addFault(String)} method.
    9    *
    10   * @author <a href="mailto:poutsma@mac.com">Arjen Poutsma</a>
    11   */
    12  public class FaultInfo
    13          extends MessagePartContainer
    14          implements Visitable
    15  {
    16      private String name;
    17
    18      /***
    19       * Initializes a new instance of the <code>FaultInfo</code> class with the given name and operation
    20       *
    21       * @param name the name.
    22       */
    23      FaultInfo(String name, OperationInfo operation)
    24      {
    25          super(operation);
    26          this.name = name;
    27      }
    28
    29      /***
    30       * Returns the name of the fault.
    31       *
    32       * @return the name.
    33       */
    34      public String getName()
    35      {
    36          return name;
    37      }
    38
    39      /***
    40       * Sets the name of the fault.
    41       *
    42       * @param name the name.
    43       */
    44      public void setName(String name)
    45      {
    46          if ((name == null) || (name.length() == 0))
    47          {
    48              throw new IllegalArgumentException("Invalid name [" + name + "]");
    49          }
    50          getOperation().removeFault(getName());
    51          this.name = name;
    52          getOperation().addFault(this);
    53      }
    54
    55      /***
    56       * Acceps the given visitor. Iterates over all message part infos.
    57       *
    58       * @param visitor the visitor.
    59       */
    60      public void accept(Visitor visitor)
    61      {
    62          visitor.startFault(this);
    63          for (Iterator iterator = getMessageParts().iterator(); iterator.hasNext();)
    64          {
    65              MessagePartInfo messagePartInfo = (MessagePartInfo) iterator.next();
    66              messagePartInfo.accept(visitor);
    67          }
    68          visitor.endFault(this);
    69      }
    70  }