Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.icq
Class OperationSetServerStoredAccountInfoIcqImpl

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractOperationSetServerStoredAccountInfo
      extended by net.java.sip.communicator.impl.protocol.icq.OperationSetServerStoredAccountInfoIcqImpl
All Implemented Interfaces:
OperationSet, OperationSetServerStoredAccountInfo

public class OperationSetServerStoredAccountInfoIcqImpl
extends AbstractOperationSetServerStoredAccountInfo

Author:
Damian Minkov

Nested Class Summary
static class OperationSetServerStoredAccountInfoIcqImpl.InterestDetail
          User interests
static class OperationSetServerStoredAccountInfoIcqImpl.NotesDetail
          User notes
static class OperationSetServerStoredAccountInfoIcqImpl.OriginCityDetail
          Origin City of user
static class OperationSetServerStoredAccountInfoIcqImpl.OriginCountryDetail
          Origin country Code of user
static class OperationSetServerStoredAccountInfoIcqImpl.OriginPostalCodeDetail
          Origin Postal Code of user
static class OperationSetServerStoredAccountInfoIcqImpl.OriginProvinceDetail
          Origin Province of User
static class OperationSetServerStoredAccountInfoIcqImpl.WorkDepartmentNameDetail
          Work department
static class OperationSetServerStoredAccountInfoIcqImpl.WorkFaxDetail
          Fax at work
static class OperationSetServerStoredAccountInfoIcqImpl.WorkOcupationDetail
          User ocupation at work
static class OperationSetServerStoredAccountInfoIcqImpl.WorkPositionNameDetail
          User position name at work
 
Field Summary
(package private) static ServerStoredDetails.GenderDetail[] genders
           
(package private) static String[] interestsCategories
           
(package private) static String[] occupations
           
static Map<Class<? extends ServerStoredDetails.GenericDetail>,int[]> supportedTypes
           
 
Constructor Summary
OperationSetServerStoredAccountInfoIcqImpl(InfoRetreiver infoRetreiver, String uin, ProtocolProviderServiceIcqImpl icqProvider)
          Creates instance of OperationSetServerStoredAccountInfo for icq protocol.
 
Method Summary
 void addDetail(ServerStoredDetails.GenericDetail detail)
          Adds the specified detail to the list of details registered on-line for this account.
 Iterator<ServerStoredDetails.GenericDetail> getAllAvailableDetails()
          Returns all details currently available and set for our account.
(package private) static Locale getCountry(int code)
          Returns the Locale corresponding the index coming from icq server
