FileDocCategorySizeDatePackage
ListResourceBundle.javaAPI DocAndroid 1.5 API3971Wed May 06 22:41:04 BST 2009java.util

ListResourceBundle

public abstract class ListResourceBundle extends ResourceBundle
{@code ListResourceBundle} is the abstract superclass of classes which provide resources by implementing the {@code getContents()} method to return the list of resources.
see
ResourceBundle
since
Android 1.0

Fields Summary
Hashtable
table
Constructors Summary
public ListResourceBundle()
Constructs a new instance of this class.

since
Android 1.0

        super();
    
Methods Summary
protected abstract java.lang.Object[][]getContents()
Returns an {@code Object} array which contains the resources of this {@code ListResourceBundle}. Each element in the array is an array of two elements, the first is the resource key string and the second is the resource.

return
a {@code Object} array containing the resources.
since
Android 1.0

public java.util.EnumerationgetKeys()
Returns the names of the resources contained in this {@code ListResourceBundle}.

return
an {@code Enumeration} of the resource names.
since
Android 1.0

        if (table == null) {
            initializeTable();
        }
        if (parent == null) {
            return table.keys();
        }
        return new Enumeration<String>() {
            Enumeration<String> local = table.keys();

            Enumeration<String> pEnum = parent.getKeys();

            String nextElement;

            private boolean findNext() {
                if (nextElement != null) {
                    return true;
                }
                while (pEnum.hasMoreElements()) {
                    String next = pEnum.nextElement();
                    if (!table.containsKey(next)) {
                        nextElement = next;
                        return true;
                    }
                }
                return false;
            }

            public boolean hasMoreElements() {
                if (local.hasMoreElements()) {
                    return true;
                }
                return findNext();
            }

            public String nextElement() {
                if (local.hasMoreElements()) {
                    return local.nextElement();
                }
                if (findNext()) {
                    String result = nextElement;
                    nextElement = null;
                    return result;
                }
                // Cause an exception
                return pEnum.nextElement();
            }
        };
    
public final java.lang.ObjecthandleGetObject(java.lang.String key)

        if (table == null) {
            initializeTable();
        }
        return table.get(key);
    
private synchronized voidinitializeTable()

        if (table == null) {
            Object[][] contents = getContents();
            table = new Hashtable<String, Object>(contents.length / 3 * 4 + 3);
            for (int i = 0; i < contents.length; i++) {
                table.put((String)contents[i][0], contents[i][1]);
            }
        }