diff --git a/ccm-core/src/com/arsdigita/globalization/ChainableResourceBundle.java b/ccm-core/src/com/arsdigita/globalization/ChainableResourceBundle.java index fa8dfa667..b2070ded6 100755 --- a/ccm-core/src/com/arsdigita/globalization/ChainableResourceBundle.java +++ b/ccm-core/src/com/arsdigita/globalization/ChainableResourceBundle.java @@ -32,6 +32,9 @@ public interface ChainableResourceBundle { * which normally has protected access. If you have a PropertyResourceBundle * or a ListResourceBundle, this will simply delegate to the * handleGetObject(String key) method. + * + * @param key + * @return */ public Object handleGetObject(String key); @@ -40,6 +43,8 @@ public interface ChainableResourceBundle { * which normally has protected access. If you have a PropertyResourceBundle * or a ListResourceBundle, this will simply delegate to the * getKeys() method. + * + * @return */ - public Enumeration getKeys(); + public Enumeration getKeys(); } diff --git a/ccm-core/src/com/arsdigita/globalization/ChainedResourceBundle.java b/ccm-core/src/com/arsdigita/globalization/ChainedResourceBundle.java index c275d559e..e3183d369 100755 --- a/ccm-core/src/com/arsdigita/globalization/ChainedResourceBundle.java +++ b/ccm-core/src/com/arsdigita/globalization/ChainedResourceBundle.java @@ -43,29 +43,33 @@ import java.util.ResourceBundle; * */ public class ChainedResourceBundle extends ResourceBundle { - - private List m_bundles; - private List m_keys; + + private final List bundles; + private final List keys; public ChainedResourceBundle() { super(); - m_bundles = new LinkedList(); - m_keys = new LinkedList(); + bundles = new LinkedList(); + keys = new LinkedList(); } /** * this wraps the PropertyResourceBundle in a ChainableResourceBundle * and then delegates to addBundle(ChainableResourceBundle bundle); + * + * @param bundle */ - public void addBundle(PropertyResourceBundle bundle) { + public void addBundle(final PropertyResourceBundle bundle) { addBundle(new ChainablePropertyResourceBundle(bundle)); } /** * this wraps the PropertyResourceBundle in a ChainableResourceBundle * and then delegates to addBundle(ChainableResourceBundle bundle); + * + * @param bundle */ - public void addBundle(ListResourceBundle bundle) { + public void addBundle(final ListResourceBundle bundle) { addBundle(new ChainableListResourceBundle(bundle)); } @@ -73,32 +77,32 @@ public class ChainedResourceBundle extends ResourceBundle { * This adds bundles to this chained resource. The bundles * are examined for the key in the order that they are added. */ - private void addBundle(ChainableResourceBundle bundle) { - m_bundles.add(bundle); - Enumeration enu = bundle.getKeys(); + private void addBundle(final ChainableResourceBundle bundle) { + bundles.add(bundle); + final Enumeration enu = bundle.getKeys(); while (enu.hasMoreElements()) { - m_keys.add(enu.nextElement()); + keys.add(enu.nextElement()); } } - - public void putBundle(PropertyResourceBundle bundle) { - putBundle(new ChainablePropertyResourceBundle(bundle)); - } - - public void putBundle(ListResourceBundle bundle) { - putBundle(new ChainableListResourceBundle(bundle)); + + public void putBundle(final PropertyResourceBundle bundle) { + putBundle(new ChainablePropertyResourceBundle(bundle)); } - private void putBundle(ChainableResourceBundle bundle) { - m_bundles.add(0,bundle); - Enumeration enu = bundle.getKeys(); - List bundleKeys = new LinkedList(); + public void putBundle(final ListResourceBundle bundle) { + putBundle(new ChainableListResourceBundle(bundle)); + } + + private void putBundle(final ChainableResourceBundle bundle) { + bundles.add(0, bundle); + final Enumeration enu = bundle.getKeys(); + final List bundleKeys = new LinkedList(); while (enu.hasMoreElements()) { bundleKeys.add(enu.nextElement()); } - m_keys.addAll(0, bundleKeys); + keys.addAll(0, bundleKeys); } - + /** * Because this particular bundle is just a wrapper around other bundles, * this method will return null so that the ResourceBundle can then @@ -106,20 +110,24 @@ public class ChainedResourceBundle extends ResourceBundle { * @param key * @return */ + @Override public Object handleGetObject(final String key) { - Iterator iter = m_bundles.iterator(); + final Iterator iter = bundles.iterator(); Object object = null; - while (iter.hasNext() && object == null) { - object = ((ChainableResourceBundle)iter.next()).handleGetObject(key); - } + ChainableResourceBundle bundle; + while (iter.hasNext() && object == null) { + bundle = iter.next(); + object = bundle.handleGetObject(key); + //object = iter.next().handleGetObject(key); + } return object; } - public Enumeration getKeys() { - return Collections.enumeration(m_keys); + @Override + public Enumeration getKeys() { + return Collections.enumeration(keys); } - /** * This is basically a way to allow us to set the parent. The javadoc * for these methods can be found by looking at the javadoc for @@ -127,57 +135,59 @@ public class ChainedResourceBundle extends ResourceBundle { * an internal PropertyResourceBundle. */ private class ChainablePropertyResourceBundle - implements ChainableResourceBundle { + implements ChainableResourceBundle { - private PropertyResourceBundle m_wrappedBundle = null; + private final PropertyResourceBundle wrappedBundle; /** * This creates a new Bundle that delegates everything to the * passed in bundle and sets the parent of the passed in bundle * to the passed in ResourceBundle */ - public ChainablePropertyResourceBundle(PropertyResourceBundle bundle) { + public ChainablePropertyResourceBundle(final PropertyResourceBundle bundle) { super(); - m_wrappedBundle = bundle; - } - - public Object handleGetObject(String key) { - return m_wrappedBundle.handleGetObject(key); + wrappedBundle = bundle; } - public Enumeration getKeys() { - return m_wrappedBundle.getKeys(); + @Override + public Object handleGetObject(final String key) { + return wrappedBundle.handleGetObject(key); } + + @Override + public Enumeration getKeys() { + return wrappedBundle.getKeys(); + } + } - /** * This is basically a way to allow us to set the parent. The javadoc * for these methods can be found by looking at the javadoc for * PropertyResourceBundle since this delegate everything to * an internal PropertyResourceBundle. */ - private class ChainableListResourceBundle - implements ChainableResourceBundle { + private class ChainableListResourceBundle implements ChainableResourceBundle { - private ListResourceBundle m_wrappedBundle = null; + private final ListResourceBundle m_wrappedBundle; /** * This creates a new Bundle that delegates everything to the * passed in bundle and sets the parent of the passed in bundle * to the passed in ResourceBundle */ - public ChainableListResourceBundle(ListResourceBundle bundle) { + public ChainableListResourceBundle(final ListResourceBundle bundle) { super(); m_wrappedBundle = bundle; } - - public Object handleGetObject(String key) { + + public Object handleGetObject(final String key) { return m_wrappedBundle.handleGetObject(key); } - public Enumeration getKeys() { + public Enumeration getKeys() { return m_wrappedBundle.getKeys(); } + } }