org.sandev.ui.util
Class TextUtil

java.lang.Object
  extended by org.sandev.ui.util.TextUtil

public class TextUtil
extends java.lang.Object

Text manipulation utilities.


Constructor Summary
TextUtil()
           
 
Method Summary
static void checkForMisses(EmailAddress ea, java.util.ArrayList al)
          If our text had an email with no atsign in it, then it will end up stuck to one of the names.
static java.lang.String cleanName(java.lang.String rawname)
          Given a name, clean up any known extraneous characters and return the result.
static EmailAddress getEmailFromText(java.lang.String text)
          Read the given text to extract a single email address.
static EmailAddress[] getEmailsFromText(java.lang.String text)
          Parse the email addresses out of the given text and return them as an array of EmailAddress instances.
static boolean isValidEmailAddressChar(char ch)
          Return true if the given character is valid in an email address on either side of the atSign, false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextUtil

public TextUtil()
Method Detail

getEmailsFromText

public static EmailAddress[] getEmailsFromText(java.lang.String text)
Parse the email addresses out of the given text and return them as an array of EmailAddress instances. The returned array will contain instances for all the data read, but some of these instances may be invalid if the text was not parsed completely successfully. The caller can filter out the invalid entries or use them to report back errors.

This method breaks the address text into separate strings with one email address per string, then calls through to the single email address get method. To locate each email address we search forward for a '@' and then search forward again while we have valid email characters. So terminating delimiters end up at the start of the next token. If a Logger is given, then the parsed

Valid email address characters are letters, numbers, '.', '_' and '-'. Everything else is email client specific extensions. Different clients also use different address separators for writing multiple addresses on one line. Commas and semicolons are both in common use as separators, as are newlines and whitespace.


getEmailFromText

public static EmailAddress getEmailFromText(java.lang.String text)
Read the given text to extract a single email address.


cleanName

public static java.lang.String cleanName(java.lang.String rawname)
Given a name, clean up any known extraneous characters and return the result.


isValidEmailAddressChar

public static boolean isValidEmailAddressChar(char ch)
Return true if the given character is valid in an email address on either side of the atSign, false otherwise.


checkForMisses

public static void checkForMisses(EmailAddress ea,
                                  java.util.ArrayList al)
If our text had an email with no atsign in it, then it will end up stuck to one of the names. This method checks for known issues and tries to correct them by trimming out the cruft and adding corresponding invalid instances to the list. This is a post processing hack to catch things that the normal parsing misses.

known cases: