//# 6 errors, 38 messages
//#
/*
    //#I18nUtils.java:1:1: class: org.apache.roller.weblogger.util.I18nUtils
    //#I18nUtils.java:1:1: method: org.apache.roller.weblogger.util.I18nUtils.org.apache.roller.weblogger.util.I18nUtils__static_init
 * 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.util;

import java.util.Locale;
import org.apache.commons.lang.StringUtils;


/**
 * A utility class for dealing with i18n.
 */
public final class I18nUtils {
    //#I18nUtils.java:28: method: void org.apache.roller.weblogger.util.I18nUtils.org.apache.roller.weblogger.util.I18nUtils()
    //#I18nUtils.java:28: end of method: void org.apache.roller.weblogger.util.I18nUtils.org.apache.roller.weblogger.util.I18nUtils()
    
    public static final Locale toLocale(String locale) {
        if (locale != null) {
    //#I18nUtils.java:31: method: Locale org.apache.roller.weblogger.util.I18nUtils.toLocale(String)
    //#input(Locale toLocale(String)): locale
    //#output(Locale toLocale(String)): new Locale(toLocale#1) num objects
    //#output(Locale toLocale(String)): new Locale(toLocale#2) num objects
    //#output(Locale toLocale(String)): new Locale(toLocale#3) num objects
    //#output(Locale toLocale(String)): return_value
    //#new obj(Locale toLocale(String)): new Locale(toLocale#1)
    //#new obj(Locale toLocale(String)): new Locale(toLocale#2)
    //#new obj(Locale toLocale(String)): new Locale(toLocale#3)
    //#presumption(Locale toLocale(String)): org.apache.commons.lang.StringUtils:split(...)@32 != null
    //#post(Locale toLocale(String)): init'ed(return_value)
    //#post(Locale toLocale(String)): new Locale(toLocale#1) num objects <= 1
    //#post(Locale toLocale(String)): new Locale(toLocale#2) num objects <= 1
    //#post(Locale toLocale(String)): new Locale(toLocale#3) num objects <= 1
    //#test_vector(Locale toLocale(String)): locale: Addr_Set{null}, Inverse{null}
    //#test_vector(Locale toLocale(String)): localeStr.length@32: {0, 4..+Inf}, {1}, {2}, {3}
            String[] localeStr = StringUtils.split(locale,"_");
    //#I18nUtils.java:32: Warning: method not available
    //#    -- call on String[] org.apache.commons.lang.StringUtils:split(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    unanalyzed callee: String[] org.apache.commons.lang.StringUtils:split(String, String)
            if (localeStr.length == 1) {
                if (localeStr[0] == null) localeStr[0] = "";
    //#I18nUtils.java:34: ?use of default init
    //#    init'ed(localeStr[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    basic block: bb_3
    //#    assertion: init'ed(localeStr[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#I18nUtils.java:34: Warning: test always goes same way
    //#    test predetermined because localeStr[0] == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    from bb: bb_3
    //#    live edge: bb_3-->bb_4
    //#    tested vn: undefined == null
    //#    tested vn values: {1}
                return new Locale(localeStr[0]);
            } else if (localeStr.length == 2) {
                if (localeStr[0] == null) localeStr[0] = "";
    //#I18nUtils.java:37: ?use of default init
    //#    init'ed(localeStr[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    basic block: bb_7
    //#    assertion: init'ed(localeStr[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#I18nUtils.java:37: Warning: test always goes same way
    //#    test predetermined because localeStr[0] == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    from bb: bb_7
    //#    live edge: bb_7-->bb_8
    //#    tested vn: undefined == null
    //#    tested vn values: {1}
                if (localeStr[1] == null) localeStr[1] = "";
    //#I18nUtils.java:38: ?use of default init
    //#    init'ed(localeStr[1])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    basic block: bb_9
    //#    assertion: init'ed(localeStr[1])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#I18nUtils.java:38: Warning: test always goes same way
    //#    test predetermined because localeStr[1] == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    from bb: bb_9
    //#    live edge: bb_9-->bb_10
    //#    tested vn: undefined == null
    //#    tested vn values: {1}
                return new Locale(localeStr[0], localeStr[1]);
            } else if (localeStr.length == 3) {
                if (localeStr[0] == null) localeStr[0] = "";
    //#I18nUtils.java:41: ?use of default init
    //#    init'ed(localeStr[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    basic block: bb_13
    //#    assertion: init'ed(localeStr[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#I18nUtils.java:41: Warning: test always goes same way
    //#    test predetermined because localeStr[0] == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    from bb: bb_13
    //#    live edge: bb_13-->bb_14
    //#    tested vn: undefined == null
    //#    tested vn values: {1}
                if (localeStr[1] == null) localeStr[1] = "";
    //#I18nUtils.java:42: ?use of default init
    //#    init'ed(localeStr[1])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    basic block: bb_15
    //#    assertion: init'ed(localeStr[1])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#I18nUtils.java:42: Warning: test always goes same way
    //#    test predetermined because localeStr[1] == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    from bb: bb_15
    //#    live edge: bb_15-->bb_16
    //#    tested vn: undefined == null
    //#    tested vn values: {1}
                if (localeStr[2] == null) localeStr[2] = "";
    //#I18nUtils.java:43: ?use of default init
    //#    init'ed(localeStr[2])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    basic block: bb_17
    //#    assertion: init'ed(localeStr[2])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#I18nUtils.java:43: Warning: test always goes same way
    //#    test predetermined because localeStr[2] == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.I18nUtils
    //#    method: Locale toLocale(String)
    //#    from bb: bb_17
    //#    live edge: bb_17-->bb_18
    //#    tested vn: undefined == null
    //#    tested vn values: {1}
                return new Locale(localeStr[0], localeStr[1], localeStr[2]);
            }
        }
        return Locale.getDefault();
    //#I18nUtils.java:47: end of method: Locale org.apache.roller.weblogger.util.I18nUtils.toLocale(String)
    }
    
}
    //#output(org.apache.roller.weblogger.util.I18nUtils__static_init): __Descendant_Table[org/apache/roller/weblogger/util/I18nUtils]
    //#post(org.apache.roller.weblogger.util.I18nUtils__static_init): __Descendant_Table[org/apache/roller/weblogger/util/I18nUtils] == &__Dispatch_Table
    //#I18nUtils.java:: end of method: org.apache.roller.weblogger.util.I18nUtils.org.apache.roller.weblogger.util.I18nUtils__static_init
    //#I18nUtils.java:: end of class: org.apache.roller.weblogger.util.I18nUtils
