Every decent Java IDE supports code generation and code re-factoring, right? We
have reckon that the 80:20 rule applies in reverse here: 20% of the code generation
features available do 80% of the code generation used by most developers. So, The
Squealer is aimed at the essential features only. Currently this is Java accessor
method generation and an experimental form of Value Object generation (from a SQL
statement).
Accessor methods (or get/set methods for your class fields) are essential to
maintain encapsulation of your classes, but yet are all identical. The Squealer allows
you to generate accessor methods for all fields in a class or a selection of fields
(using the Windows clipboard to pass the selected fields from your editor to The
Squealer).
Why the Output is So Terse
The methods are grouped into set() and get()
methods by alphabetical order. The output is optimised for space reasons (to a limit
of 80 characters) because we believe accessor methods to be the lowest form of code:
nobody should every have to study them or have comments/Javadoc to explain them.
Because of this
we like to squeeze them into as small a chunk of nicely formatted code that we can.
They also break most rules for variable naming conventions, but again we consider
them an exception to the normal rules: these methods should really be provided
by the Java compiler based on some keyword on the fields.
The key characteristic of Squealer code generation is that it is unobtrusive. We
aim not to modify your source files. We will auto-generate stuff and put it
in your editor's Results window. It's up to you to take the output and integrate it
back in to your code. We feel this is a much safer way to work. Plus it means you
can see clearly what The Squealer's doing.
Examples
Select some fields in your Java class and hit Alt-A . You will see the
following results in the Command Results.
Current project is: test
Squealer Code Generation Version 0.16
Creating Getter and Setter methods for file SessionVO.java
Created 14 accessor methods
------------------------------------------------------------------------------------
public void setEmailAddress(String s) { emailAddress_i = s; }
public void setInternalSession(EJBObject e) { internalSession_i = e; }
public void setPasswordExpired(boolean b) { passwordExpired_i = b; }
public void setPrivileges(HashMap h) { privileges_i = h; }
public void setRoles(HashMap h) { roles_i = h; }
public void setUserPK(UserPK u) { userPK_i = u; }
public void setUsername(String s) { username_i = s; }
public String getEmailAddress() { return emailAddress_i; }
public EJBObject getInternalSession() { return internalSession_i; }
public boolean getPasswordExpired() { return passwordExpired_i; }
public HashMap getPrivileges() { return privileges_i; }
public HashMap getRoles() { return roles_i; }
public UserPK getUserPK() { return userPK_i; }
public String getUsername() { return username_i; }
|