|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||||
@Retention(value=SOURCE)
@Target(value={FIELD,LOCAL_VARIABLE})
public @interface Msg
Denotes that a final String variable is a Message Definition together with its doc
comment (can be omitted when referencing another so defined msg) and constant
value. The constant value is the msgID, and
the doc comment is the default content
of that Message.
But as a standard came with Java 6.0, JSR 269: Pluggable Annotation
Processing API does NOT model local variables yet. Even worse, it
doesn't provide means to obtain line number information of Java elements. Due
to its limitations, the @Msg Annotation Processor depends on SUN's
implementation of javac (the Compiler
Tree API in fact), and a message has to be defined as a
final String field of the class. We are looking forward JSR
269 and its successors will encount local variables as well, at least provide
line number information in a pure Java way, such we can produce more meanful
source position information for localizable messages.
However, Ableverse Platform provides an open source, but not supported patch
to SUN javac, which can be downloaded from
http://www.ableverse.org/opensource/javac6patch.zip . With this patch,
you will be able to define localizable messages with
final String local variables, with the limitation that their
location and msgID must be literal string
constants (can't be constant references). But this patch is not officially
supported, use it for your own sake at your own risk.
Variables annotated with this annotation should be of type
String and have the final modifer, or
compile time errors will be generated. If the variable is a class field (This
will be true until JSR 269 supports local variables, or you are compiling
using a patched SUN javac), normally SUN javac will optimize it to be
static, but an explicit static modifier is
advised, to avoid unnecessary instance fields.
av.msg,
Messager| Optional Element Summary | |
|---|---|
String |
location
Specifies name of the Message Bundle which manages the XML resources to contain this message. |
public abstract String location
And dot(".") style notation is also supported to specify parent levels, such that "." means to store this message at current class' msg bundle, and ".." meas to store at the current package's, and "..." means parent package of current package.
The default value is ".", which selects the current class' msg bundle.
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||||