Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.litesoft.locale;

import java.util.*;

@SuppressWarnings("Convert2Diamond")
public final class Locales
{
    private static Locales sInstance;

    public static synchronized Locales getInstance()
    {
        if ( sInstance == null )
        {
            throw new IllegalStateException( "Locales referenced before being initialized!" );
        }
        return sInstance;
    }

    private static synchronized void setInstance( Locales pInstance )
    {
        if ( sInstance != null )
        {
            throw new IllegalStateException( "Duplicate Locales created!" );
        }
        sInstance = pInstance;
    }

    private final Set<AbstractLocale> mSupported;
    private final List<String> mActiveCodes = new ArrayList<String>();

    public Locales( AbstractLocale... pSupportedLocales )
    {
        mSupported = Collections.unmodifiableSet( toSet( pSupportedLocales ) );
        for ( AbstractLocale zLocale : pSupportedLocales )
        {
            if ( zLocale.isActive() )
            {
                mActiveCodes.add( zLocale.getCode() );
            }
        }
        setInstance( this ); // 'this' leakage, but is final class!
    }

    public static Set<AbstractLocale> getSupported()
    {
        return getInstance().mSupported;
    }

    public static String[] getActiveCodes()
    {
        List<String> zActiveCodes = getInstance().mActiveCodes;
        return zActiveCodes.toArray( new String[zActiveCodes.size()] );
    }

    public static Set<AbstractLocale> toSet( AbstractLocale... pSupportedLocales )
    {
        Set<AbstractLocale> zLocales = new HashSet<>();
        Collections.addAll( zLocales, pSupportedLocales );
        return zLocales;
    }
}

Commits for litesoft/trunk/DeviceDesktopTest/src/org/litesoft/locale/Locales.java

Diff revisions: vs.
Revision Author Commited Message
943 Diff Diff GeorgeS picture GeorgeS Tue 03 Jun, 2014 04:25:50 +0000

Extracting commonfoundation

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

935 Diff Diff GeorgeS picture GeorgeS Fri 30 May, 2014 20:28:08 +0000

Reformatted.

931 Diff Diff GeorgeS picture GeorgeS Tue 01 Apr, 2014 20:11:20 +0000

Locale Support.

929 GeorgeS picture GeorgeS Mon 31 Mar, 2014 01:42:14 +0000

Locale Work...