/* * Created on 28.04.2003 * */ package net.sourceforge.phpeclipse.phpeditor.php; import java.util.ArrayList; import org.eclipse.jface.text.IDocument; /** * A stack for keeping track of the contenttypes for partitions that * contain other partitions. * * @author Stefan Langer * @version $Revision: 1.2 $ */ 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) { } }