Hi,
I have writen a tiny emacs macro function that create setter and
getter method from a Java variable definition. I think its very
useful especially if you are a user of emacsen.
---snip---snip---snip---snip---snip
(defun make-accessor(&optional arg)
"Generate and insert accessor methods. If apply with C-u, just
getter methods whould be inserted."
(interactive "P")
(save-excursion
(if (search-forward-regexp
"\\(pubic\\|private\\|protected\\|static\\|[ \t\n]\\)+\\([a-zA-Z_0-9]+\\)[
\t\n]+\\([a-zA-Z_0-9]+\\)[ \t\n]*[;=]")
(progn
(let* ((varname (buffer-substring (match-beginning 3) (match-end 3)))
(vartype (buffer-substring (match-beginning 2) (match-end 2)))
(capname (concat (upcase (substring varname 0 1))
(substring varname 1)))
)
(end-of-line)
(newline-and-indent)
(newline-and-indent)
(insert (format "public %s get%s() {" vartype capname))
(newline-and-indent)
(insert (format "return %s;" varname))
(newline-and-indent)
(insert "}")
(indent-according-to-mode)
(if (not arg)
(progn
(newline-and-indent)
(newline-and-indent)
(insert (format "public void set%s(%s arg) {" capname vartype))
(newline-and-indent)
(insert (format "%s = arg;" varname))
(newline-and-indent)
(insert "}")
(indent-according-to-mode)
)))))))
---snip---snip---snip---snip---snip
Marc-andre Thibodeau <[EMAIL PROTECTED]> writes:
> Hi!
>
> Could anybody suggest me a tool for generating JavaBeans setters and
> getters automatically?
> Thanks!
>
> MA
>
>
--
--
UEHARA, Junji
Advanced System developing department,
Electronic Commerce Development Center
NTT Software corporation
223-1, Yamashita-cho Naka-ku Yokohama City,
Kanagawa Pref. , Japan 231-8554
Tel: +81-45-212-7408
Fax: +81-45-212-7948