1 /*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xml.internal.dtm.ref;
23
57 public class DTMNodeList extends DTMNodeListBase {
58 private DTMIterator m_iter;
59
60 //================================================================
61 // Methods unique to this class
62 private DTMNodeList() {
63 }
64
65 /**
66 * Public constructor: Wrap a DTMNodeList around an existing
67 * and preconfigured DTMIterator
68 *
69 * WARNING: THIS HAS THE SIDE EFFECT OF ISSUING setShouldCacheNodes(true)
70 * AGAINST THE DTMIterator.
71 *
72 */
73 public DTMNodeList(DTMIterator dtmIterator) {
74 if (dtmIterator != null) {
75 int pos = dtmIterator.getCurrentPos();
76 try {
77 m_iter=(DTMIterator)dtmIterator.cloneWithReset();
78 } catch(CloneNotSupportedException cnse) {
79 m_iter = dtmIterator;
80 }
81 m_iter.setShouldCacheNodes(true);
82 m_iter.runTo(-1);
83 m_iter.setCurrentPos(pos);
84 }
85 }
86
87 /**
88 * Access the wrapped DTMIterator. I'm not sure whether anyone will
89 * need this or not, but let's write it and think about it.
90 *
91 */
92 public DTMIterator getDTMIterator() {
93 return m_iter;
94 }
95
96 //================================================================
97 // org.w3c.dom.NodeList API follows
|
1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Nov 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xml.internal.dtm.ref;
23
57 public class DTMNodeList extends DTMNodeListBase {
58 private DTMIterator m_iter;
59
60 //================================================================
61 // Methods unique to this class
62 private DTMNodeList() {
63 }
64
65 /**
66 * Public constructor: Wrap a DTMNodeList around an existing
67 * and preconfigured DTMIterator
68 *
69 * WARNING: THIS HAS THE SIDE EFFECT OF ISSUING setShouldCacheNodes(true)
70 * AGAINST THE DTMIterator.
71 *
72 */
73 public DTMNodeList(DTMIterator dtmIterator) {
74 if (dtmIterator != null) {
75 int pos = dtmIterator.getCurrentPos();
76 try {
77 m_iter = dtmIterator.cloneWithReset();
78 } catch(CloneNotSupportedException cnse) {
79 m_iter = dtmIterator;
80 }
81 m_iter.setShouldCacheNodes(true);
82 m_iter.runTo(-1);
83 m_iter.setCurrentPos(pos);
84 }
85 }
86
87 /**
88 * Access the wrapped DTMIterator. I'm not sure whether anyone will
89 * need this or not, but let's write it and think about it.
90 *
91 */
92 public DTMIterator getDTMIterator() {
93 return m_iter;
94 }
95
96 //================================================================
97 // org.w3c.dom.NodeList API follows
|