KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > lists > ExtPosition


1 // Copyright (c) 2003 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.lists;
5
6 /** A SeqPosition for sequences that need more than a Pos int for a position.
7  * For such sequences, a Pos int is an index into a PositionManager,
8  * which manages a table of ExtPositions, which may contain more state
9  * than a regular SeqPosition does.
10  */

11
12 public class ExtPosition extends SeqPosition
13 {
14   /** Index into PositionManager.positions, if >= 0.
15    * This is used if we need a single Pos integer for this position. */

16   int position = -1;
17
18   public int getPos ()
19   {
20     if (position < 0)
21       position = PositionManager.manager.register(this);
22     return position;
23   }
24
25   public void setPos (AbstractSequence seq, int ipos)
26   {
27     throw seq.unsupported("setPos");
28   }
29
30   public final boolean isAfter()
31   {
32     return (ipos & 1) != 0;
33   }
34
35   public void release ()
36   {
37     if (position >= 0)
38       PositionManager.manager.release(position);
39     sequence = null;
40   }
41 }
42
Popular Tags