As i needed some practice in emacs-lisp:
here is the sample code needed to respect the java bean spec in the get-set method
wizard :)
(defcustom jde-gen-get-set-var-template
'(
"'n>"
"(P \"Variable type: \" type) \" \""
"(P \"Variable name: \" name) \";\" 'n> 'n>"
"\"/**\" 'n>"
"\"* Get the value of \" (s name) \".\" 'n>"
"\"* @return value of \" (s name) \".\" 'n>"
"\"*/\" 'n>"
"\"public \" (s type)"
"(if (string= \"boolean\" (jde-gen-lookup-named 'type) ) "
"\" is\" "
"\" get\" ) "
"(jde-gen-init-cap (jde-gen-lookup-named 'name))"
"\"() {return \" (s name) \";}\" 'n> 'n>"
"\"/**\" 'n>"
"\"* Set the value of \" (s name) \".\" 'n>"
"\"* @param v Value to assign to \" (s name) \".\" 'n>"
"\"*/\" 'n>"
"\"public void set\" (jde-gen-init-cap (jde-gen-lookup-named 'name))"
"\"(\" (s type) \" v) {this.\" (s name) \" = v;}\" 'n>"
)
"*Template for creating a get/set method pair.
Setting this variable defines a template instantiation
command `jde-gen-get-set', as a side-effect."
:group 'jde-gen
:type '(repeat string)
:set '(lambda (sym val)
(defalias 'jde-gen-get-set
(tempo-define-template
"java-get-set-pair"
(jde-gen-read-template val)
nil
"Insert variable get-set method pair."))
(set-default sym val)))
Excuse me if this code may look dirty , it's my first one.
Wouldn't it be a good idea to place here the K&R bracket style in option as in the
other wizards?
Steff
(really proud of this small thing that took me 4 hours ;) )
Paul Kinnucan wrote:
> At 09:26 AM 6/27/00 -0400, Matthew G Knepley wrote:
> > I am a new user of JDE and first I have to say what an amazing environment
> >it is. I wanted to suggest a small change to the default Get/Set Pair
> template.
> >Accorindg to my Java in a NutShell reference, the JavaBeans convention for a
> >boolean Get is isVariable() rather than getVariable().
> >
> > 1) Is this correct?
> >
> > 2) Could the template detect a boolean return type and use "is" instead?
> >
>
> Yes, this is a good idea that has been suggested before. It is relatively
> easy to do so I'll try to have it done in the next releases (probably this
> weekend).
>
> - Paul