extends ListResourceBundle : ListResourceBundle « java.util « Java by API






extends ListResourceBundle

 
import java.awt.Button;
import java.util.Enumeration;
import java.util.ListResourceBundle;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] argv) {
    try {
      ResourceBundle rb = ResourceBundle.getBundle("SimpleResourceBundle");

      System.out.println(rb.getString("AMMessage"));
      System.out.println(rb.getString("PMMessage"));

    } catch (MissingResourceException mre) {
      mre.printStackTrace();
    }
  }
}

class SampleResourceBundle extends ListResourceBundle {
  public Object[][] getContents() {
    return contents;
  }
  static final Object[][] contents = { { "okButton", new Button("OK") },
      { "negativeInteger", new Integer(-1) }, { "textString", "Thank you for reading our book" } };
}

class SimpleResourceBundle extends ResourceBundle {

  private String keys = "AMMessage PMMessage";

  public Object handleGetObject(String key) {
    if (key.equals("AMMessage"))
      return "Good morning";
    if (key.equals("PMMessage"))
      return "Good evening";

    return null;
  }

  public Enumeration getKeys() {
    StringTokenizer keyTokenizer = new StringTokenizer(keys);

    return keyTokenizer;
  }
}

class SimpleResourceBundle_it extends SimpleResourceBundle {

  public Object handleGetObject(String key) {
    if (key.equals("AMMessage"))
      return "Buona mattina";
    if (key.equals("PMMessage"))
      return "Buona sera";

    return null;
  }
}

   
  








Related examples in the same category