/** * Initializes the internationalization fields declared on the supplied class. Internationalization fields must be public, * static, not final, and of type <code>I18n</code>. The supplied class must not be an interface (of course), but has no * restrictions as to what class it may extend or what interfaces it must implement. * * @param i18nClass A class declaring one or more public, static, non-final fields of type <code>I18n</code>. */ public static void initialize( Class<?> i18nClass ) { validateI18nClass(i18nClass); synchronized (i18nClass) { // Find all public static non-final String fields in the supplied class and instantiate an I18n object for each. try { for (Field fld : i18nClass.getDeclaredFields()) { // Ensure field is of type I18n if (fld.getType() == I18n.class) { initializeI18nField(fld); } } cleanupPreviousProblems(i18nClass); } catch (IllegalAccessException err) { // If this happens, it will happen with the first field visited in the above loop throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass)); } } }
/** * Initializes the internationalization fields declared on the supplied class. Internationalization fields must be public, * static, not final, and of type <code>I18n</code>. The supplied class must not be an interface (of course), but has no * restrictions as to what class it may extend or what interfaces it must implement. * * @param i18nClass A class declaring one or more public, static, non-final fields of type <code>I18n</code>. */ public static void initialize( Class<?> i18nClass ) { validateI18nClass(i18nClass); synchronized (i18nClass) { // Find all public static non-final String fields in the supplied class and instantiate an I18n object for each. try { for (Field fld : i18nClass.getDeclaredFields()) { // Ensure field is of type I18n if (fld.getType() == I18n.class) { initializeI18nField(fld); } } cleanupPreviousProblems(i18nClass); } catch (IllegalAccessException err) { // If this happens, it will happen with the first field visited in the above loop throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass)); } } }
/** * Initializes the internationalization fields declared on the supplied class. Internationalization fields must be public, * static, not final, and of type <code>I18n</code>. The supplied class must not be an interface (of course), but has no * restrictions as to what class it may extend or what interfaces it must implement. * * @param i18nClass A class declaring one or more public, static, non-final fields of type <code>I18n</code>. */ public static void initialize( Class<?> i18nClass ) { validateI18nClass(i18nClass); synchronized (i18nClass) { // Find all public static non-final String fields in the supplied class and instantiate an I18n object for each. try { for (Field fld : i18nClass.getDeclaredFields()) { // Ensure field is of type I18n if (fld.getType() == I18n.class) { initializeI18nField(fld); } } cleanupPreviousProblems(i18nClass); } catch (IllegalAccessException err) { // If this happens, it will happen with the first field visited in the above loop throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass)); } } }