[Simple-support] Transform annotations, simple class names, JSON output, and more
Brought to you by:
niallg
|
From: Paul J. <pa...@pa...> - 2014-02-11 10:09:52
|
Hi,
I've just started using Simple and it looks like it's exactly what I need.
I have been using XStream extensively, and investigated JAX-B but Simple
seems to meet my needs better.
However, I have a few questions!
1) Can I strip the value element on an ElementMap?
If I have a field like this:
@ElementMap(inline=true, attribute=true, entry="sink", key="type")
Map<String,VarInfo> sinks = new HashMap<String,VarInfo>();
It produces XML like this:
<sink type="xss">
<varInfo>
<varInfoItem>
<source class="uk.co.pentest.srcscan.analyse.RouteEnd$Field"
field="test::field"/>
</varInfoItem>
</varInfo>
</field>
I would like to remove the <varInfo> tag - so it's children go directly
inside the <sink> tag.
2) Can Simple generate short names in class attributes?
If we look at the source tag above, it includes the full class name for the
class. I would like it to be the simple class name: Field. Is this
possible? I don't need to read this XML; only generate it.
I am aware of ElementUnion however, this does not suit my needs. The
problem is that I have multiple polymorphic fields in the class (source and
destination) and there are a fair number of polymorphic types. To make this
work with ElementUnion I'd need many many lines of annotations, which would
kill the benefit of Simple.
3) Can I specify Transformers using an annotation?
I am using RegistryMatcher and my transformer is working correctly. But I
have to have a bit of the code where I specify all the transformers. Is it
possible to use an annotation instead?
What I have:
matcher.bind(MethodDescriptor.class,
MethodDescriptor.XmlTransform.class);
What I'd like:
@Transformer(XmlTransform.class)
class MethodDescriptor {
...
4) Can Simple generate JSON output?
I can live with using a beta quality plugin. And I only need to generate
JSON, never read it. If there's no existing plugin for this, I will look at
writing one, and any pointers would be appreciated.
Any help would be greatly appreciated! All the best,
Paul
|