parser/html/javasrc/StateSnapshot.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser/html/javasrc/StateSnapshot.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,204 @@
     1.4 +/*
     1.5 + * Copyright (c) 2009-2010 Mozilla Foundation
     1.6 + *
     1.7 + * Permission is hereby granted, free of charge, to any person obtaining a 
     1.8 + * copy of this software and associated documentation files (the "Software"), 
     1.9 + * to deal in the Software without restriction, including without limitation 
    1.10 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
    1.11 + * and/or sell copies of the Software, and to permit persons to whom the 
    1.12 + * Software is furnished to do so, subject to the following conditions:
    1.13 + *
    1.14 + * The above copyright notice and this permission notice shall be included in 
    1.15 + * all copies or substantial portions of the Software.
    1.16 + *
    1.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    1.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    1.20 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
    1.22 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
    1.23 + * DEALINGS IN THE SOFTWARE.
    1.24 + */
    1.25 +
    1.26 +package nu.validator.htmlparser.impl;
    1.27 +
    1.28 +import nu.validator.htmlparser.annotation.Auto;
    1.29 +
    1.30 +
    1.31 +public class StateSnapshot<T> implements TreeBuilderState<T> {
    1.32 +
    1.33 +    private final @Auto StackNode<T>[] stack;
    1.34 +
    1.35 +    private final @Auto StackNode<T>[] listOfActiveFormattingElements;
    1.36 +
    1.37 +    private final @Auto int[] templateModeStack;
    1.38 +
    1.39 +    private final T formPointer;
    1.40 +
    1.41 +    private final T headPointer;
    1.42 +
    1.43 +    private final T deepTreeSurrogateParent;
    1.44 +
    1.45 +    private final int mode;
    1.46 +
    1.47 +    private final int originalMode;
    1.48 +    
    1.49 +    private final boolean framesetOk;
    1.50 +
    1.51 +    private final boolean needToDropLF;
    1.52 +
    1.53 +    private final boolean quirks;
    1.54 +
    1.55 +    /**
    1.56 +     * @param stack
    1.57 +     * @param listOfActiveFormattingElements
    1.58 +     * @param templateModeStack
    1.59 +     * @param formPointer
    1.60 +     * @param headPointer
    1.61 +     * @param deepTreeSurrogateParent
    1.62 +     * @param mode
    1.63 +     * @param originalMode
    1.64 +     * @param framesetOk
    1.65 +     * @param needToDropLF
    1.66 +     * @param quirks
    1.67 +     */
    1.68 +    StateSnapshot(StackNode<T>[] stack,
    1.69 +            StackNode<T>[] listOfActiveFormattingElements, int[] templateModeStack, T formPointer,
    1.70 +            T headPointer, T deepTreeSurrogateParent, int mode, int originalMode,
    1.71 +            boolean framesetOk, boolean needToDropLF, boolean quirks) {
    1.72 +        this.stack = stack;
    1.73 +        this.listOfActiveFormattingElements = listOfActiveFormattingElements;
    1.74 +        this.templateModeStack = templateModeStack;
    1.75 +        this.formPointer = formPointer;
    1.76 +        this.headPointer = headPointer;
    1.77 +        this.deepTreeSurrogateParent = deepTreeSurrogateParent;
    1.78 +        this.mode = mode;
    1.79 +        this.originalMode = originalMode;
    1.80 +        this.framesetOk = framesetOk;
    1.81 +        this.needToDropLF = needToDropLF;
    1.82 +        this.quirks = quirks;
    1.83 +    }
    1.84 +    
    1.85 +    /**
    1.86 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getStack()
    1.87 +     */
    1.88 +    public StackNode<T>[] getStack() {
    1.89 +        return stack;
    1.90 +    }
    1.91 +
    1.92 +    /**
    1.93 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getTemplateModeStack()
    1.94 +     */
    1.95 +    public int[] getTemplateModeStack() {
    1.96 +        return templateModeStack;
    1.97 +    }
    1.98 +
    1.99 +    /**
   1.100 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElements()
   1.101 +     */
   1.102 +    public StackNode<T>[] getListOfActiveFormattingElements() {
   1.103 +        return listOfActiveFormattingElements;
   1.104 +    }
   1.105 +
   1.106 +    /**
   1.107 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getFormPointer()
   1.108 +     */
   1.109 +    public T getFormPointer() {
   1.110 +        return formPointer;
   1.111 +    }
   1.112 +
   1.113 +    /**
   1.114 +     * Returns the headPointer.
   1.115 +     * 
   1.116 +     * @return the headPointer
   1.117 +     */
   1.118 +    public T getHeadPointer() {
   1.119 +        return headPointer;
   1.120 +    }
   1.121 +
   1.122 +    /**
   1.123 +     * Returns the deepTreeSurrogateParent.
   1.124 +     * 
   1.125 +     * @return the deepTreeSurrogateParent
   1.126 +     */
   1.127 +    public T getDeepTreeSurrogateParent() {
   1.128 +        return deepTreeSurrogateParent;
   1.129 +    }
   1.130 +    
   1.131 +    /**
   1.132 +     * Returns the mode.
   1.133 +     * 
   1.134 +     * @return the mode
   1.135 +     */
   1.136 +    public int getMode() {
   1.137 +        return mode;
   1.138 +    }
   1.139 +
   1.140 +    /**
   1.141 +     * Returns the originalMode.
   1.142 +     * 
   1.143 +     * @return the originalMode
   1.144 +     */
   1.145 +    public int getOriginalMode() {
   1.146 +        return originalMode;
   1.147 +    }
   1.148 +
   1.149 +    /**
   1.150 +     * Returns the framesetOk.
   1.151 +     * 
   1.152 +     * @return the framesetOk
   1.153 +     */
   1.154 +    public boolean isFramesetOk() {
   1.155 +        return framesetOk;
   1.156 +    }
   1.157 +
   1.158 +    /**
   1.159 +     * Returns the needToDropLF.
   1.160 +     * 
   1.161 +     * @return the needToDropLF
   1.162 +     */
   1.163 +    public boolean isNeedToDropLF() {
   1.164 +        return needToDropLF;
   1.165 +    }
   1.166 +
   1.167 +    /**
   1.168 +     * Returns the quirks.
   1.169 +     * 
   1.170 +     * @return the quirks
   1.171 +     */
   1.172 +    public boolean isQuirks() {
   1.173 +        return quirks;
   1.174 +    }
   1.175 +    
   1.176 +    /**
   1.177 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElementsLength()
   1.178 +     */
   1.179 +    public int getListOfActiveFormattingElementsLength() {
   1.180 +        return listOfActiveFormattingElements.length;
   1.181 +    }
   1.182 +
   1.183 +    /**
   1.184 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getStackLength()
   1.185 +     */
   1.186 +    public int getStackLength() {
   1.187 +        return stack.length;
   1.188 +    }
   1.189 +
   1.190 +    /**
   1.191 +     * @see nu.validator.htmlparser.impl.TreeBuilderState#getTemplateModeStackLength()
   1.192 +     */
   1.193 +    public int getTemplateModeStackLength() {
   1.194 +        return templateModeStack.length;
   1.195 +    }
   1.196 +
   1.197 +    @SuppressWarnings("unused") private void destructor() {
   1.198 +        for (int i = 0; i < stack.length; i++) {
   1.199 +            stack[i].release();
   1.200 +        }
   1.201 +        for (int i = 0; i < listOfActiveFormattingElements.length; i++) {
   1.202 +            if (listOfActiveFormattingElements[i] != null) {
   1.203 +                listOfActiveFormattingElements[i].release();                
   1.204 +            }
   1.205 +        }
   1.206 +    }
   1.207 +}

mercurial