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