// A G E N T // . . . // StringToEmailAddress.java // (c) Andy Wood ... 1996 // **************************************************************************** package cyberdesk.acton.convert; import cyberdesk.types.EmailAddress; // **************************************************************************** public class StringToEmailAddress extends ConversionApplet { protected boolean weCanConvert( Object data ) { return data instanceof java.lang.String; } protected boolean potentialLoop( ConversionInfo pathelement ) { return pathelement.getSource() instanceof cyberdesk.types.EmailAddress; } protected Object tryToConvert( Object data ) throws CouldNotConvertException { EmailAddress address; // Probably should be a bit more discerning about email addresses - // at the moment it just looks for an @ symbol anywhere in the string! if ( ( (String)data ).indexOf( '@' ) != -1 ) address = new EmailAddress( (String)data ); else throw new CouldNotConvertException(); return address; } } // ****************************************************************************Return to the CyberDesk sample code page.