//# 0 errors, 51 messages
//#
/*
    //#UIUtils.java:1:1: class: org.apache.roller.weblogger.ui.struts2.util.UIUtils$1
    //#UIUtils.java:1:1: method: org.apache.roller.weblogger.ui.struts2.util.UIUtils$1.org.apache.roller.weblogger.ui.struts2.util.UIUtils$1__static_init
    //#UIUtils.java:1:1: class: org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator
    //#UIUtils.java:1:1: method: org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init
    //#UIUtils.java:1:1: class: org.apache.roller.weblogger.ui.struts2.util.UIUtils
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.struts2.util;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;


/**
 * A utilities class used by the Weblogger UI.
 */
public final class UIUtils {
    //#UIUtils.java:32: method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils.org.apache.roller.weblogger.ui.struts2.util.UIUtils()
    
    private static final List locales;
    private static final List timeZones;
    
    
    // load up the locales and time zones lists
    static {
        // build locales list
        locales = Arrays.asList(Locale.getAvailableLocales());
    //#UIUtils.java:41: method: org.apache.roller.weblogger.ui.struts2.util.UIUtils.org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIUtils]
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init): locales
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init): timeZones
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIUtils] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init): init'ed(locales)
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init): init'ed(timeZones)
        Collections.sort(locales, new LocaleComparator());
        
        // build time zones list
        timeZones = Arrays.asList(TimeZone.getAvailableIDs());
        Collections.sort(timeZones);
    }
    //#UIUtils.java:47: end of method: org.apache.roller.weblogger.ui.struts2.util.UIUtils.org.apache.roller.weblogger.ui.struts2.util.UIUtils__static_init
    
    
    public static List getLocales() {
        return locales;
    //#UIUtils.java:51: method: List org.apache.roller.weblogger.ui.struts2.util.UIUtils.getLocales()
    //#input(List getLocales()): locales
    //#output(List getLocales()): return_value
    //#post(List getLocales()): init'ed(return_value)
    //#UIUtils.java:51: end of method: List org.apache.roller.weblogger.ui.struts2.util.UIUtils.getLocales()
    }
    
    
    public static List getTimeZones() {
        return timeZones;
    //#UIUtils.java:56: method: List org.apache.roller.weblogger.ui.struts2.util.UIUtils.getTimeZones()
    //#input(List getTimeZones()): timeZones
    //#output(List getTimeZones()): return_value
    //#post(List getTimeZones()): init'ed(return_value)
    //#UIUtils.java:56: end of method: List org.apache.roller.weblogger.ui.struts2.util.UIUtils.getTimeZones()
    }
    
    
    // special comparator for sorting locales
    private static final class LocaleComparator implements Comparator {
    //#UIUtils.java:61: method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator()
    //#UIUtils.java:61: end of method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator()
    //#UIUtils.java:61: method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator(UIUtils$1)
    //#input(void org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator(UIUtils$1)): this
    //#UIUtils.java:61: end of method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator(UIUtils$1)
    //#UIUtils.java:61: end of method: void org.apache.roller.weblogger.ui.struts2.util.UIUtils.org.apache.roller.weblogger.ui.struts2.util.UIUtils()
        public int compare(Object obj1, Object obj2) {
            if (obj1 instanceof Locale && obj2 instanceof Locale) {
    //#UIUtils.java:63: method: int org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.compare(Object, Object)
    //#input(int compare(Object, Object)): obj1
    //#input(int compare(Object, Object)): obj1._tainted
    //#input(int compare(Object, Object)): obj2
    //#input(int compare(Object, Object)): obj2._tainted
    //#output(int compare(Object, Object)): return_value
    //#presumption(int compare(Object, Object)): java.util.Locale:getDisplayName(...)@66 != null
    //#post(int compare(Object, Object)): init'ed(return_value)
    //#test_vector(int compare(Object, Object)): java.lang.String:compareTo(...)@66: {-2_147_483_648..-1, 1..4_294_967_295}, {0}
                Locale locale1 = (Locale)obj1;
                Locale locale2 = (Locale)obj2;
                int compName = locale1.getDisplayName().compareTo(locale2.getDisplayName());
                if (compName == 0) {
                    return locale1.toString().compareTo(locale2.toString());
                }
                return compName;
            }
            return 0;
    //#UIUtils.java:72: end of method: int org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.compare(Object, Object)
        }
    }
    
}
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIUtils$1__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIUtils$1]
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIUtils$1__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIUtils$1] == &__Dispatch_Table
    //#UIUtils.java:: end of method: org.apache.roller.weblogger.ui.struts2.util.UIUtils$1.org.apache.roller.weblogger.ui.struts2.util.UIUtils$1__static_init
    //#UIUtils.java:: end of class: org.apache.roller.weblogger.ui.struts2.util.UIUtils$1
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIUtils$LocaleComparator]
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIUtils$LocaleComparator] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I == &compare
    //#UIUtils.java:: end of method: org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator.org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator__static_init
    //#UIUtils.java:: end of class: org.apache.roller.weblogger.ui.struts2.util.UIUtils$LocaleComparator
    //#UIUtils.java:: end of class: org.apache.roller.weblogger.ui.struts2.util.UIUtils
