1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Sep 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 * $Id: BasisLibrary.java,v 1.6 2006/06/20 21:51:58 spericas Exp $
23 */
44 import java.text.DecimalFormat;
45 import java.text.DecimalFormatSymbols;
46 import java.text.FieldPosition;
47 import java.text.MessageFormat;
48 import java.text.NumberFormat;
49 import java.util.Locale;
50 import java.util.ResourceBundle;
51 import java.util.concurrent.atomic.AtomicInteger;
52 import javax.xml.transform.dom.DOMSource;
53 import jdk.xml.internal.SecuritySupport;
54 import org.w3c.dom.Attr;
55 import org.w3c.dom.DOMException;
56 import org.w3c.dom.Document;
57 import org.w3c.dom.Element;
58 import org.w3c.dom.NodeList;
59 import org.xml.sax.SAXException;
60
61 /**
62 * Standard XSLT functions. All standard functions expect the current node
63 * and the DOM as their last two arguments.
64 */
65 public final class BasisLibrary {
66
67 private final static String EMPTYSTRING = "";
68
69 /**
70 * Re-use a single instance of StringBuffer (per thread) in the basis library.
71 * StringBuilder is better, however, DecimalFormat only accept StringBuffer
72 */
73 private static final ThreadLocal<StringBuilder> threadLocalStringBuilder =
74 new ThreadLocal<StringBuilder> () {
75 @Override protected StringBuilder initialValue() {
76 return new StringBuilder();
77 }
78 };
79
80 /**
81 * ThreadLocal for StringBuffer used
82 */
83 private static final ThreadLocal<StringBuffer> threadLocalStringBuffer =
|
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 */
43 import java.text.DecimalFormat;
44 import java.text.DecimalFormatSymbols;
45 import java.text.FieldPosition;
46 import java.text.MessageFormat;
47 import java.text.NumberFormat;
48 import java.util.Locale;
49 import java.util.ResourceBundle;
50 import java.util.concurrent.atomic.AtomicInteger;
51 import javax.xml.transform.dom.DOMSource;
52 import jdk.xml.internal.SecuritySupport;
53 import org.w3c.dom.Attr;
54 import org.w3c.dom.DOMException;
55 import org.w3c.dom.Document;
56 import org.w3c.dom.Element;
57 import org.w3c.dom.NodeList;
58 import org.xml.sax.SAXException;
59
60 /**
61 * Standard XSLT functions. All standard functions expect the current node
62 * and the DOM as their last two arguments.
63 *
64 * @LastModified: Sep 2017
65 */
66 public final class BasisLibrary {
67
68 private final static String EMPTYSTRING = "";
69
70 /**
71 * Re-use a single instance of StringBuffer (per thread) in the basis library.
72 * StringBuilder is better, however, DecimalFormat only accept StringBuffer
73 */
74 private static final ThreadLocal<StringBuilder> threadLocalStringBuilder =
75 new ThreadLocal<StringBuilder> () {
76 @Override protected StringBuilder initialValue() {
77 return new StringBuilder();
78 }
79 };
80
81 /**
82 * ThreadLocal for StringBuffer used
83 */
84 private static final ThreadLocal<StringBuffer> threadLocalStringBuffer =
|