• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Bean standards [FYI not a question]

 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
K&B book discusses about java bean standards in first chapter for
a) Simple properties
b) Boolean properties
c) Events
But it does not discusses about indexed properties {arrays} , so here are the conventions
If a bean has a indexed property named say Foo[] foos; then the valid getter and setter method signatures are as follows
a) public Foo[] getFoos();
b) public void setFoos( Foo[] var) ;
c) public Foo getFoos(int index);
d) public void setFoos( int index, Foo var);
Note, getFoos() and setFoos() are overloaded, one returns the indexed property and the other returns a specific Foo object from the array given the index and note that index must be the first argument to setFoos().

Also Events :
The event source must extend java.util.EventListner
So if you have an event named ActionListner, then the ActionListner class must extend java.util.EventListner and the method conventions are same as explained in the book.

Read javabean spec Section 8.3.
Thanks
Deepak
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,

Thanks for the info!

I do want to make one comment, and that is that the conventions that you discuss are not included in the actual exam. So, it's good information in general, but if you're focused on studying for the exam, you can skip it for now.

It's important for everyone to remember that the exam does NOT cover the entire Java spec. If you study the spec., you can find tons and tons of details that aren't in our books, or in any other books, or in any mock exams. That's because we don't want people who are focused on the exam to study stuff that outside the scope of the exam

My request would be that when you share info like this you mention whether or not it's in scope so that people will know where to focus their valuable time.

Thanks,

Bert
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bert,
I was confused over java method naming conventions for boolean properties that whether getStopped() was a java bean convention, thats when i stumbled into java method naming conventions for indexed properties in bean specs. I wasn't sure if they were included for the exam and i missed asking whether indexed property naming conventions on exam or not.
I will make sure i will be very much exam oriented next time i share any
information if any because am also preparing for my exam
Thanks
Deepak
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem at all Deepak,

The only way to find out is to ask
 
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic