Partitionscanner Framework
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / php / PartitionStack.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PartitionStack.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PartitionStack.java
new file mode 100644 (file)
index 0000000..380b4cf
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Created on 28.04.2003
+ *
+ */
+package net.sourceforge.phpeclipse.phpeditor.php;
+
+import java.util.*;
+
+import org.eclipse.jface.text.*;
+
+/**
+ * A stack for keeping track of the contenttypes for partitions that 
+ * contain other partitions.
+ * 
+ * @author Stefan Langer
+ * @version $Revision: 1.1 $
+ */
+public class PartitionStack
+{
+    private ArrayList fPartitionStack = new ArrayList(5);
+    private int fStackTop = -1;
+    
+    /**
+     * Pushes the specified contenttype onto the partitionstack. 
+     * This will keep track of the last partitions read.
+     * @param contentType The contenttype to push onto the stack.
+     */
+    public void pushStack(String contentType)
+    {
+       if(fStackTop < fPartitionStack.size())
+       {
+               fPartitionStack.add(++fStackTop, contentType);
+       }
+    }
+    /**
+     * Returns the contentype of the last partition on the partition stack.
+     * If no partition is currently on the stack this function simply returns
+     * the HTML contenttype as default.
+     * @return The contenttype of the last partition on stack.
+     */
+    public String popStack()
+    {
+       if(fStackTop >= 0)
+       {
+               return (String)fPartitionStack.get(fStackTop--);
+       }
+       
+       return IPHPPartitionScannerConstants.HTML;
+    }
+    
+    public boolean isEmpty()
+    {
+       return (fStackTop < 0);
+    }
+    
+    /**
+     * Initializes this stack from the specified document for the
+     * specified offset.
+     * @param offset           The offset to initialize from
+     * @param fDocument        The document to initialize from
+     */
+    public void initializeStack(int offset, IDocument fDocument)
+    {
+       
+    }
+
+}