-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContactsFolder.java
More file actions
80 lines (65 loc) · 2.79 KB
/
Copy pathContactsFolder.java
File metadata and controls
80 lines (65 loc) · 2.79 KB
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
package javaxt.exchange;
//******************************************************************************
//** ContactFolder Class
//******************************************************************************
/**
* Used to represent a contact folder.
*
******************************************************************************/
public class ContactsFolder extends Folder {
private Connection conn;
//**************************************************************************
//** Constructor
//**************************************************************************
/** Creates a new instance of this class. */
public ContactsFolder(Connection conn) throws ExchangeException {
super("contacts", conn);
this.conn = conn;
}
//**************************************************************************
//** getContacts
//**************************************************************************
/** Returns an array of all contacts found in the contact folder.
*
public Contact[] getContacts() throws ExchangeException {
java.util.ArrayList<Contact> contacts = new java.util.ArrayList<Contact>();
int offset = 0;
int maxRecords = 25;
while(true){
Contact[] arr = getContacts(offset, maxRecords);
for (int i=0; i<arr.length; i++){
contacts.add(arr[i]);
}
if (arr.length<maxRecords) break;
else offset+=maxRecords;
}
return contacts.toArray(new Contact[contacts.size()]);
}
*/
//**************************************************************************
//** getContacts
//**************************************************************************
/** Returns an array of contacts.
* @param limit Maximum number of items to return.
* @param offset Item offset. 0 implies no offset.
*/
public Contact[] getContacts(int offset, int limit) throws ExchangeException {
java.util.ArrayList<Contact> contacts = new java.util.ArrayList<Contact>();
org.w3c.dom.NodeList nodes = getItems(offset, limit, null, null, null).getElementsByTagName("t:Contact");
for (int i=0; i<nodes.getLength(); i++){
org.w3c.dom.Node node = nodes.item(i);
if (node.getNodeType()==1){
contacts.add(new Contact(node));
}
}
return contacts.toArray(new Contact[contacts.size()]);
}
//**************************************************************************
//** getContact
//**************************************************************************
/** Returns a contact associated with the given exchangeID.
*/
public Contact getContact(String exchangeID) throws ExchangeException {
return new Contact(exchangeID, conn);
}
}