hey,
i'd always wanted a simple emacs function to generate a serialVersionUID, but
jde doesn't seem to provide one.  the itch finally got to me, so i whipped one
up.  may be useful enough to work it's way back into the jde distribution. 
possible enhancments are that instead of inserting at point, the method could
figure out where to insert it (was too much work to figure out how to get that
to work).  enjoy.
-james


(defun jde-insert-serialver ()
  "Inserts the serialVersionUID statement generated by a call to the serialver
program in the current buffer at the beginning of the current line.  Must have
serialver tool in the current path."
  (interactive)
  (let ((run-classpath (jde-build-classpath jde-global-classpath))
        (run-package (jde-parse-get-package-name))
        (run-class (jde-parse-get-class-at-point))
        cmd-str serialver-str)

    ;; create serialver command
    (if run-package
        (setq run-class (concat run-package "." run-class)))
    (setq cmd-str
          (concat "serialver -classpath '" run-classpath "' " run-class))

    ;; generate serialver string in temp buffer
    (with-temp-buffer
      (shell-command cmd-str t)
      (goto-char 0)
      (re-search-forward "static final.*$")
      (setq serialver-str (concat "private " (match-string 0))))

    ;; insert serialver string at beginning of line and indent accordingly
    (beginning-of-line)
    (insert serialver-str)
    (beginning-of-line)
    (indent-for-tab-command)
    ))



Reply via email to