Re: [Simple-support] null variables and suppressing empty tags
Brought to you by:
niallg
|
From: Erez L. <er...@es...> - 2011-09-22 13:16:41
|
Thanks! I was also thinking about plugging in a different/custom serializer
here:
private static final Serializer serializer = new Persister(new
AnnotationStrategy());
Does this make any sense or am I barking up the wrong tree?
On Thu, Sep 22, 2011 at 6:20 AM, Niall Gallagher
<gal...@ya...>wrote:
> Hi,
>
> I think for this a change is required. Currently the @Path is required
> regardless of whether the elements are null or not.
>
> I will take a look at adding something like this.
>
> Niall
>
>
> --- On *Wed, 21/9/11, Erez Lirov <er...@es...>* wrote:
>
>
> From: Erez Lirov <er...@es...>
> Subject: Re: [Simple-support] null variables and suppressing empty tags
> To: "Niall Gallagher" <gal...@ya...>
> Cc: "James Oltmans" <Jam...@ip...>, "
> sim...@li..." <
> sim...@li...>
> Received: Wednesday, 21 September, 2011, 6:10 AM
>
>
> Oops. I'm sorry. That was supposed to be @Path("To") I think I was
> switching things out while testing and copying. Here's the current copy of
> the code. I just executed and it produced:
> <ContinuityOfCareRecord>
> <To/>
> </ContinuityOfCareRecord>
>
> ---------------
>
> import org.junit.Before;
> import org.junit.Test;
> import org.simpleframework.xml.Element;
> import org.simpleframework.xml.Path;
> import org.simpleframework.xml.Root;
>
> import com.espoc.vrclcommon.util.XmlUtil;
>
> public class CcrTest {
>
> @Root(name = "ContinuityOfCareRecord")
> static class Test1 {
> @Element(name = "ActorLink", required = false)
> @Path("To")
> protected CcrDocActorLink toLink;
> }
>
> @Before
> public void setUp() throws Exception {
> }
>
> @Test
> public void test() throws Exception {
> // CcrDoc doc = sample();
> Test1 doc = new Test1();
> System.out.println(XmlUtil.getAsString(doc));
> }
> }
>
> public class XmlUtil {
> private static final Serializer serializer = new Persister(new
> AnnotationStrategy());
>
> public static String getAsString(Object obj) throws Exception {
> ByteArrayOutputStream b = new ByteArrayOutputStream();
> serializer.write(obj, b);
> return b.toString();
> }
> }
>
> On Wed, Sep 21, 2011 at 4:40 AM, Niall Gallagher <
> gal...@ya... <http://mc/compose?to=...@ya...>
> > wrote:
>
> The below annotated class will not generate the XML you provided. Can you
> provide a proper example of what you are doing.
>
> --- On *Tue, 20/9/11, Erez Lirov <er...@es...<http://mc/compose?to...@es...>
> >* wrote:
>
>
> From: Erez Lirov <er...@es... <http://mc/compose?to...@es...>>
> Subject: Re: [Simple-support] null variables and suppressing empty tags
> To: "James Oltmans" <Jam...@ip...<http://mc/compose?to=...@ip...>
> >
> Cc: "sim...@li...<http://mc/compose?to=...@li...>"
> <sim...@li...<http://mc/compose?to=...@li...>
> >
> Received: Tuesday, 20 September, 2011, 12:05 PM
>
>
> Doesn't look like the @Path annotation accepts required=false. It looks
> like @Path only accepts one parameter, the path string...
>
> On Tue, Sep 20, 2011 at 11:52 AM, James Oltmans <Jam...@ip...<http://mc/compose?to=...@ip...>
> > wrote:
>
> Set required = false for the To element****
>
> ** **
>
> *From:* Erez Lirov [mailto:er...@es...<http://mc/compose?to...@es...>]
>
> *Sent:* Tuesday, September 20, 2011 7:25 AM
> *To:* sim...@li...<http://mc/compose?to=...@li...>
> *Subject:* [Simple-support] null variables and suppressing empty tags****
>
> ** **
>
> I have an annotated class that has a null field like this:****
>
> ** **
>
> @Root(name = "ContinuityOfCareRecord")****
>
> class Test1 {****
>
> @Element(name = "ActorID", required = false)****
>
> @Path("Patient")****
>
> protected String patientId;****
>
> }****
>
> ** **
>
> generating the XML gives:****
>
> <ContinuityOfCareRecord>****
>
> <To/>****
>
> </ContinuityOfCareRecord>****
>
> ** **
>
> Is there any way to automatically suppress the <To/> tag since there are no
> values under it?****
>
> ** **
>
> Thanks!****
>
>
>
>
> --
> The materials in this e-mail are private, may contain Protected Health
> Information as defined by the Health Insurance Portability and Accounting
> Act of 1986 (as codified at 42 U.S.C. 1320d through d-8), and are intended
> only for the use of the individual(s) named above. If you are not the
> intended recipient of this e-mail, or the employee or agent responsible for
> delivering this to the intended recipient, you are hereby notified that any
> unauthorized use, disclosure, copying, distribution or the taking of any
> action in reliance on the contents of this information is strictly
> prohibited. If you have received this e-mail in error, please immediately
> notify us by telephone at 877-753-4286 or notify us by e-mail at
> hel...@ve... <http://mc/compose?to=...@ve...>. Thank
> you.
>
> -----Inline Attachment Follows-----
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...<http://mc/compose?to=...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
>
> --
> The materials in this e-mail are private, may contain Protected Health
> Information as defined by the Health Insurance Portability and Accounting
> Act of 1986 (as codified at 42 U.S.C. 1320d through d-8), and are intended
> only for the use of the individual(s) named above. If you are not the
> intended recipient of this e-mail, or the employee or agent responsible for
> delivering this to the intended recipient, you are hereby notified that any
> unauthorized use, disclosure, copying, distribution or the taking of any
> action in reliance on the contents of this information is strictly
> prohibited. If you have received this e-mail in error, please immediately
> notify us by telephone at 877-753-4286 or notify us by e-mail at
> hel...@ve... <http://mc/compose?to=...@ve...>. Thank
> you.
>
>
--
The materials in this e-mail are private, may contain Protected Health
Information as defined by the Health Insurance Portability and Accounting
Act of 1986 (as codified at 42 U.S.C. 1320d through d-8), and are intended
only for the use of the individual(s) named above. If you are not the
intended recipient of this e-mail, or the employee or agent responsible for
delivering this to the intended recipient, you are hereby notified that any
unauthorized use, disclosure, copying, distribution or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this e-mail in error, please immediately
notify us by telephone at 877-753-4286 or notify us by e-mail at
hel...@ve.... Thank you.
|