|
|
|
|
@ -16,14 +16,14 @@
|
|
|
|
|
* @author Emil Ivov
|
|
|
|
|
*/
|
|
|
|
|
public class MockContact
|
|
|
|
|
extends AbstractContact
|
|
|
|
|
implements Contact
|
|
|
|
|
{
|
|
|
|
|
private String contactID = null;
|
|
|
|
|
private MockProvider parentProvider = null;
|
|
|
|
|
private MockContactGroup parentGroup = null;
|
|
|
|
|
private PresenceStatus presenceStatus = MockStatusEnum.MOCK_STATUS_50;
|
|
|
|
|
private boolean isPersistent = true;
|
|
|
|
|
private boolean isResolved = true;
|
|
|
|
|
private MockContactGroup parentGroup = null;
|
|
|
|
|
private MockProvider parentProvider = null;
|
|
|
|
|
private PresenceStatus presenceStatus = MockStatusEnum.MOCK_STATUS_50;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an instance of a meta contact with the specified string used
|
|
|
|
|
@ -40,14 +40,34 @@ public MockContact(String id,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method is only called when the contact is added to a new
|
|
|
|
|
* <tt>MockContactGroup</tt> by the MockContactGroup itself.
|
|
|
|
|
* @param newParentGroup the <tt>MockContactGroup</tt> that is now parent
|
|
|
|
|
* of this <tt>MockContact</tt>
|
|
|
|
|
* Determines whether a specific <tt>Object</tt> is equal to this instance.
|
|
|
|
|
* <tt>MockContact</tt> defines equality on {@link Contact#getAddress()}
|
|
|
|
|
* regardless of their <tt>ProtocolProviderService</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param obj the <tt>Object</tt> which is to be compared to this instance
|
|
|
|
|
* @return <tt>true</tt> if the specified <tt>obj</tt> is equal to this
|
|
|
|
|
* instance; otherwise, <tt>false</tt>.
|
|
|
|
|
*/
|
|
|
|
|
void setParentGroup(MockContactGroup newParentGroup)
|
|
|
|
|
@Override
|
|
|
|
|
public boolean equals(Object obj)
|
|
|
|
|
{
|
|
|
|
|
this.parentGroup = newParentGroup;
|
|
|
|
|
if (obj == null)
|
|
|
|
|
return false;
|
|
|
|
|
else if (obj == this)
|
|
|
|
|
return true;
|
|
|
|
|
else if (!obj.getClass().equals(getClass()))
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Contact contact = (Contact) obj;
|
|
|
|
|
String address = contact.getAddress();
|
|
|
|
|
String thisAddress = getAddress();
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
(address == null)
|
|
|
|
|
? (thisAddress == null)
|
|
|
|
|
: address.equals(thisAddress);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -72,28 +92,34 @@ public String getDisplayName()
|
|
|
|
|
return contactID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the display name of this contact.
|
|
|
|
|
* Returns a byte array containing an image (most often a photo or an
|
|
|
|
|
* avatar) that the contact uses as a representation.
|
|
|
|
|
*
|
|
|
|
|
* @param displayName the new display name for this contact.
|
|
|
|
|
* @return byte[] an image representing the contact.
|
|
|
|
|
*/
|
|
|
|
|
public void setDisplayName(String displayName)
|
|
|
|
|
public byte[] getImage()
|
|
|
|
|
{
|
|
|
|
|
if (isResolved)
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
// contactID = displayName;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a byte array containing an image (most often a photo or an
|
|
|
|
|
* avatar) that the contact uses as a representation.
|
|
|
|
|
*
|
|
|
|
|
* @return byte[] an image representing the contact.
|
|
|
|
|
* Returns the group that contains this contact.
|
|
|
|
|
* @return a reference to the MockContactGroup that contains this contact.
|
|
|
|
|
*/
|
|
|
|
|
public byte[] getImage()
|
|
|
|
|
public ContactGroup getParentContactGroup()
|
|
|
|
|
{
|
|
|
|
|
return this.parentGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns null as no persistent data is required and the contact address is
|
|
|
|
|
* sufficient for restoring the contact.
|
|
|
|
|
* <p>
|
|
|
|
|
* @return null as no such data is needed.
|
|
|
|
|
*/
|
|
|
|
|
public String getPersistentData()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
@ -108,17 +134,6 @@ public PresenceStatus getPresenceStatus()
|
|
|
|
|
return this.presenceStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets <tt>mockPresenceStatus</tt> as the PresenceStatus that this contact
|
|
|
|
|
* is currently in.
|
|
|
|
|
* @param mockPresenceStatus the <tt>MockPresenceStatus</tt> currently valid
|
|
|
|
|
* for this contact.
|
|
|
|
|
*/
|
|
|
|
|
public void setPresenceStatus(MockStatusEnum mockPresenceStatus)
|
|
|
|
|
{
|
|
|
|
|
this.presenceStatus = mockPresenceStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a reference to the protocol provider that created the contact.
|
|
|
|
|
*
|
|
|
|
|
@ -130,37 +145,36 @@ public ProtocolProviderService getProtocolProvider()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determines whether or not this contact represents our own identity.
|
|
|
|
|
*
|
|
|
|
|
* @return true in case this is a contact that represents ourselves and
|
|
|
|
|
* false otherwise.
|
|
|
|
|
* Return the current status message of this contact.
|
|
|
|
|
*
|
|
|
|
|
* @return null as the protocol has currently no support of status messages
|
|
|
|
|
*/
|
|
|
|
|
public boolean isLocal()
|
|
|
|
|
public String getStatusMessage()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the group that contains this contact.
|
|
|
|
|
* @return a reference to the MockContactGroup that contains this contact.
|
|
|
|
|
* Returns a hash code value for this instance supported for the benefit of
|
|
|
|
|
* hashtables.
|
|
|
|
|
*
|
|
|
|
|
* @return a hash code value for this instance
|
|
|
|
|
*/
|
|
|
|
|
public ContactGroup getParentContactGroup()
|
|
|
|
|
@Override
|
|
|
|
|
public int hashCode()
|
|
|
|
|
{
|
|
|
|
|
return this.parentGroup;
|
|
|
|
|
return getAddress().hashCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a string representation of this contact, containing most of its
|
|
|
|
|
* representative details.
|
|
|
|
|
* Determines whether or not this contact represents our own identity.
|
|
|
|
|
*
|
|
|
|
|
* @return a string representation of this contact.
|
|
|
|
|
* @return true in case this is a contact that represents ourselves and
|
|
|
|
|
* false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public String toString()
|
|
|
|
|
public boolean isLocal()
|
|
|
|
|
{
|
|
|
|
|
StringBuffer buff = new StringBuffer("MockContact[ DisplayName=")
|
|
|
|
|
.append(getDisplayName()).append("]");
|
|
|
|
|
|
|
|
|
|
return buff.toString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -179,17 +193,6 @@ public boolean isPersistent()
|
|
|
|
|
return isPersistent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns null as no persistent data is required and the contact address is
|
|
|
|
|
* sufficient for restoring the contact.
|
|
|
|
|
* <p>
|
|
|
|
|
* @return null as no such data is needed.
|
|
|
|
|
*/
|
|
|
|
|
public String getPersistentData()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determines whether or not this contact has been resolved against the
|
|
|
|
|
* server. Unresolved contacts are used when initially loading a contact
|
|
|
|
|
@ -204,6 +207,42 @@ public boolean isResolved()
|
|
|
|
|
return isResolved;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the display name of this contact.
|
|
|
|
|
*
|
|
|
|
|
* @param displayName the new display name for this contact.
|
|
|
|
|
*/
|
|
|
|
|
public void setDisplayName(String displayName)
|
|
|
|
|
{
|
|
|
|
|
if (isResolved)
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
// contactID = displayName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method is only called when the contact is added to a new
|
|
|
|
|
* <tt>MockContactGroup</tt> by the MockContactGroup itself.
|
|
|
|
|
* @param newParentGroup the <tt>MockContactGroup</tt> that is now parent
|
|
|
|
|
* of this <tt>MockContact</tt>
|
|
|
|
|
*/
|
|
|
|
|
void setParentGroup(MockContactGroup newParentGroup)
|
|
|
|
|
{
|
|
|
|
|
this.parentGroup = newParentGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets <tt>mockPresenceStatus</tt> as the PresenceStatus that this contact
|
|
|
|
|
* is currently in.
|
|
|
|
|
* @param mockPresenceStatus the <tt>MockPresenceStatus</tt> currently valid
|
|
|
|
|
* for this contact.
|
|
|
|
|
*/
|
|
|
|
|
public void setPresenceStatus(MockStatusEnum mockPresenceStatus)
|
|
|
|
|
{
|
|
|
|
|
this.presenceStatus = mockPresenceStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Makes the contact resolved or unresolved.
|
|
|
|
|
*
|
|
|
|
|
@ -216,12 +255,16 @@ public void setResolved(boolean resolved)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the current status message of this contact.
|
|
|
|
|
*
|
|
|
|
|
* @return null as the protocol has currently no support of status messages
|
|
|
|
|
* Returns a string representation of this contact, containing most of its
|
|
|
|
|
* representative details.
|
|
|
|
|
*
|
|
|
|
|
* @return a string representation of this contact.
|
|
|
|
|
*/
|
|
|
|
|
public String getStatusMessage()
|
|
|
|
|
public String toString()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
StringBuffer buff = new StringBuffer("MockContact[ DisplayName=")
|
|
|
|
|
.append(getDisplayName()).append("]");
|
|
|
|
|
|
|
|
|
|
return buff.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|