public final class C10N extends Object
Utility class for generating implementations of c10n message interfaces
annotated with @C10NMessages.
Usage similar to logger creating in frameworks like log4j or slf4j.
Sample usage:
-- MyMessages.java
import c10n.C10NMessages;
@C10NMessages
public interface MyMessages {
@C10NDef("Hello, {0}")
String title(String who);
@C10NDef("OK")
String ok();
@C10NDef("Cancel")
String cancel();
}
-- MyApplication.java
import c10n.C10N;
import javax.swing.*;
class MyApplication {
private static final MyMessages msg = C10N.get(MyMessages.class);
public static void main(String[] args){
JFrame frame = new JFrame(msg.title("World"));
JButton okButton = new JButton(msg.ok());
JButton cancelButton = new JButton(msg.cancel());
...
}
}
Implementation of MyMessages class is generated and will return
messages from configured bundle (TODO configuration).
| Modifier and Type | Field and Description |
|---|---|
static Locale |
FALLBACK_LOCALE
Internal locale object used as a fallback when current locale does not
match any of the user-defined locale mappings.
|
| Constructor and Description |
|---|
C10N() |
| Modifier and Type | Method and Description |
|---|---|
static ConfiguredC10NModule |
configure(C10NConfigBase conf) |
static C10NMsgFactory |
createMsgFactory(ConfiguredC10NModule configuredModule) |
static <T> T |
get(Class<T> c10nInterface) |
static <T> T |
get(Class<T> c10nInterface,
Locale locale) |
static ClassLoader |
getProxyClassloader()
Get the instance of the classloader currently used for loading c10n-interface proxies.
|
static ConfiguredC10NModule |
getRootConfiguredModule() |
static C10NMsgFactory |
getRootFactory() |
static void |
setProxyClassloader(ClassLoader classloader)
Overrides the classloader used for loading c10n-interface proxies.
|
static void |
setRootFactory(C10NMsgFactory newRoot) |
public static final Locale FALLBACK_LOCALE
public static ConfiguredC10NModule getRootConfiguredModule()
public static C10NMsgFactory getRootFactory()
public static void setRootFactory(C10NMsgFactory newRoot)
public static <T> T get(Class<T> c10nInterface)
public static ConfiguredC10NModule configure(C10NConfigBase conf)
public static C10NMsgFactory createMsgFactory(ConfiguredC10NModule configuredModule)
public static void setProxyClassloader(ClassLoader classloader)
Overrides the classloader used for loading c10n-interface proxies. This maybe useful in the context of hot-swapping enabled classloaders, like the one for Play framework 2.0
Overriding should be done before any calls to get(Class), to be effective.
By default, the classloader of Object.getClass() class is used.
classloader - the classloader to use for loading c10n-interface proxies (not-null)public static ClassLoader getProxyClassloader()
Copyright © 2013. All Rights Reserved.