OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

sca-j message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: JAVA-139: Discussion

I haven't had any reply from Vamsi to the email I sent him about this.

The main problem I see is what type to use for the new defaultValue
attribute on the @Property annotation.  @Property can to applied to
any Java type, which means that the default value can also be of any
Java type.

It's not possible to use a type of java.lang.Object for an attribute
of an annotation.  One possible approach would be to define separate
defaultValueXXX attributes for each Java primitive type and String.
With this approach, the user would have to write code like:
   @Property defaultValueInt(10)
   protected int discountRate;
We would also need defaultValueXXX attributes for arrays of these types.

This takes care of simple-valued properties, but it doesn't provide
any way to provide a default for a complex-valued property that is
represented in Java by a class using JAXB mappings.

For the complex-valued property case (including enums), it would be
possible to use an XML string to represent the default value.  We
could support this by defining a defaultValueXML attribute.

With this approach we would need the following new attributes:
   boolean defaultValueBoolean() default false;
   byte defaultValueByte() default 0;
   char defaultValueChar() default ' ';
   double defaultValueDouble() default 0.0d;
   float defaultValueFloat() default 0.0f;
   int defaultValueInt() default 0;
   long defaultValueLong() default 0;
   short defaultValueShort() default 0;
   String defaultValueString() default "";
   boolean[] defaultValueBooleanArray() default {};
   byte[] defaultValueByteArray() default {};
   char[] defaultValueCharArray() default {};
   double[] defaultValueDoubleArray() default {};
   float[] defaultValueFloatArray() default {};
   int[] defaultValueIntArray() default {};
   long[] defaultValueLongArray() default {};
   short[] defaultValueShortArray() default {};
   String[] defaultValueStringArray() default {};
   String defaultValueXML() default "";

Comments, suggestions?


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]