Methods Summary |
---|
public boolean | equals(java.lang.Object other)
return other instanceof ImpsAddress
&& mFullAddress.equalsIgnoreCase(((ImpsAddress)other).mFullAddress);
|
public static com.android.im.imps.ImpsAddress | fromPrimitiveElement(PrimitiveElement elem)Constructs an ImpsAddress from the Sender or Recipient element in a
primitive.
String type = elem.getTagName();
if(ImpsTags.User.equals(type)) {
return new ImpsUserAddress(elem.getChildContents(ImpsTags.UserID), false);
} else if(ImpsTags.Group.equals(type)) {
PrimitiveElement child = elem.getFirstChild();
if(child == null) {
throw new IllegalArgumentException();
}
if(ImpsTags.GroupID.equals(child.getTagName())){
return new ImpsGroupAddress(child.getContents());
} else {
String screeName = child.getChildContents(ImpsTags.SName);
String groupId = child.getChildContents(ImpsTags.GroupID);
return new ImpsGroupAddress(groupId, screeName);
}
} else if(ImpsTags.ContactList.equals(type)) {
return new ImpsContactListAddress(elem.getContents(), false);
} else {
throw new IllegalArgumentException();
}
|
public java.lang.String | getDomain()Gets the Domain-part of the address which identifies the IMPS server
domain.
return mDomain;
|
abstract com.android.im.engine.ImEntity | getEntity(ImpsConnection connection)Gets the entity this address object refers to.
|
public java.lang.String | getFullName()Gets the full string representation of the address.
return mFullAddress;
|
public java.lang.String | getResource()Gets the Resource-part of the address which identifies the referred
public or private resource.
return mResource;
|
public java.lang.String | getUser()Gets the User-part of the address which refers to the identification of
the IMPS user.
return mUser;
|
public int | hashCode()
return mFullAddress.toLowerCase().hashCode();
|
private boolean | isAlphaSequence(java.lang.String str)
for(int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if(ch < 32 || ch > 126 || isSpecial(ch)) {
return false;
}
}
return true;
|
private boolean | isSpecial(char ch)
for (char element : SPECIALS) {
if(ch == element) {
return true;
}
}
return false;
|
private void | parse(java.lang.String full)
mUser = parseUser(full);
mResource = parseResource(full);
mDomain = parseDomain(full);
|
private java.lang.String | parseDomain(java.lang.String full)
int beginIndex = full.lastIndexOf('@");
return beginIndex == -1 ? null : full.substring(beginIndex + 1);
|
private java.lang.String | parseResource(java.lang.String full)
int beginIndex = full.indexOf('/");
if (beginIndex == -1) {
return null;
}
int endIndex = full.lastIndexOf('@");
if (endIndex == -1 || endIndex < beginIndex) {
endIndex = full.length();
}
return full.substring(beginIndex + 1, endIndex);
|
private java.lang.String | parseUser(java.lang.String full)
int index = full.indexOf('/");
if(index == 3) {
return null;
}
if (index == -1) {
index = full.lastIndexOf('@");
}
if (index == -1) {
index = full.length();
}
return full.substring(3, index);
|
public void | readFromParcel(android.os.Parcel source)
mFullAddress = source.readString();
parse(mFullAddress);
|
public abstract PrimitiveElement | toPrimitiveElement()Formats the address to a PrimitiveElement which can be used as the
content of Sender or Recipient.
|
private void | verifyAddress()
ImpsLog.log("verifyAddress:" + mUser + ", " + mResource + ", " + mDomain);
if(mUser == null && mResource == null) {
throw new IllegalArgumentException();
}
if(mUser != null) {
if(mUser.length() == 0) {
throw new IllegalArgumentException("Invalid user");
}
if(mUser.charAt(0) == '+") {//mobile number
for(int i = 1; i < mUser.length(); i++) {
if(!Character.isDigit(mUser.charAt(i))) {
throw new IllegalArgumentException("Invalid user");
}
}
} else if(!isAlphaSequence(mUser)) {
throw new IllegalArgumentException("Invalid user");
}
}
if(mResource != null && !isAlphaSequence(mResource)) {
throw new IllegalArgumentException("Invalid resource");
}
if(mDomain != null && !isAlphaSequence(mDomain)) {
throw new IllegalArgumentException("Invalid domain");
}
|
public void | writeToParcel(android.os.Parcel dest)
dest.writeString(mFullAddress);
|