View Javadoc

1   /*
2    * $Id: DeltaCollector.java,v 1.2 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    
9   package com.bbn.swede.core.dom;
10  
11  import java.util.ArrayList;
12  import java.util.List;
13  
14  
15  /***
16   * A visitor that collects deltas that match a type mask.
17   * @author jlerner
18   */
19  /*package*/ class DeltaCollector implements IOASTDeltaVisitor/package-summary/html">class="comment">package*/ class DeltaCollector implements IOASTDeltaVisitor/package-summary.html">class="comment">/*package*/ class DeltaCollector implements IOASTDeltaVisitor/package-summary.html">class="comment">package*/ class DeltaCollector implements IOASTDeltaVisitor
20  {
21     private ArrayList _alDeltas = new ArrayList();
22     private int _mask;
23     /***
24      * Constructs a visitor to find deltas matching a type mask.
25      * @param iTypeMask The type mask.
26      */
27     public DeltaCollector(int iTypeMask)
28     {
29        _mask = iTypeMask;
30     }
31     /* (non-Javadoc)
32      * @see com.bbn.swede.core.dom.IOASTDeltaVisitor#visit(com.bbn.swede.core.dom.IOASTDelta)
33      */
34     public boolean visit(IOASTDelta delta)
35     {
36        if ((delta.getType() & _mask) > 0)
37        {
38           _alDeltas.add(delta);
39        }
40        return true;
41     }
42     
43     /***
44      * Retrieves the list of matching deltas.
45      * @return The matching deltas.
46      */
47     public List getDeltas()
48     {
49        return _alDeltas;
50     }
51  }