View Javadoc

1   package cz.cuni.amis.pogamut.sposh.exceptions;
2   
3   import cz.cuni.amis.pogamut.sposh.elements.ParseException;
4   import java.text.MessageFormat;
5   
6   /**
7    * When there is a cycle in the posh tree, this exception should be thrown.
8    * Use in methods adding elements to the tree. Cycle in the tree is
9    * a sequence of elements, that link to each other and last one links to the first one
10   * (e.g. (AP ap1 ap2) (AP ap2 ap1))
11   * @author Honza
12   */
13  public class CycleException extends ParseException {
14      
15      /**
16       * Create a new exception that specifies which name caused the cycle.
17       */
18      public static CycleException createFromName(String name) {
19          String msg = MessageFormat.format("Adding an element with name '{0}' would cause a cycle", name);
20          return new CycleException(msg);
21      }
22      
23      public CycleException(String message) {
24          super(message);
25      }
26  }