/** * Returns all keys in this resource bundle with the specified prefix. * * @param prefix The prefix. * @return The set of all keys in the resource bundle with the prefix. */ public Set<String> keySet(String prefix) { Set<String> set = new HashSet<>(); for (String s : keySet()) { if (s.equals(prefix) || (s.startsWith(prefix) && s.charAt(prefix.length()) == '.')) set.add(s); } return set; }
/** * Returns all keys in this resource bundle with the specified prefix. * * @param prefix The prefix. * @return The set of all keys in the resource bundle with the prefix. */ public Set<String> keySet(String prefix) { Set<String> set = new HashSet<>(); for (String s : keySet()) { if (s.equals(prefix) || (s.startsWith(prefix) && s.charAt(prefix.length()) == '.')) set.add(s); } return set; }
/** * Returns all keys in this resource bundle with the specified prefix. * * @param prefix The prefix. * @return The set of all keys in the resource bundle with the prefix. */ public Set<String> keySet(String prefix) { Set<String> set = new HashSet<>(); for (String s : keySet()) { if (s.equals(prefix) || (s.startsWith(prefix) && s.charAt(prefix.length()) == '.')) set.add(s); } return set; }
/** * Returns the resource bundle for the specified locale. * * @param locale The client locale. * @return The resource bundle for the specified locale. Never <jk>null</jk>. */ public MessageBundle getBundle(Locale locale) { MessageBundle mb = localizedBundles.get(locale); if (mb != null) return mb; mb = new MessageBundle(forClass, bundlePath, locale); List<MessageBundle> l = new ArrayList<>(searchBundles.size()-1); for (int i = 1; i < searchBundles.size(); i++) { MessageBundle srb = searchBundles.get(i); srb = new MessageBundle(srb.forClass, srb.bundlePath, locale); l.add(srb); mb.allKeys.addAll(srb.keySet()); } mb.searchBundles.addAll(l); localizedBundles.putIfAbsent(locale, mb); return localizedBundles.get(locale); } }
/** * Returns the resource bundle for the specified locale. * * @param locale The client locale. * @return The resource bundle for the specified locale. Never <jk>null</jk>. */ public MessageBundle getBundle(Locale locale) { MessageBundle mb = localizedBundles.get(locale); if (mb != null) return mb; mb = new MessageBundle(forClass, bundlePath, locale); List<MessageBundle> l = new ArrayList<>(searchBundles.size()-1); for (int i = 1; i < searchBundles.size(); i++) { MessageBundle srb = searchBundles.get(i); srb = new MessageBundle(srb.forClass, srb.bundlePath, locale); l.add(srb); mb.allKeys.addAll(srb.keySet()); } mb.searchBundles.addAll(l); localizedBundles.putIfAbsent(locale, mb); return localizedBundles.get(locale); } }
/** * Returns the resource bundle for the specified locale. * * @param locale The client locale. * @return The resource bundle for the specified locale. Never <jk>null</jk>. */ public MessageBundle getBundle(Locale locale) { MessageBundle mb = localizedBundles.get(locale); if (mb != null) return mb; mb = new MessageBundle(forClass, bundlePath, locale); List<MessageBundle> l = new ArrayList<>(searchBundles.size()-1); for (int i = 1; i < searchBundles.size(); i++) { MessageBundle srb = searchBundles.get(i); srb = new MessageBundle(srb.forClass, srb.bundlePath, locale); l.add(srb); mb.allKeys.addAll(srb.keySet()); } mb.searchBundles.addAll(l); localizedBundles.putIfAbsent(locale, mb); return localizedBundles.get(locale); } }
/** * Add another bundle path to this resource bundle. * * <p> * Order of property lookup is first-to-last. * * <p> * This method must be called from the same thread as the call to the constructor. * This eliminates the need for synchronization. * * @param forClass The class using this resource bundle. * @param bundlePath The bundle path. * @return This object (for method chaining). */ public MessageBundle addSearchPath(Class<?> forClass, String bundlePath) { assertSameThread(creationThreadId, "This method can only be called from the same thread that created the object."); MessageBundle srb = new MessageBundle(forClass, bundlePath); if (srb.rb != null) { allKeys.addAll(srb.keySet()); searchBundles.add(srb); } return this; }
/** * Add another bundle path to this resource bundle. * * <p> * Order of property lookup is first-to-last. * * <p> * This method must be called from the same thread as the call to the constructor. * This eliminates the need for synchronization. * * @param forClass The class using this resource bundle. * @param bundlePath The bundle path. * @return This object (for method chaining). */ public MessageBundle addSearchPath(Class<?> forClass, String bundlePath) { assertSameThread(creationThreadId, "This method can only be called from the same thread that created the object."); MessageBundle srb = new MessageBundle(forClass, bundlePath); if (srb.rb != null) { allKeys.addAll(srb.keySet()); searchBundles.add(srb); } return this; }
/** * Add another bundle path to this resource bundle. * * <p> * Order of property lookup is first-to-last. * * <p> * This method must be called from the same thread as the call to the constructor. * This eliminates the need for synchronization. * * @param forClass The class using this resource bundle. * @param bundlePath The bundle path. * @return This object (for method chaining). */ public MessageBundle addSearchPath(Class<?> forClass, String bundlePath) { assertSameThread(creationThreadId, "This method can only be called from the same thread that created the object."); MessageBundle srb = new MessageBundle(forClass, bundlePath); if (srb.rb != null) { allKeys.addAll(srb.keySet()); searchBundles.add(srb); } return this; }
for (String key : msgs.keySet(prefix)) { if (key.length() > prefix.length()) { String value = vr.resolve(msgs.getString(key));
for (String key : msgs.keySet(prefix)) { if (key.length() > prefix.length()) { String value = vr.resolve(msgs.getString(key));