All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lessvoid.xml.tools.BundleInfoResourceBundle Maven / Gradle / Ivy

Go to download

Nifty GUI is a Java Library that supports the building of interactive user interfaces for games or similar applications. It utilizes OpenGL for rendering and it can be easily integrated into many rendering systems. The configuration of the GUI is stored in xml files with little supporting Java code. In short Nifty helps you to layout stuff, display it in a cool way and interact with it :)

There is a newer version: 1.4.3
Show newest version
package de.lessvoid.xml.tools;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

/**
 * A BundleInfo that will use an already existing ResourceBundle. 
 * @author void
 */
public class BundleInfoResourceBundle implements BundleInfo {
  private final ResourceBundle defaultResourceBundle;
  private Map resourceBundles = new HashMap();

  public BundleInfoResourceBundle(final ResourceBundle resourceBundle) {
    this.defaultResourceBundle = resourceBundle;
    resourceBundles.put(resourceBundle.getLocale(), resourceBundle);
  }

  public void add(final ResourceBundle resourceBundle) {
    resourceBundles.put(resourceBundle.getLocale(), resourceBundle);
  }

  @Override
  public String getString(final String resourceKey, final Locale locale) {
    ResourceBundle res;
    if (locale == null) {
      res = defaultResourceBundle;
    } else {
      res = resourceBundles.get(locale);
      if (res == null) {
        res = defaultResourceBundle;
      }
    }
    return res.getString(resourceKey);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy