From 3b3c107b9930b363f56cd65d6440c4e70159fbad Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Wed, 24 Oct 2012 10:12:44 +0000 Subject: [PATCH] Reverts an incomplete modification to fix the build. --- .../impl/protocol/mock/MockContact.java | 181 +++++++++++------- 1 file changed, 112 insertions(+), 69 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java b/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java index 6fc1a0060..71464d861 100644 --- a/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java +++ b/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java @@ -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 - * MockContactGroup by the MockContactGroup itself. - * @param newParentGroup the MockContactGroup that is now parent - * of this MockContact + * Determines whether a specific Object is equal to this instance. + * MockContact defines equality on {@link Contact#getAddress()} + * regardless of their ProtocolProviderService. + * + * @param obj the Object which is to be compared to this instance + * @return true if the specified obj is equal to this + * instance; otherwise, false. */ - 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. + *

+ * @return null as no such data is needed. + */ + public String getPersistentData() { return null; } @@ -108,17 +134,6 @@ public PresenceStatus getPresenceStatus() return this.presenceStatus; } - /** - * Sets mockPresenceStatus as the PresenceStatus that this contact - * is currently in. - * @param mockPresenceStatus the MockPresenceStatus 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. - *

- * @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 + * MockContactGroup by the MockContactGroup itself. + * @param newParentGroup the MockContactGroup that is now parent + * of this MockContact + */ + void setParentGroup(MockContactGroup newParentGroup) + { + this.parentGroup = newParentGroup; + } + + /** + * Sets mockPresenceStatus as the PresenceStatus that this contact + * is currently in. + * @param mockPresenceStatus the MockPresenceStatus 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(); } }