Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6892493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:32:31+00:00 2026-05-27T06:32:31+00:00

I had to subclass ResourceBundle due to our specific needs. However, to override getKeys()

  • 0

I had to subclass ResourceBundle due to our specific needs.

However, to override getKeys(), I am a bit in trouble. This getKeys needs to somehow concatenate from a map of underlying ResourceBundles. How can I do that?

Thanks

EDIT: While submitting I came across an idea. Basically we have for each of our Module a ResourceBundle, so my code looks like this so far:

public Enumeration<String> getKeys() {
        ArrayList<String> keys = new ArrayList<String>();

        for (Map.Entry<Module, ResourceBundle> entry : internalMap.entrySet()) {
            Enumeration<String> tmp = entry.getValue().getKeys();
            while (tmp.hasMoreElements()) {
                String key = tmp.nextElement();
                keys.add(key);
            }
        }

        return Collections.enumeration(keys);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:32:32+00:00Added an answer on May 27, 2026 at 6:32 am

    This is what we finally came up with. There is more code to it but thought it would be fair to share the basics. The solution follows a bit skaffman’s proposal.
    Thanks to all contributions.

    public class ChainedResourceBundle extends ResourceBundle implements Enumeration<String> {
    
        Iterator<Map.Entry<Module, ResourceBundle>> tables;
        private Enumeration<String>                 keys;
    
        private Map<Module, ResourceBundle>         internalMap    = new HashMap<Module, ResourceBundle>();
        private Map<String, String>                 customizedKeys = new HashMap<String, String>();
    
    
        @Override
        public Enumeration<String> getKeys() {
            tables = internalMap.entrySet().iterator();
            nextTable();
            return this;
        }
    
    
        @Override
        public boolean hasMoreElements() {
            return keys != null;
        }
    
    
        @Override
        public String nextElement() {
            String key = keys.nextElement();
            if (!keys.hasMoreElements()) {
                nextTable();
            }
            return key;
        }
    
        private void nextTable() {
            if (tables.hasNext()) {
                keys = tables.next().getValue().getKeys();
            } else {
                keys = null;
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had spend some time on this Bridge pattern example from wikipedia , however,
Had a coworker ask me this, and in my brain befuddled state I didn't
Just to grok this: If I had a transient property, lets say averagePrice, and
I have a UIViewController subclass called TripViewController. This class has the following method: -
(Jeopardy-style question, I wish the answer had been online when I had this issue)
Edit: This didn't work because I had: class Animal { ... } class Horse
this is something I have always had confusion about I never can seem to
I've had a crack at implementing bindings for my own NSView subclass. It works,
I thought I had this nailed, and then I go and look at some
I had two classes: ParentClass and SubClass. SubClass inherit from ParentClass. I had the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.