/** * Verify that the given string is a valid email address. * "Validity" in this context only means that the address conforms * to the correct syntax (not if the address actually exists). * * @param email The email address to verify. * @return a boolean indicating whether the email address is correctly formatted. */ public final static boolean verifyEmail(String email) { return MailUtils.verifyEmail(email); }
/** * Decode binary data from String using base64. * * @see #encodeBytes(byte[]) */ public final static byte[] decodeBytes(String str) throws IOException { return MailUtils.decodeBytes(str); }
/** * Encode binary data into String using base64. * * @see #decodeBytes(java.lang.String) */ public final static String encodeBytes(byte[] data) throws IOException { return MailUtils.encodeBytes(data); }
/** * Verify that the given string is a valid email address. * "Validity" in this context only means that the address conforms * to the correct syntax (not if the address actually exists). * * @param email The email address to verify. * @return a boolean indicating whether the email address is correctly formatted. */ public final static boolean verifyEmail(String email) { return MailUtils.verifyEmail(email); }
/** * Decode binary data from String using base64. * @deprecated use {@link MailUtils#decodeBytes(String)} instead. * @see #encodeBytes(byte[]) */ public final static byte[] decodeBytes(String str) throws IOException { return MailUtils.decodeBytes(str); }
/** * Encode binary data into String using base64. * @deprecated use {@link MailUtils#encodeBytes(byte[])} instead. * @see #decodeBytes(java.lang.String) */ public final static String encodeBytes(byte[] data) throws IOException { return MailUtils.encodeBytes(data); }
public void validate(Object object) throws ValidationException { String fieldName = getFieldName(); String value = (String) getFieldValue(fieldName, object); if (value == null) { return; } value = value.trim(); if (value.length() == 0) { return; } String[] emails = value.split("\\s*,\\s*"); // split on comma surrounded by option whitespace // now validate each e-mail address for (int i=0; i < emails.length; i++) { if (!MailUtils.verifyEmail(emails[i])) { addFieldError(fieldName, object); break; } } } }
/** * Decode Object from a String by decoding with base64 then deserializing. * @see #encodeObject(java.lang.Object) */ public final static Object decodeObject(String str) throws IOException, ClassNotFoundException { ByteArrayInputStream bytes = new ByteArrayInputStream(MailUtils.decodeBytes(str)); ObjectInputStream stream = new ObjectInputStream(bytes); Object result = stream.readObject(); stream.close(); return result; }
/** * Encode an Object to String by serializing it and encoding using base64. * * @see #decodeObject(java.lang.String) */ public final static String encodeObject(Object o) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream stream = new ObjectOutputStream(bytes); stream.writeObject(o); stream.close(); bytes.flush(); return MailUtils.encodeBytes(bytes.toByteArray()); }