Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AbstractOperationSetContactCapabilities<T extends ProtocolProviderService>

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractOperationSetContactCapabilities<T>
Type Parameters:
T - the type of the ProtocolProviderService implementation providing the AbstractOperationSetContactCapabilities implementation
All Implemented Interfaces:
OperationSet, OperationSetContactCapabilities
Direct Known Subclasses:
OperationSetContactCapabilitiesJabberImpl

public abstract class AbstractOperationSetContactCapabilities<T extends ProtocolProviderService>
extends Object
implements OperationSetContactCapabilities

Represents a default implementation of OperationSetContactCapabilities which attempts to make it easier for implementers to provide complete solutions while focusing on implementation-specific functionality.

Author:
Lubomir Marinov

Field Summary
protected  T parentProvider
          The ProtocolProviderService which provides this OperationSetContactCapabilities.
 
Constructor Summary
protected AbstractOperationSetContactCapabilities(T parentProvider)
          Initializes a new AbstractOperationSetContactCapabilities instance which is to be provided by a specific ProtocolProviderService implementation.
 
Method Summary
 void addContactCapabilitiesListener(ContactCapabilitiesListener listener)
          Registers a specific ContactCapabilitiesListener to be notified about changes in the list of OperationSet capabilities of Contacts.
protected  void fireContactCapabilitiesEvent(Contact sourceContact, int eventID, Map<String,? extends OperationSet> opSets)
          Fires a new ContactCapabilitiesEvent to notify the registered ContactCapabilitiesListeners that a specific Contact has changed its list of OperationSet capabilities.
<U extends OperationSet>
U
getOperationSet(Contact contact, Class<U> opsetClass)
          Gets the OperationSet corresponding to the specified Class and supported by the specified Contact.
protected
<U extends OperationSet>
U
getOperationSet(Contact contact, Class<U> opsetClass, boolean online)
          Gets the OperationSet corresponding to the specified Class and supported by the specified Contact.
 Map<String,OperationSet> getSupportedOperationSets(Contact contact)
          Gets the OperationSets supported by a specific Contact.
protected  Map<String,OperationSet> getSupportedOperationSets(Contact contact, boolean online)
          Gets the OperationSets supported by a specific Contact.
protected  boolean isOnline(Contact contact)
          Determines whether a specific Contact is online (in contrast to offline).
 void removeContactCapabilitiesListener(ContactCapabilitiesListener listener)
          Unregisters a specific ContactCapabilitiesListener to no longer be notified about changes in the list of OperationSet capabilities of Contacts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentProvider

protected final T extends ProtocolProviderService parentProvider
The ProtocolProviderService which provides this OperationSetContactCapabilities.

Constructor Detail

AbstractOperationSetContactCapabilities

protected AbstractOperationSetContactCapabilities(T parentProvider)
Initializes a new AbstractOperationSetContactCapabilities instance which is to be provided by a specific ProtocolProviderService implementation.

Parameters:
parentProvider - the ProtocolProviderService implementation which will provide the new instance
Method Detail

addContactCapabilitiesListener

public void addContactCapabilitiesListener(ContactCapabilitiesListener listener)
Registers a specific ContactCapabilitiesListener to be notified about changes in the list of OperationSet capabilities of Contacts. If the specified listener has already been registered, adding it again has no effect.

Specified by:
addContactCapabilitiesListener in interface OperationSetContactCapabilities
Parameters:
listener - the ContactCapabilitiesListener which is to be notified about changes in the list of OperationSet capabilities of Contacts
See Also:
OperationSetContactCapabilities.addContactCapabilitiesListener( ContactCapabilitiesListener)

fireContactCapabilitiesEvent

protected void fireContactCapabilitiesEvent(Contact sourceContact,
                                            int eventID,
                                            Map<String,? extends OperationSet> opSets)
Fires a new ContactCapabilitiesEvent to notify the registered ContactCapabilitiesListeners that a specific Contact has changed its list of OperationSet capabilities.

Parameters:
sourceContact - the Contact which is the source/cause of the event to be fired
eventID - the ID of the event to be fired which indicates the specifics of the change of the list of OperationSet capabilities of the specified sourceContact and the details of the event
opSets - the new set of operation sets for the given source contact

getOperationSet

public <U extends OperationSet> U getOperationSet(Contact contact,
                                                  Class<U> opsetClass)
Gets the OperationSet corresponding to the specified Class and supported by the specified Contact. If the returned value is non-null, it indicates that the Contact is considered by the associated protocol provider to possess the opsetClass capability. Otherwise, the associated protocol provider considers contact to not have the opsetClass capability. AbstractOperationSetContactCapabilities looks for the name of the specified opsetClass in the Map returned by getSupportedOperationSets(Contact) and returns the associated OperationSet. Since the implementation is suboptimal due to the temporary Map allocations and loopups, extenders are advised to override getOperationSet(Contact, Class, boolean).

Specified by:
getOperationSet in interface OperationSetContactCapabilities
Type Parameters:
U - the type extending OperationSet for which the specified contact is to be checked whether it possesses it as a capability
Parameters:
contact - the Contact for which the opsetClass capability is to be queried
opsetClass - the OperationSet Class for which the specified contact is to be checked whether it possesses it as a capability
Returns:
the OperationSet corresponding to the specified opsetClass which is considered by the associated protocol provider to be possessed as a capability by the specified contact; otherwise, null
See Also:
OperationSetContactCapabilities.getOperationSet(Contact, Class)

getOperationSet

protected <U extends OperationSet> U getOperationSet(Contact contact,
                                                     Class<U> opsetClass,
                                                     boolean online)
Gets the OperationSet corresponding to the specified Class and supported by the specified Contact. If the returned value is non-null, it indicates that the Contact is considered by the associated protocol provider to possess the opsetClass capability. Otherwise, the associated protocol provider considers contact to not have the opsetClass capability. AbstractOperationSetContactCapabilities looks for the name of the specified opsetClass in the Map returned by getSupportedOperationSets(Contact) and returns the associated OperationSet. Since the implementation is suboptimal due to the temporary Map allocations and loopups, extenders are advised to override.

Type Parameters:
U - the type extending OperationSet for which the specified contact is to be checked whether it possesses it as a capability
Parameters:
contact - the Contact for which the opsetClass capability is to be queried
opsetClass - the OperationSet Class for which the specified contact is to be checked whether it possesses it as a capability
online - true if contact is online; otherwise, false
Returns:
the OperationSet corresponding to the specified opsetClass which is considered by the associated protocol provider to be possessed as a capability by the specified contact; otherwise, null
See Also:
OperationSetContactCapabilities.getOperationSet(Contact, Class)

getSupportedOperationSets

public Map<String,OperationSet> getSupportedOperationSets(Contact contact)
Gets the OperationSets supported by a specific Contact. The returned OperationSets are considered by the associated protocol provider to capabilities possessed by the specified contact. The default implementation returns the result of calling ProtocolProviderService.getSupportedOperationSets() on the associated ProtocolProviderService implementation. Extenders have to override the default implementation of getSupportedOperationSets(Contact, boolean) in order to provide actual capability detection for the specified contact.

Specified by:
getSupportedOperationSets in interface OperationSetContactCapabilities
Parameters:
contact - the Contact for which the supported OperationSet capabilities are to be retrieved
Returns:
a Map listing the OperationSets considered by the associated protocol provider to be supported by the specified contact (i.e. to be possessed as capabilities). Each supported OperationSet capability is represented by a Map.Entry with key equal to the OperationSet class name and value equal to the respective OperationSet instance
See Also:
OperationSetContactCapabilities.getSupportedOperationSets(Contact)

getSupportedOperationSets

protected Map<String,OperationSet> getSupportedOperationSets(Contact contact,
                                                             boolean online)
Gets the OperationSets supported by a specific Contact. The returned OperationSets are considered by the associated protocol provider to capabilities possessed by the specified contact. The default implementation returns the result of calling ProtocolProviderService.getSupportedOperationSets() on the associated ProtocolProviderService implementation. Extenders have to override the default implementation in order to provide actual capability detection for the specified contact.

Parameters:
contact - the Contact for which the supported OperationSet capabilities are to be retrieved
online - true if contact is online; otherwise, false
Returns:
a Map listing the OperationSets considered by the associated protocol provider to be supported by the specified contact (i.e. to be possessed as capabilities). Each supported OperationSet capability is represented by a Map.Entry with key equal to the OperationSet class name and value equal to the respective OperationSet instance
See Also:
OperationSetContactCapabilities.getSupportedOperationSets(Contact)

isOnline

protected boolean isOnline(Contact contact)
Determines whether a specific Contact is online (in contrast to offline).

Parameters:
contact - the Contact which is to be determines whether it is online
Returns:
true if the specified contact is online; otherwise, false

removeContactCapabilitiesListener

public void removeContactCapabilitiesListener(ContactCapabilitiesListener listener)
Unregisters a specific ContactCapabilitiesListener to no longer be notified about changes in the list of OperationSet capabilities of Contacts. If the specified listener has already been unregistered or has never been registered, removing it has no effect.

Specified by:
removeContactCapabilitiesListener in interface OperationSetContactCapabilities
Parameters:
listener - the ContactCapabilitiesListener which is to no longer be notified about changes in the list of OperationSet capabilities of Contacts
See Also:
OperationSetContactCapabilities.removeContactCapabilitiesListener( ContactCapabilitiesListener)

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.