1 /* |
1 /* |
2 * reserved comment block |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT REMOVE OR ALTER! |
3 * @LastModified: Oct 2017 |
4 */ |
4 */ |
5 /* |
5 /* |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
7 * contributor license agreements. See the NOTICE file distributed with |
7 * contributor license agreements. See the NOTICE file distributed with |
8 * this work for additional information regarding copyright ownership. |
8 * this work for additional information regarding copyright ownership. |
19 * limitations under the License. |
19 * limitations under the License. |
20 */ |
20 */ |
21 |
21 |
22 package com.sun.org.apache.xerces.internal.dom; |
22 package com.sun.org.apache.xerces.internal.dom; |
23 |
23 |
24 import java.util.Vector; |
24 import java.util.ArrayList; |
25 |
25 import java.util.List; |
26 import org.w3c.dom.CharacterData; |
26 import org.w3c.dom.CharacterData; |
27 import org.w3c.dom.DOMException; |
27 import org.w3c.dom.DOMException; |
28 import org.w3c.dom.DocumentFragment; |
28 import org.w3c.dom.DocumentFragment; |
29 import org.w3c.dom.Node; |
29 import org.w3c.dom.Node; |
30 import org.w3c.dom.ranges.Range; |
30 import org.w3c.dom.ranges.Range; |
125 if ( fDetach ) { |
125 if ( fDetach ) { |
126 throw new DOMException( |
126 throw new DOMException( |
127 DOMException.INVALID_STATE_ERR, |
127 DOMException.INVALID_STATE_ERR, |
128 DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null)); |
128 DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null)); |
129 } |
129 } |
130 Vector startV = new Vector(); |
130 List<Node> startV = new ArrayList<>(); |
131 Node node; |
131 Node node; |
132 for (node=fStartContainer; node != null; |
132 for (node=fStartContainer; node != null; |
133 node=node.getParentNode()) |
133 node=node.getParentNode()) |
134 { |
134 { |
135 startV.addElement(node); |
135 startV.add(node); |
136 } |
136 } |
137 Vector endV = new Vector(); |
137 List<Node> endV = new ArrayList<>(); |
138 for (node=fEndContainer; node != null; |
138 for (node=fEndContainer; node != null; |
139 node=node.getParentNode()) |
139 node=node.getParentNode()) |
140 { |
140 { |
141 endV.addElement(node); |
141 endV.add(node); |
142 } |
142 } |
143 int s = startV.size()-1; |
143 int s = startV.size()-1; |
144 int e = endV.size()-1; |
144 int e = endV.size()-1; |
145 Object result = null; |
145 Node result = null; |
146 while (s>=0 && e>=0) { |
146 while (s>=0 && e>=0) { |
147 if (startV.elementAt(s) == endV.elementAt(e)) { |
147 if (startV.get(s) == endV.get(e)) { |
148 result = startV.elementAt(s); |
148 result = startV.get(s); |
149 } else { |
149 } else { |
150 break; |
150 break; |
151 } |
151 } |
152 --s; |
152 --s; |
153 --e; |
153 --e; |
154 } |
154 } |
155 return (Node)result; |
155 return result; |
156 } |
156 } |
157 |
157 |
158 |
158 |
159 public void setStart(Node refNode, int offset) |
159 public void setStart(Node refNode, int offset) |
160 throws RangeException, DOMException |
160 throws RangeException, DOMException |