(package private) static int getCountryCode(Locale cLocale)
          Returns the index stored on the server corresponding the given locale
 Iterator<ServerStoredDetails.GenericDetail> getDetails(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          Returns an iterator over all details that are instances of exactly the same class as the one specified.
 Iterator<ServerStoredDetails.GenericDetail> getDetailsAndDescendants(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          Returns an iterator over all details that are instances or descendants of the specified class.
(package private) static int getInterestCode(String value)
           
(package private) static int getLanguageCode(Locale locale)
          Returns the index stored on the server corresponding the given locale
 int getMaxDetailInstances(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          The method returns the number of instances supported for a particular detail type.
(package private) static int getOccupationCode(String occupationStr)
           
(package private) static Locale getSpokenLanguage(int code)
          Returns the Locale corresponding the index coming from icq server
 Iterator<Class<? extends ServerStoredDetails.GenericDetail>> getSupportedDetailTypes()
          Returns all detail Class-es that the underlying implementation supports setting.
 boolean isDetailClassSupported(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
          Determines whether a detail class represents a detail supported by the underlying implementation or not.
 boolean removeDetail(ServerStoredDetails.GenericDetail detail)
          Removes the specified detail from the list of details stored online for this account.
 boolean replaceDetail(ServerStoredDetails.GenericDetail currentDetailValue, ServerStoredDetails.GenericDetail newDetailValue)
          Replaces the currentDetailValue detail with newDetailValue and returns true if the operation was a success or false if currentDetailValue did not previously exist (in this case an additional call to addDetail is required).
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractOperationSetServerStoredAccountInfo
addServerStoredDetailsChangeListener, fireServerStoredDetailsChangeEvent, removeServerStoredDetailsChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportedTypes

public static final Map<Class<? extends ServerStoredDetails.GenericDetail>,int[]> supportedTypes

genders

static ServerStoredDetails.GenderDetail[] genders

occupations

static String[] occupations

interestsCategories

static String[] interestsCategories
Constructor Detail

OperationSetServerStoredAccountInfoIcqImpl

public OperationSetServerStoredAccountInfoIcqImpl(InfoRetreiver infoRetreiver,
                                                  String uin,
                                                  ProtocolProviderServiceIcqImpl icqProvider)
Creates instance of OperationSetServerStoredAccountInfo for icq protocol.

Parameters:
infoRetreiver - the info retreiver
uin - our own account uin
icqProvider - the provider
Method Detail

getAllAvailableDetails

public Iterator<ServerStoredDetails.GenericDetail> getAllAvailableDetails()
Returns all details currently available and set for our account.

Returns:
a java.util.Iterator over all details currently set our account.

getDetails

public Iterator<ServerStoredDetails.GenericDetail> getDetails(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
Returns an iterator over all details that are instances of exactly the same class as the one specified.

Parameters:
detailClass - one of the detail classes defined in the ServerStoredDetails class, indicating the kind of details we're interested in.

Returns:
a java.util.Iterator over all details of specified class.

getDetailsAndDescendants

public Iterator<ServerStoredDetails.GenericDetail> getDetailsAndDescendants(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
Returns an iterator over all details that are instances or descendants of the specified class.

Parameters:
detailClass - one of the detail classes defined in the ServerStoredDetails class, indicating the kind of details we're interested in.

Returns:
a java.util.Iterator over all details that are instances or descendants of the specified class.

getMaxDetailInstances

public int getMaxDetailInstances(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
The method returns the number of instances supported for a particular detail type.

Parameters:
detailClass - the class whose max instance number we'd like to find out.

Returns:
int the maximum number of detail instances.

getSupportedDetailTypes

public Iterator<Class<? extends ServerStoredDetails.GenericDetail>> getSupportedDetailTypes()
Returns all detail Class-es that the underlying implementation supports setting.

Returns:
a java.util.Iterator over all detail classes supported by the implementation.

isDetailClassSupported

public boolean isDetailClassSupported(Class<? extends ServerStoredDetails.GenericDetail> detailClass)
Determines whether a detail class represents a detail supported by the underlying implementation or not.

Parameters:
detailClass - the class the support for which we'd like to determine.

Returns:
true if the underlying implementation supports setting details of this type and false otherwise.

addDetail

public void addDetail(ServerStoredDetails.GenericDetail detail)
               throws IllegalArgumentException,
                      OperationFailedException,
                      ArrayIndexOutOfBoundsException
Adds the specified detail to the list of details registered on-line for this account. If such a detail already exists its max instance number is consulted and if it allows it - a second instance is added or otherwise and illegal argument exception is thrown. An IllegalArgumentException is also thrown in case the class of the specified detail is not supported by the underlying implementation, i.e. its class name was not returned by the getSupportedDetailTypes() method.

Parameters:
detail - the detail that we'd like registered on the server.

Throws:
IllegalArgumentException - if such a detail already exists and its max instances number has been atteined or if the underlying implementation does not support setting details of the corresponding class.
OperationFailedException - with code Network Failure if putting the new value online has failed
ArrayIndexOutOfBoundsException - if the number of instances currently registered by the application is already equal to the maximum number of supported instances (@see getMaxDetailInstances())

removeDetail

public boolean removeDetail(ServerStoredDetails.GenericDetail detail)
                     throws OperationFailedException
Removes the specified detail from the list of details stored online for this account.

Parameters:
detail - the detail to remove
Returns:
true if the specified detail existed and was successfully removed and false otherwise.
Throws:
OperationFailedException - with code Network Failure if removing the detail from the server has failed

replaceDetail

public boolean replaceDetail(ServerStoredDetails.GenericDetail currentDetailValue,
                             ServerStoredDetails.GenericDetail newDetailValue)
                      throws ClassCastException,
                             OperationFailedException
Replaces the currentDetailValue detail with newDetailValue and returns true if the operation was a success or false if currentDetailValue did not previously exist (in this case an additional call to addDetail is required).

Parameters:
currentDetailValue - the detail value we'd like to replace.
newDetailValue - the value of the detail that we'd like to replace currentDetailValue with.
Returns:
boolean
Throws:
ClassCastException - if newDetailValue is not an instance of the same class as currentDetailValue.
OperationFailedException - with code Network Failure if putting the new value back online has failed

getCountry

static Locale getCountry(int code)
Returns the Locale corresponding the index coming from icq server

Parameters:
code - int
Returns:
Locale

getCountryCode

static int getCountryCode(Locale cLocale)
Returns the index stored on the server corresponding the given locale

Parameters:
cLocale - Locale
Returns:
int

getSpokenLanguage

static Locale getSpokenLanguage(int code)
Returns the Locale corresponding the index coming from icq server

Parameters:
code - int
Returns:
Locale

getLanguageCode

static int getLanguageCode(Locale locale)
Returns the index stored on the server corresponding the given locale

Parameters:
locale - Locale
Returns:
int

getOccupationCode

static int getOccupationCode(String occupationStr)
Parameters:
occupationStr - String
Returns:
int

getInterestCode

static int getInterestCode(String value)
Parameters:
value - String
Returns:
int

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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