On Fri, 11 Jan 2002 01:51, Paulo Gaspar wrote: > Wouldn't an adapter class for such especial cases be adequate? > Something like (just a draft):
Similar to what I did. Except mine looked like > public class LogLevel extends ValuedEnum > implements Serializable > { > private final static Map m_levelMap = new HashMap(5); > > public final static LogLevel DEBUG = new LogLevel("DEBUG", 5); > public final static LogLevel INFO = new LogLevel("INFO", 10); > public final static LogLevel WARN = new LogLevel("WARN", 15); > public final static LogLevel ERROR = new LogLevel("ERROR", 20); > public final static LogLevel FATAL_ERROR = new LogLevel("FATAL_ERROR", > 25); > public static void log( final String message, LogLevel level ) { ...do if statement here... } > > private LogLevel(final String i_name, final int i_value) > { > super(i_name, i_value, m_levelMap); > } > > public static LogLevel getLevelForName(final String i_levelName) > { > return (LogLevel)m_levelMap.get(i_levelName.toUpperCase()); > } > > public String toString() > { > return "LogLevel[" + getName() + "/" + getValue() + "]"; > } > > private Object readResolve() > throws ObjectStreamException > { > return getLevelForName(getName()); > } > } > This would allow to keep the current "clean" interface and > use this class just for those especial cases. > > What do you think? Either way is good ;) -- Cheers, Pete ---------------------------------------- "Liberty means responsibility. That is why most men dread it." - Locke ---------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>