[..]
/**
* The actual data that needs to be persisted for a location.
*
* @ojb.class * @jdo.persistence-capable
*/
public class LocationBase implements Location {
/**
* @ojb.field primarykey="true"
*/
Integer id;
/**
* @ojb.field length="40"
*/
String country;
If you want to write a setter method for this field:
public void setCountry(String newCountry) {
if(newCountry != null && newCountry.length() > 40)
a) newCountry = newCountry.substring(0, 40);
b) throw new StringTooLongException("Length of country
has to be less or equals than 40 characters");
this.country = newCountry;
}Regardless, if you want to reduce the size of the string or let the caller do it: you replicate the size of the string (here: 40) in the code.
This puts the information in one place. which is very nice and easy to maintain.
How do you solve the problem above?
-- Christian
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
