1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1780 this.endOffset = offset + length;
1781 pos = offset;
1782 if (changes == null) {
1783 changes = new Vector<ElemChanges>();
1784 } else {
1785 changes.removeAllElements();
1786 }
1787 if (path == null) {
1788 path = new Stack<ElemChanges>();
1789 } else {
1790 path.removeAllElements();
1791 }
1792 fracturedParent = null;
1793 fracturedChild = null;
1794 offsetLastIndex = offsetLastIndexOnReplace = false;
1795 }
1796
1797 /**
1798 * Pushes a new element onto the stack that represents
1799 * the current path.
1800 * @param record Whether or not the push should be
1801 * recorded as an element change or not.
1802 * @param isFracture true if pushing on an element that was created
1803 * as the result of a fracture.
1804 */
1805 void push(Element e, int index, boolean isFracture) {
1806 ElemChanges ec = new ElemChanges(e, index, isFracture);
1807 path.push(ec);
1808 }
1809
1810 void push(Element e, int index) {
1811 push(e, index, false);
1812 }
1813
1814 void pop() {
1815 ElemChanges ec = path.peek();
1816 path.pop();
1817 if ((ec.added.size() > 0) || (ec.removed.size() > 0)) {
1818 changes.addElement(ec);
1819 } else if (! path.isEmpty()) {
1820 Element e = ec.parent;
1821 if(e.getElementCount() == 0) {
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1780 this.endOffset = offset + length;
1781 pos = offset;
1782 if (changes == null) {
1783 changes = new Vector<ElemChanges>();
1784 } else {
1785 changes.removeAllElements();
1786 }
1787 if (path == null) {
1788 path = new Stack<ElemChanges>();
1789 } else {
1790 path.removeAllElements();
1791 }
1792 fracturedParent = null;
1793 fracturedChild = null;
1794 offsetLastIndex = offsetLastIndexOnReplace = false;
1795 }
1796
1797 /**
1798 * Pushes a new element onto the stack that represents
1799 * the current path.
1800 * @param isFracture true if pushing on an element that was created
1801 * as the result of a fracture.
1802 */
1803 void push(Element e, int index, boolean isFracture) {
1804 ElemChanges ec = new ElemChanges(e, index, isFracture);
1805 path.push(ec);
1806 }
1807
1808 void push(Element e, int index) {
1809 push(e, index, false);
1810 }
1811
1812 void pop() {
1813 ElemChanges ec = path.peek();
1814 path.pop();
1815 if ((ec.added.size() > 0) || (ec.removed.size() > 0)) {
1816 changes.addElement(ec);
1817 } else if (! path.isEmpty()) {
1818 Element e = ec.parent;
1819 if(e.getElementCount() == 0) {
|