Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / php / PartitionStack.java
1 /*
2  * Created on 28.04.2003
3  *
4  */
5 package net.sourceforge.phpeclipse.phpeditor.php;
6
7 import java.util.ArrayList;
8
9 import org.eclipse.jface.text.IDocument;
10
11 /**
12  * A stack for keeping track of the contenttypes for partitions that 
13  * contain other partitions.
14  * 
15  * @author Stefan Langer
16  * @version $Revision: 1.2 $
17  */
18 public class PartitionStack
19 {
20     private ArrayList fPartitionStack = new ArrayList(5);
21     private int fStackTop = -1;
22     
23     /**
24      * Pushes the specified contenttype onto the partitionstack. 
25      * This will keep track of the last partitions read.
26      * @param contentType The contenttype to push onto the stack.
27      */
28     public void pushStack(String contentType)
29     {
30         if(fStackTop < fPartitionStack.size())
31         {
32                 fPartitionStack.add(++fStackTop, contentType);
33         }
34     }
35     /**
36      * Returns the contentype of the last partition on the partition stack.
37      * If no partition is currently on the stack this function simply returns
38      * the HTML contenttype as default.
39      * @return The contenttype of the last partition on stack.
40      */
41     public String popStack()
42     {
43         if(fStackTop >= 0)
44         {
45                 return (String)fPartitionStack.get(fStackTop--);
46         }
47         
48         return IPHPPartitionScannerConstants.HTML;
49     }
50     
51     public boolean isEmpty()
52     {
53         return (fStackTop < 0);
54     }
55     
56     /**
57      * Initializes this stack from the specified document for the
58      * specified offset.
59      * @param offset            The offset to initialize from
60      * @param fDocument The document to initialize from
61      */
62     public void initializeStack(int offset, IDocument fDocument)
63     {
64         
65     }
66
67 }