View Javadoc

1   /*
2    * $Id: NodeDisplacementVisitor.java,v 1.12 2005/05/31 23:28:07 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   package com.bbn.swede.core.dom;
9   
10  /***
11   * A visitor to adjust the position of nodes in the OAST to reflect a character 
12   * displacement.
13   */
14  public class NodeDisplacementVisitor implements IOASTNodeVisitor
15  {
16     /***
17      * The starting offset of the displacement.
18      */
19     protected int _iStartOffset;
20     /***
21      * The length of the displacement.
22      */
23     protected int _iOffsetLength;
24     /***
25      * Creates a NodeDisplacementVisitor.
26      * @param iStartOffset The location of the displacement.
27      * @param iOffsetLength The magnitude of the displacement.  May be negative.
28      */
29     public NodeDisplacementVisitor(int iStartOffset, int iOffsetLength)
30     {
31        _iStartOffset = iStartOffset;
32        _iOffsetLength = iOffsetLength;
33     }
34  
35     /* (non-Javadoc)
36      * @see com.bbn.swede.core.dom.IOASTNodeVisitor#visit(com.bbn.swede.core.dom.OASTNode)
37      */
38     public boolean visit(OASTNode node)
39     {
40        return node.displace(_iStartOffset, _iOffsetLength);
41     }
42  
43  }