1 /*
2 * Copyright (c) 2012, 2016, 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
105
106 Object getBreakIteratorInfo(String key) {
107 Object biInfo;
108 String cacheKey = BREAK_ITERATOR_INFO + key;
109
110 removeEmptyReferences();
111 ResourceReference data = cache.get(cacheKey);
112 if (data == null || ((biInfo = data.get()) == null)) {
113 biInfo = localeData.getBreakIteratorInfo(locale).getObject(key);
114 cache.put(cacheKey, new ResourceReference(cacheKey, biInfo, referenceQueue));
115 }
116
117 return biInfo;
118 }
119
120 @SuppressWarnings("unchecked")
121 byte[] getBreakIteratorResources(String key) {
122 return (byte[]) localeData.getBreakIteratorResources(locale).getObject(key);
123 }
124
125 int getCalendarData(String key) {
126 Integer caldata;
127 String cacheKey = CALENDAR_DATA + key;
128
129 removeEmptyReferences();
130
131 ResourceReference data = cache.get(cacheKey);
132 if (data == null || ((caldata = (Integer) data.get()) == null)) {
133 ResourceBundle rb = localeData.getCalendarData(locale);
134 if (rb.containsKey(key)) {
135 caldata = Integer.parseInt(rb.getString(key));
136 } else {
137 caldata = 0;
138 }
139
140 cache.put(cacheKey,
141 new ResourceReference(cacheKey, (Object) caldata, referenceQueue));
142 }
143
144 return caldata;
145 }
146
147 public String getCollationData() {
148 String key = "Rule";
149 String coldata = "";
150
151 removeEmptyReferences();
152 ResourceReference data = cache.get(COLLATION_DATA_CACHEKEY);
153 if (data == null || ((coldata = (String) data.get()) == null)) {
154 ResourceBundle rb = localeData.getCollationData(locale);
155 if (rb.containsKey(key)) {
156 coldata = rb.getString(key);
157 }
158 cache.put(COLLATION_DATA_CACHEKEY,
159 new ResourceReference(COLLATION_DATA_CACHEKEY, (Object) coldata, referenceQueue));
160 }
161
|
1 /*
2 * Copyright (c) 2012, 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
105
106 Object getBreakIteratorInfo(String key) {
107 Object biInfo;
108 String cacheKey = BREAK_ITERATOR_INFO + key;
109
110 removeEmptyReferences();
111 ResourceReference data = cache.get(cacheKey);
112 if (data == null || ((biInfo = data.get()) == null)) {
113 biInfo = localeData.getBreakIteratorInfo(locale).getObject(key);
114 cache.put(cacheKey, new ResourceReference(cacheKey, biInfo, referenceQueue));
115 }
116
117 return biInfo;
118 }
119
120 @SuppressWarnings("unchecked")
121 byte[] getBreakIteratorResources(String key) {
122 return (byte[]) localeData.getBreakIteratorResources(locale).getObject(key);
123 }
124
125 public String getCalendarData(String key) {
126 String caldata = "";
127 String cacheKey = CALENDAR_DATA + key;
128
129 removeEmptyReferences();
130
131 ResourceReference data = cache.get(cacheKey);
132 if (data == null || ((caldata = (String) data.get()) == null)) {
133 ResourceBundle rb = localeData.getCalendarData(locale);
134 if (rb.containsKey(key)) {
135 caldata = rb.getString(key);
136 }
137
138 cache.put(cacheKey,
139 new ResourceReference(cacheKey, caldata, referenceQueue));
140 }
141
142 return caldata;
143 }
144
145 public String getCollationData() {
146 String key = "Rule";
147 String coldata = "";
148
149 removeEmptyReferences();
150 ResourceReference data = cache.get(COLLATION_DATA_CACHEKEY);
151 if (data == null || ((coldata = (String) data.get()) == null)) {
152 ResourceBundle rb = localeData.getCollationData(locale);
153 if (rb.containsKey(key)) {
154 coldata = rb.getString(key);
155 }
156 cache.put(COLLATION_DATA_CACHEKEY,
157 new ResourceReference(COLLATION_DATA_CACHEKEY, (Object) coldata, referenceQueue));
158 }
159
|