MessageBundle.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 package com.generalrobotix.ui.util;
11 
12 import java.util.Locale;
13 import java.util.ResourceBundle;
15 
16 public class MessageBundle {
17  private static MessageBundle this_;
18  protected static ResourceBundle messages_;
19 
20  private MessageBundle() {
21  messages_ =
22  ResourceBundle.getBundle("com.generalrobotix.messages", Locale.US);
23  }
24 
25  private MessageBundle(Locale locale) {
26  messages_ = ResourceBundle.getBundle("com.generalrobotix.messages", locale);
27  }
28 
29  public static final void setLocale(Locale locale) {
30  if (this_ == null) {
31  this_ = new MessageBundle(locale);
32  } else {
33  messages_ =
34  ResourceBundle.getBundle("com.generalrobotix.messages", locale);
35  }
36  }
37 
38  public static final void setLocale(String language, String country) {
39  if (this_ == null) {
40  this_ = new MessageBundle(new Locale(language, country));
41  } else {
42  messages_ =
43  ResourceBundle.getBundle(
44  "com.generalrobotix.messages",
45  new Locale(language, country)
46  );
47  }
48  }
49 
50  public static final String get(String key) {
51  if (this_ == null) {
52  this_ = new MessageBundle(Locale.getDefault());
53  }
54  try{
55  return messages_.getString(key);
56  }catch(Exception e){
57  try{
58  GrxDebugUtil.println("not found " + key + "in messages_(defaultlocale).properties");
59  return ResourceBundle.getBundle("com.generalrobotix.messages", Locale.US).getString(key);
60  }catch(Exception e1){
61  GrxDebugUtil.println("not found " + key + "in messages_en.properties");
62  return "";
63  }
64  }
65  }
66 
67  public static final ResourceBundle getMessages() { return messages_; }
68 }
#define null
our own NULL pointer
Definition: IceTypes.h:57
static final void setLocale(Locale locale)
static final void setLocale(String language, String country)
static final ResourceBundle getMessages()


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:24