AccessorType patch

View: New views
2 Messages — Rating Filter:   Alert me  

AccessorType patch

by jpkutner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I needed a feature from Simple XML that was not provided so I added it
to the sources and built myself.  I would like to submit my patch back
to the project.

This new feature is similar to the @XmlAccessorType annotation in JAXB:
https://jaxb.dev.java.net/nonav/2.1/docs/api/javax/xml/bind/annotation/XmlAccessorType.html

When you add this annotation to a class it automatically picks up the
Java Bean properties (getters and setters) as @Elements or
@ElementLists.  This has been important to my application because each
of my classes has tens of properties, and I have hundreds of classes.
The feature still allows you to override the default annotation values
by explicitly annotating certain properties.  See my example of the
kinds of things allowed.

I would very much like to see this patch make its way into the trunk.
So I am willing to rework it in order to better fit the overall vision
of the project.  Please let me know what is needed to make this
happen.

Thanks,

Joe Kutner

@Root
@AccessorType(AccessType.PROPERTY)
public class Foobar {
  private String one;
  private List<String> two;
  private int three;
  private Date four;

  // no need to annotate this
  public String getOne() {  ...  }

  // no need to annotate this
  public void setOne(String one) {  ...  }

  // no need to annotate this
  public List<String> getTwo() {  ...  }

  // no need to annotate this
  public void setTwo(List<String> two) {  ...  }

  @Transient
  public void getThree() { ... }

  @Transient
  public void setThree(int three) { ...}

  @Element(name = "mydate")
  public Date getFour() { ... }

  @Element(name = "mydate")
  public void setFour(Date four) { ...}
}


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

accessortype.patch (36K) Download Attachment

Re: AccessorType patch

by Niall Gallagher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cool, thanks, Ill make sure to add this feature. Seems like a good addition.

--- On Thu, 8/13/09, Joe Kutner <jpkutner@...> wrote:

> From: Joe Kutner <jpkutner@...>
> Subject: [Simple-support] AccessorType patch
> To: simple-support@...
> Date: Thursday, August 13, 2009, 12:08 PM
> Hello,
>
> I needed a feature from Simple XML that was not provided so
> I added it
> to the sources and built myself.  I would like to
> submit my patch back
> to the project.
>
> This new feature is similar to the @XmlAccessorType
> annotation in JAXB:
> https://jaxb.dev.java.net/nonav/2.1/docs/api/javax/xml/bind/annotation/XmlAccessorType.html
>
> When you add this annotation to a class it automatically
> picks up the
> Java Bean properties (getters and setters) as @Elements or
> @ElementLists.  This has been important to my
> application because each
> of my classes has tens of properties, and I have hundreds
> of classes.
> The feature still allows you to override the default
> annotation values
> by explicitly annotating certain properties.  See my
> example of the
> kinds of things allowed.
>
> I would very much like to see this patch make its way into
> the trunk.
> So I am willing to rework it in order to better fit the
> overall vision
> of the project.  Please let me know what is needed to
> make this
> happen.
>
> Thanks,
>
> Joe Kutner
>
> @Root
> @AccessorType(AccessType.PROPERTY)
> public class Foobar {
>   private String one;
>   private List<String> two;
>   private int three;
>   private Date four;
>
>   // no need to annotate this
>   public String getOne() {  ...  }
>
>   // no need to annotate this
>   public void setOne(String one) {  ...  }
>
>   // no need to annotate this
>   public List<String> getTwo() {  ... 
> }
>
>   // no need to annotate this
>   public void setTwo(List<String> two) { 
> ...  }
>
>   @Transient
>   public void getThree() { ... }
>
>   @Transient
>   public void setThree(int three) { ...}
>
>   @Element(name = "mydate")
>   public Date getFour() { ... }
>
>   @Element(name = "mydate")
>   public void setFour(Date four) { ...}
> }
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal
> Reports 2008 30-Day
> trial. Simplify your report design, integration and
> deployment - and focus on
> what you do best, core application coding. Discover what's
> new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Simple-support@...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>


     

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support