/** * Constructor. * * <p> * A shortcut for calling <code>new MessageBundle(forClass, bundlePath)</code>. * * @param forClass The class * @param bundlePath The location of the resource bundle. * @return A new message bundle belonging to the class. */ public static final MessageBundle create(Class<?> forClass, String bundlePath) { return new MessageBundle(forClass, bundlePath); }
/** * Constructor. * * <p> * A shortcut for calling <code>new MessageBundle(forClass, bundlePath)</code>. * * @param forClass The class * @param bundlePath The location of the resource bundle. * @return A new message bundle belonging to the class. */ public static final MessageBundle create(Class<?> forClass, String bundlePath) { return new MessageBundle(forClass, bundlePath); }
/** * Constructor. * * <p> * A shortcut for calling <code>new MessageBundle(forClass, bundlePath)</code>. * * @param forClass The class * @param bundlePath The location of the resource bundle. * @return A new message bundle belonging to the class. */ public static final MessageBundle create(Class<?> forClass, String bundlePath) { return new MessageBundle(forClass, bundlePath); }
/** * 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; }
if (! r.messages().isEmpty()) { if (msgs == null) msgs = new MessageBundle(c, r.messages()); else msgs.addSearchPath(c, r.messages()); msgs = new MessageBundle(this.getClass(), ""); if (clientVersionHeader.isEmpty()) clientVersionHeader = "X-Client-Version";