michael@0: /* michael@0: * Copyright (c) 2009-2010 Mozilla Foundation michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice shall be included in michael@0: * all copies or substantial portions of the Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: */ michael@0: michael@0: package nu.validator.htmlparser.impl; michael@0: michael@0: import nu.validator.htmlparser.annotation.Auto; michael@0: michael@0: michael@0: public class StateSnapshot implements TreeBuilderState { michael@0: michael@0: private final @Auto StackNode[] stack; michael@0: michael@0: private final @Auto StackNode[] listOfActiveFormattingElements; michael@0: michael@0: private final @Auto int[] templateModeStack; michael@0: michael@0: private final T formPointer; michael@0: michael@0: private final T headPointer; michael@0: michael@0: private final T deepTreeSurrogateParent; michael@0: michael@0: private final int mode; michael@0: michael@0: private final int originalMode; michael@0: michael@0: private final boolean framesetOk; michael@0: michael@0: private final boolean needToDropLF; michael@0: michael@0: private final boolean quirks; michael@0: michael@0: /** michael@0: * @param stack michael@0: * @param listOfActiveFormattingElements michael@0: * @param templateModeStack michael@0: * @param formPointer michael@0: * @param headPointer michael@0: * @param deepTreeSurrogateParent michael@0: * @param mode michael@0: * @param originalMode michael@0: * @param framesetOk michael@0: * @param needToDropLF michael@0: * @param quirks michael@0: */ michael@0: StateSnapshot(StackNode[] stack, michael@0: StackNode[] listOfActiveFormattingElements, int[] templateModeStack, T formPointer, michael@0: T headPointer, T deepTreeSurrogateParent, int mode, int originalMode, michael@0: boolean framesetOk, boolean needToDropLF, boolean quirks) { michael@0: this.stack = stack; michael@0: this.listOfActiveFormattingElements = listOfActiveFormattingElements; michael@0: this.templateModeStack = templateModeStack; michael@0: this.formPointer = formPointer; michael@0: this.headPointer = headPointer; michael@0: this.deepTreeSurrogateParent = deepTreeSurrogateParent; michael@0: this.mode = mode; michael@0: this.originalMode = originalMode; michael@0: this.framesetOk = framesetOk; michael@0: this.needToDropLF = needToDropLF; michael@0: this.quirks = quirks; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getStack() michael@0: */ michael@0: public StackNode[] getStack() { michael@0: return stack; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getTemplateModeStack() michael@0: */ michael@0: public int[] getTemplateModeStack() { michael@0: return templateModeStack; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElements() michael@0: */ michael@0: public StackNode[] getListOfActiveFormattingElements() { michael@0: return listOfActiveFormattingElements; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getFormPointer() michael@0: */ michael@0: public T getFormPointer() { michael@0: return formPointer; michael@0: } michael@0: michael@0: /** michael@0: * Returns the headPointer. michael@0: * michael@0: * @return the headPointer michael@0: */ michael@0: public T getHeadPointer() { michael@0: return headPointer; michael@0: } michael@0: michael@0: /** michael@0: * Returns the deepTreeSurrogateParent. michael@0: * michael@0: * @return the deepTreeSurrogateParent michael@0: */ michael@0: public T getDeepTreeSurrogateParent() { michael@0: return deepTreeSurrogateParent; michael@0: } michael@0: michael@0: /** michael@0: * Returns the mode. michael@0: * michael@0: * @return the mode michael@0: */ michael@0: public int getMode() { michael@0: return mode; michael@0: } michael@0: michael@0: /** michael@0: * Returns the originalMode. michael@0: * michael@0: * @return the originalMode michael@0: */ michael@0: public int getOriginalMode() { michael@0: return originalMode; michael@0: } michael@0: michael@0: /** michael@0: * Returns the framesetOk. michael@0: * michael@0: * @return the framesetOk michael@0: */ michael@0: public boolean isFramesetOk() { michael@0: return framesetOk; michael@0: } michael@0: michael@0: /** michael@0: * Returns the needToDropLF. michael@0: * michael@0: * @return the needToDropLF michael@0: */ michael@0: public boolean isNeedToDropLF() { michael@0: return needToDropLF; michael@0: } michael@0: michael@0: /** michael@0: * Returns the quirks. michael@0: * michael@0: * @return the quirks michael@0: */ michael@0: public boolean isQuirks() { michael@0: return quirks; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElementsLength() michael@0: */ michael@0: public int getListOfActiveFormattingElementsLength() { michael@0: return listOfActiveFormattingElements.length; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getStackLength() michael@0: */ michael@0: public int getStackLength() { michael@0: return stack.length; michael@0: } michael@0: michael@0: /** michael@0: * @see nu.validator.htmlparser.impl.TreeBuilderState#getTemplateModeStackLength() michael@0: */ michael@0: public int getTemplateModeStackLength() { michael@0: return templateModeStack.length; michael@0: } michael@0: michael@0: @SuppressWarnings("unused") private void destructor() { michael@0: for (int i = 0; i < stack.length; i++) { michael@0: stack[i].release(); michael@0: } michael@0: for (int i = 0; i < listOfActiveFormattingElements.length; i++) { michael@0: if (listOfActiveFormattingElements[i] != null) { michael@0: listOfActiveFormattingElements[i].release(); michael@0: } michael@0: } michael@0: } michael@0: }