View Javadoc

1   package at.ac.tuwien.infosys.sm4all.copal.api.event.xml;
2   
3   import java.text.MessageFormat;
4   import org.w3c.dom.Document;
5   import org.w3c.dom.Node;
6   
7   /**
8    * Exception for when parsing a {@link Document} representing a
9    * {@link XMLContextEvent} is missing a required field. Field can be any
10   * {@link Node} in the {@link Document}.
11   * 
12   * @author sanjin
13   */
14  public class MissingFieldException extends ParsingException {
15  
16      private static final long serialVersionUID = -4251626533810898685L;
17      private static final MessageFormat DETAIL_MESSAGE = new MessageFormat(
18              "{0} is missing.");
19  
20      /**
21       * Creates exception with specified name of missing field.
22       * 
23       * @param name the name of missing field.
24       */
25      public MissingFieldException(final String name) {
26          super(DETAIL_MESSAGE.format(new Object[]{ name }, new StringBuffer(),
27                  null).toString());
28      }
29  
30      /**
31       * Creates exception with specified name of missing field and cause
32       * exception.
33       * 
34       * @param name the name of missing field.
35       * @param cause the cause exception of the parsing problem.
36       */
37      public MissingFieldException(final String name, final Throwable cause) {
38          super(DETAIL_MESSAGE.format(new Object[]{ name }, new StringBuffer(),
39                  null).toString(), cause);
40      }
41  }