View Javadoc

1   /*
2    * $Id: OASTException.java,v 1.4 2005/06/01 17:38:38 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8    
9   package com.bbn.swede.core.dom;
10  
11  /***
12   * Custom exception type for OAST errors.
13   * @author jlerner
14   */
15  public class OASTException extends Exception
16  {
17     private IOWLAbstractSyntaxTree _tree;
18     private OASTNode _node;
19     /***
20      * Constructs an exception that represents a problem that occurred during
21      * an OAST API call.  This version of the constructor should be used for
22      * general tree errors that do not involve a specific node, such as a 
23      * read-only error or a locked for modifications error.  The node
24      * returned by <code>getNode()</code> in the resulting exception object
25      * will be <code>null</code>.
26      * @param sMessage The detail message for the exception
27      * @param tree The tree that caused the error.
28      */
29     public OASTException(String sMessage, IOWLAbstractSyntaxTree tree)
30     {
31        super(sMessage);
32        _tree = tree;
33     }
34     
35     /***
36      * <p>Constructs an exception that represents a problem that occurred during
37      * an OAST API call.  This version of the constructor should be used for
38      * errors relating to a high-level API call on a specific node, such as
39      * attempting to insert a node in a parent that does not contain its starting
40      * offset.</p>
41      * 
42      * <p>The return value of <code>node.getOWLAbstractSyntaxTree()</code> is
43      * assumed to be the tree that caused the exception.  If <code>node</code>
44      * is not attached to an OAST, <code>getOAST()</code> will return
45      * <code>null</code> for this exception.</p>
46      * @param sMessage The detail message for the exception
47      * @param node The node that caused the error.
48      */
49     public OASTException(String sMessage, OASTNode node)
50     {
51        super(sMessage);
52        _node = node;
53        _tree = node.getOWLAbstractSyntaxTree();
54     }
55     
56     /***
57      * Retrieves the tree that caused the exception.  This may be 
58      * <code>null</code> if the error occurred in a high-level API call on a node
59      * that is not attached to an OAST.
60      * @return The tree
61      */
62     public IOWLAbstractSyntaxTree getOAST()
63     {
64        return _tree;
65     }
66     
67     /***
68      * Retrieves the node that caused the exception.  This may be 
69      * <code>null</code> if the error was a general OAST error such as a
70      * read-only exception or a locked for modifications exception.
71      * @return The node
72      */
73     public OASTNode getNode()
74     {
75        return _node;
76     }
77  }