1 /*
2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 /*
21 * $Id: BasisLibrary.java,v 1.6 2006/06/20 21:51:58 spericas Exp $
22 */
83 */
84 private static final ThreadLocal<StringBuffer> threadLocalStringBuffer =
85 new ThreadLocal<StringBuffer> () {
86 @Override protected StringBuffer initialValue() {
87 return new StringBuffer();
88 }
89 };
90
91 /**
92 * Standard function count(node-set)
93 */
94 public static int countF(DTMAxisIterator iterator) {
95 return(iterator.getLast());
96 }
97
98 /**
99 * Standard function position()
100 * @deprecated This method exists only for backwards compatibility with old
101 * translets. New code should not reference it.
102 */
103 public static int positionF(DTMAxisIterator iterator) {
104 return iterator.isReverse()
105 ? iterator.getLast() - iterator.getPosition() + 1
106 : iterator.getPosition();
107 }
108
109 /**
110 * XSLT Standard function sum(node-set).
111 * stringToDouble is inlined
112 */
113 public static double sumF(DTMAxisIterator iterator, DOM dom) {
114 try {
115 double result = 0.0;
116 int node;
117 while ((node = iterator.next()) != DTMAxisIterator.END) {
118 result += Double.parseDouble(dom.getStringValueX(node));
119 }
120 return result;
121 }
122 catch (NumberFormatException e) {
|
1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 /*
21 * $Id: BasisLibrary.java,v 1.6 2006/06/20 21:51:58 spericas Exp $
22 */
83 */
84 private static final ThreadLocal<StringBuffer> threadLocalStringBuffer =
85 new ThreadLocal<StringBuffer> () {
86 @Override protected StringBuffer initialValue() {
87 return new StringBuffer();
88 }
89 };
90
91 /**
92 * Standard function count(node-set)
93 */
94 public static int countF(DTMAxisIterator iterator) {
95 return(iterator.getLast());
96 }
97
98 /**
99 * Standard function position()
100 * @deprecated This method exists only for backwards compatibility with old
101 * translets. New code should not reference it.
102 */
103 @Deprecated
104 public static int positionF(DTMAxisIterator iterator) {
105 return iterator.isReverse()
106 ? iterator.getLast() - iterator.getPosition() + 1
107 : iterator.getPosition();
108 }
109
110 /**
111 * XSLT Standard function sum(node-set).
112 * stringToDouble is inlined
113 */
114 public static double sumF(DTMAxisIterator iterator, DOM dom) {
115 try {
116 double result = 0.0;
117 int node;
118 while ((node = iterator.next()) != DTMAxisIterator.END) {
119 result += Double.parseDouble(dom.getStringValueX(node));
120 }
121 return result;
122 }
123 catch (NumberFormatException e) {
|