View Javadoc

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