2 * Created on 28.04.2003
5 package net.sourceforge.phpeclipse.phpeditor.php;
7 import java.util.ArrayList;
9 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
11 import org.eclipse.jface.text.IDocument;
14 * A stack for keeping track of the contenttypes for partitions that
15 * contain other partitions.
17 * @author Stefan Langer
18 * @version $Revision: 1.4 $
20 public class PartitionStack
22 private ArrayList fPartitionStack = new ArrayList(5);
23 private int fStackTop = -1;
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.
30 public void pushStack(String contentType)
32 if(fStackTop < fPartitionStack.size())
34 fPartitionStack.add(++fStackTop, contentType);
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.
43 public String popStack()
47 return (String)fPartitionStack.get(fStackTop--);
50 return IPHPPartitions.HTML;
53 public boolean isEmpty()
55 return (fStackTop < 0);
59 * Initializes this stack from the specified document for the
61 * @param offset The offset to initialize from
62 * @param fDocument The document to initialize from
64 public void initializeStack(int offset, IDocument fDocument)