public static String getLocalizedMessage(String key, Object... args) { return getLocalizedMessage(key, Locale.getDefault(), args); }
public static String getLocalizedMessage(String key, Locale locale) { Object message = getResourceBundleObject(key, locale); if (message == null) { return "Message with key:" + key + " and locale: " + locale + " not found."; } return message.toString(); }
private static void load(Class<? extends NLS> clazz) { final Field[] fieldArray = clazz.getDeclaredFields(); // build a map of field names to Field objects final int len = fieldArray.length; Map<String, Field> fields = new HashMap<>(len * 2); for (int i = 0; i < len; i++) { fields.put(fieldArray[i].getName(), fieldArray[i]); loadfieldValue(fieldArray[i], clazz); } }
private static void loadfieldValue(Field field, Class<? extends NLS> clazz) { int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC; int MOD_MASK = MOD_EXPECTED | Modifier.FINAL; if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED) return; // Set a value for this empty field. try { field.set(null, field.getName()); validateMessage(field.getName(), clazz); } catch (IllegalArgumentException | IllegalAccessException e) { // should not happen } }
/** * Initialize a given class with the message bundle Keys Should be called from * a class that extends NLS in a static block at class load time. * * @param bundleName * Property file with that contains the message bundle * @param clazz * where constants will reside */ protected static void initializeMessages(String bundleName, Class<? extends NLS> clazz) { try { load(clazz); if (!bundles.containsKey(bundleName)) bundles.put(bundleName, clazz); } catch (Throwable e) { // ignore all errors and exceptions // because this function is supposed to be called at class load time. } }
private static void loadfieldValue(Field field, Class<? extends NLS> clazz) { int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC; int MOD_MASK = MOD_EXPECTED | Modifier.FINAL; if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED) return; // Set a value for this empty field. try { field.set(null, field.getName()); validateMessage(field.getName(), clazz); } catch (IllegalArgumentException | IllegalAccessException e) { // should not happen } }
/** * Initialize a given class with the message bundle Keys Should be called from * a class that extends NLS in a static block at class load time. * * @param bundleName * Property file with that contains the message bundle * @param clazz * where constants will reside */ protected static void initializeMessages(String bundleName, Class<? extends NLS> clazz) { try { load(clazz); if (!bundles.containsKey(bundleName)) bundles.put(bundleName, clazz); } catch (Throwable e) { // ignore all errors and exceptions // because this function is supposed to be called at class load time. } }
public static String getLocalizedMessage(String key) { return getLocalizedMessage(key, Locale.getDefault()); }
private static void load(Class<? extends NLS> clazz) { final Field[] fieldArray = clazz.getDeclaredFields(); // build a map of field names to Field objects final int len = fieldArray.length; Map<String, Field> fields = new HashMap<>(len * 2); for (int i = 0; i < len; i++) { fields.put(fieldArray[i].getName(), fieldArray[i]); loadfieldValue(fieldArray[i], clazz); } }
public static String getLocalizedMessage(String key, Locale locale) { Object message = getResourceBundleObject(key, locale); if (message == null) { return "Message with key:" + key + " and locale: " + locale + " not found."; } return message.toString(); }
public static String getLocalizedMessage(String key) { return getLocalizedMessage(key, Locale.getDefault()); }
public static String getLocalizedMessage(String key, Object... args) { return getLocalizedMessage(key, Locale.getDefault(), args); }
public static String getLocalizedMessage(String key, Locale locale, Object... args) { String str = getLocalizedMessage(key, locale); if (args.length > 0) { str = new MessageFormat(str, Locale.ROOT).format(args); } return str; }
public static String getLocalizedMessage(String key, Locale locale, Object... args) { String str = getLocalizedMessage(key, locale); if (args.length > 0) { str = new MessageFormat(str, Locale.ROOT).format(args); } return str; }
@Override public final void add(QueryNode child) { if (isLeaf() || this.clauses == null || child == null) { throw new IllegalArgumentException(NLS .getLocalizedMessage(QueryParserMessages.NODE_ACTION_NOT_SUPPORTED)); } this.clauses.add(child); ((QueryNodeImpl) child).setParent(this); }
@Override public final void add(QueryNode child) { if (isLeaf() || this.clauses == null || child == null) { throw new IllegalArgumentException(NLS .getLocalizedMessage(QueryParserMessages.NODE_ACTION_NOT_SUPPORTED)); } this.clauses.add(child); ((QueryNodeImpl) child).setParent(this); }
@Override public final void add(List<QueryNode> children) { if (isLeaf() || this.clauses == null) { throw new IllegalArgumentException(NLS .getLocalizedMessage(QueryParserMessages.NODE_ACTION_NOT_SUPPORTED)); } for (QueryNode child : children) { add(child); } }
@Override public final void add(List<QueryNode> children) { if (isLeaf() || this.clauses == null) { throw new IllegalArgumentException(NLS .getLocalizedMessage(QueryParserMessages.NODE_ACTION_NOT_SUPPORTED)); } for (QueryNode child : children) { add(child); } }
@Override public String getLocalizedMessage(Locale locale) { return NLS.getLocalizedMessage(getKey(), locale, getArguments()); }
@Override public String getLocalizedMessage(Locale locale) { return NLS.getLocalizedMessage(getKey(), locale, getArguments()); }