blob: 272273cd01ca6f722edbe4aa9b54de74a4bffc05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.jabber;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.*;
/**
* @author Damian Minkov
*/
public class OperationSetServerStoredContactInfoJabberImpl
implements OperationSetServerStoredContactInfo
{
private InfoRetreiver infoRetreiver = null;
protected OperationSetServerStoredContactInfoJabberImpl(
InfoRetreiver infoRetreiver)
{
this.infoRetreiver = infoRetreiver;
}
/**
* returns the user details from the specified class or its descendants
* the class is one from the
* net.java.sip.communicator.service.protocol.ServerStoredDetails
* or implemented one in the operation set for the user info
*
* @param contact Contact
* @param detailClass Class
* @return Iterator
*/
public Iterator<GenericDetail> getDetailsAndDescendants(
Contact contact,
Class<? extends GenericDetail> detailClass)
{
List<GenericDetail> details
= infoRetreiver.getContactDetails(contact.getAddress());
List<GenericDetail> result = new LinkedList<GenericDetail>();
if(details == null)
return result.iterator();
for (GenericDetail item : details)
if(detailClass.isInstance(item))
result.add(item);
return result.iterator();
}
/**
* returns the user details from the specified class
* exactly that class not its descendants
*
* @param contact Contact
* @param detailClass Class
* @return Iterator
*/
public Iterator<GenericDetail> getDetails(
Contact contact,
Class<? extends GenericDetail> detailClass)
{
List<GenericDetail> details
= infoRetreiver.getContactDetails(contact.getAddress());
List<GenericDetail> result = new LinkedList<GenericDetail>();
if(details == null)
return result.iterator();
for (GenericDetail item : details)
if(detailClass.equals(item.getClass()))
result.add(item);
return result.iterator();
}
/**
* request the full info for the given uin
* waits and return this details
*
* @param contact Contact
* @return Iterator
*/
public Iterator<GenericDetail> getAllDetailsForContact(Contact contact)
{
List<GenericDetail> details
= infoRetreiver.getContactDetails(contact.getAddress());
if(details == null)
return new LinkedList<GenericDetail>().iterator();
else
return new LinkedList<GenericDetail>(details).iterator();
}
}
|