1 package net.suberic.pooka.gui.propedit; 2 import net.suberic.util.gui.propedit.*; 3 import java.util.*; 4 import javax.mail.internet.InternetAddress ; 5 6 9 public class EmailFilter extends PropertyEditorAdapter implements ConfigurablePropertyEditorListener { 10 11 14 public void configureListener(String key, String property, String pPropertyBase, String editorTemplate, PropertyEditorManager pManager) { 15 16 } 17 18 21 public void propertyCommitting(PropertyEditorUI source, String property, String newValue) throws PropertyValueVetoException { 22 validateAddress(property, newValue); 23 } 24 25 28 public void propertyChanging(PropertyEditorUI source, String property, String newValue) throws PropertyValueVetoException { 29 validateAddress(property, newValue); 30 } 31 32 35 public void validateAddress(String property, String newValue) throws PropertyValueVetoException { 36 try { 37 if (newValue == null || newValue.length() == 0) { 38 return; 39 } 40 InternetAddress.parse(newValue); 41 } catch (Exception e) { 42 throw new PropertyValueVetoException(property, newValue, "must be a valid email address", this); 43 } 44 } 45 } 46 | Popular Tags |