I need to automatically generate java beans from some kind of declarative
definition. One immediate approach is to define an XML Schema and compile
it using JAXB, though in fact I'll never use XML and, so, JAXB marshalling
and unmarshalling capabilities. On the contrary, I must generate a String
composed of the concatenated element values contained by the bean and split
Strings to fill the bean values. For the first functionality,
- Can JAXB generate toString() methods? If so, do they perform more or less
the value concatenation I've talked about? If no toString() methods can be
generated, it could be interesting for future JAXB versions.
- Does anyone know about some tool which can perform it?
For the second functionality, the approach I've thought about is to
retrieve metainformation such as value lengths and use it to split the
String correctly (of course, with restrictions)
- Is it possible to retrieve such information about the restrictions which
apply to every bean attribute (such as length for strings, for example)?. I
know the possibility of using XSOM to retrieve this information directly
from the schema, but looks complicated and, probably, low performing. On
the other hand, it's obvious that such information must be included in the
generated beans in order to be able to perform runtime validation. If this
possibility doesn't exist, I suggest to consider it for future versions.
- If not, are there other (may be better) ways than XSOM to do it?
- Does anyone know about other tools (not JAXB), may be not related with
XML which allow to declare data and automatically generate beans from the
declaration?
I know these are a lot of questions, not always directly related to JAXB.
Thank you very much in advance,
Juan