File Source: UIUtils.java
/*
P/P * Method: org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init
*/
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18
19 package org.apache.roller.weblogger.ui.struts2.util;
20
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.Comparator;
24 import java.util.List;
25 import java.util.Locale;
26 import java.util.TimeZone;
27
28
29 /**
30 * A utilities class used by the Weblogger UI.
31 */
/*
P/P * Method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils()
*/
32 public final class UIUtils {
33
34 private static final List locales;
35 private static final List timeZones;
36
37
38 // load up the locales and time zones lists
39 static {
40 // build locales list
/*
P/P * Method: org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init
*
* Postconditions:
* init'ed(locales)
* init'ed(timeZones)
*/
41 locales = Arrays.asList(Locale.getAvailableLocales());
42 Collections.sort(locales, new LocaleComparator());
43
44 // build time zones list
45 timeZones = Arrays.asList(TimeZone.getAvailableIDs());
46 Collections.sort(timeZones);
47 }
48
49
50 public static List getLocales() {
/*
P/P * Method: List getLocales()
*
* Postconditions:
* init'ed(return_value)
*/
51 return locales;
52 }
53
54
55 public static List getTimeZones() {
/*
P/P * Method: List getTimeZones()
*
* Postconditions:
* init'ed(return_value)
*/
56 return timeZones;
57 }
58
59
60 // special comparator for sorting locales
/*
P/P * Method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator(UIUtils$1)
*/
61 private static final class LocaleComparator implements Comparator {
62 public int compare(Object obj1, Object obj2) {
/*
P/P * Method: int compare(Object, Object)
*
* Presumptions:
* java.util.Locale:getDisplayName(...)@66 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* java.lang.String:compareTo(...)@66: {-231..-1, 1..232-1}, {0}
*/
63 if (obj1 instanceof Locale && obj2 instanceof Locale) {
64 Locale locale1 = (Locale)obj1;
65 Locale locale2 = (Locale)obj2;
66 int compName = locale1.getDisplayName().compareTo(locale2.getDisplayName());
67 if (compName == 0) {
68 return locale1.toString().compareTo(locale2.toString());
69 }
70 return compName;
71 }
72 return 0;
73 }
74 }
75
76 }
SofCheck Inspector Build Version : 2.18479
| UIUtils.java |
2009-Jan-02 14:24:50 |
| UIUtils.class |
2009-Sep-04 03:12:45 |
| UIUtils$1.class |
2009-Sep-04 03:12:45 |
| UIUtils$LocaleComparator.class |
2009-Sep-04 03:12:45 |