Methods Summary |
---|
public boolean | equals(java.lang.Object o)
if (o instanceof Address) {
return getAddress().equals(((Address) o).getAddress());
}
return super.equals(o);
|
public java.lang.String | getAddress()
return mAddress;
|
public java.lang.String | getPersonal()
return mPersonal;
|
public static java.lang.String | pack(com.android.email.mail.Address[] addresses)Packs an address list into a String that is very quick to read
and parse. Packed lists can be unpacked with unpackAddressList()
The packed list is a comma separated list of:
URLENCODE(address)[;URLENCODE(personal)]
if (addresses == null) {
return null;
} else if (addresses.length == 0) {
return "";
}
StringBuffer sb = new StringBuffer();
for (int i = 0, count = addresses.length; i < count; i++) {
Address address = addresses[i];
try {
sb.append(URLEncoder.encode(address.getAddress(), "UTF-8"));
if (address.getPersonal() != null) {
sb.append(';");
sb.append(URLEncoder.encode(address.getPersonal(), "UTF-8"));
}
if (i < count - 1) {
sb.append(',");
}
}
catch (UnsupportedEncodingException uee) {
return null;
}
}
return sb.toString();
|
public static com.android.email.mail.Address[] | parse(java.lang.String addressList)Parse a comma separated list of addresses in RFC-822 format and return an
array of Address objects.
if (addressList == null || addressList.length() == 0) {
return new Address[] {};
}
ArrayList<Address> addresses = new ArrayList<Address>();
try {
MailboxList parsedList = AddressList.parse(addressList).flatten();
for (int i = 0, count = parsedList.size(); i < count; i++) {
org.apache.james.mime4j.field.address.Address address = parsedList.get(i);
if (address instanceof NamedMailbox) {
NamedMailbox namedMailbox = (NamedMailbox)address;
addresses.add(new Address(namedMailbox.getLocalPart() + "@"
+ namedMailbox.getDomain(), namedMailbox.getName()));
} else if (address instanceof Mailbox) {
Mailbox mailbox = (Mailbox)address;
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain()));
} else {
Log.e(Email.LOG_TAG, "Unknown address type from Mime4J: "
+ address.getClass().toString());
}
}
} catch (ParseException pe) {
}
return addresses.toArray(new Address[] {});
|
public void | setAddress(java.lang.String address)
this.mAddress = address;
|
public void | setPersonal(java.lang.String personal)
this.mPersonal = personal;
|
public java.lang.String | toFriendly()
if (mPersonal != null && mPersonal.length() > 0) {
return mPersonal;
}
else {
return mAddress;
}
|
public static java.lang.String | toFriendly(com.android.email.mail.Address[] addresses)Creates a comma-delimited list of addresses in the "friendly" format (see toFriendly() for
details on the per-address conversion).
if (addresses == null || addresses.length == 0) {
return null;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < addresses.length; i++) {
if (i > 0) {
sb.append(',");
}
sb.append(addresses[i].toFriendly());
}
return sb.toString();
|
public static java.lang.String | toString(com.android.email.mail.Address[] addresses)
if (addresses == null) {
return null;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < addresses.length; i++) {
sb.append(addresses[i].toString());
if (i < addresses.length - 1) {
sb.append(',");
}
}
return sb.toString();
|
public java.lang.String | toString()
if (mPersonal != null) {
if (mPersonal.matches(".*[\\(\\)<>@,;:\\\\\".\\[\\]].*")) {
return Utility.quoteString(mPersonal) + " <" + mAddress + ">";
} else {
return mPersonal + " <" + mAddress + ">";
}
} else {
return mAddress;
}
|
public static com.android.email.mail.Address[] | unpack(java.lang.String addressList)Unpacks an address list previously packed with packAddressList()
if (addressList == null || addressList.length() == 0) {
return new Address[] { };
}
ArrayList<Address> addresses = new ArrayList<Address>();
int length = addressList.length();
int pairStartIndex = 0;
int pairEndIndex = 0;
int addressEndIndex = 0;
while (pairStartIndex < length) {
pairEndIndex = addressList.indexOf(',", pairStartIndex);
if (pairEndIndex == -1) {
pairEndIndex = length;
}
addressEndIndex = addressList.indexOf(';", pairStartIndex);
String address = null;
String personal = null;
if (addressEndIndex == -1 || addressEndIndex > pairEndIndex) {
address = Utility.fastUrlDecode(addressList.substring(pairStartIndex, pairEndIndex));
}
else {
address = Utility.fastUrlDecode(addressList.substring(pairStartIndex, addressEndIndex));
personal = Utility.fastUrlDecode(addressList.substring(addressEndIndex + 1, pairEndIndex));
}
addresses.add(new Address(address, personal));
pairStartIndex = pairEndIndex + 1;
}
return addresses.toArray(new Address[] { });
|