net.rim.pushsdk.pap.control
Class AddressList

java.lang.Object
  extended by net.rim.pushsdk.pap.control.AddressList

public class AddressList
extends Object

Represents a list of addresses (e.g. PINs, email addresses, etc.).

Author:
mdicesare

Field Summary
static String BES_ADDRESS_PREFIX
          Each BES address in PAP must have the specified prefix.
static String BES_ADDRESS_SUFFIX
          Each BES address in PAP must have the specified suffix.
static String BES_PUSH_ALL_NOT_ALLOWED_ERROR_MSG
          Error message indicating that enterprise (BES) does not support performing a push_all.
static String PUSH_ALL
          Deprecated. Use Constants.PUSH_ALL instead.
 
Constructor Summary
AddressList()
          Default address list constructor.
AddressList(boolean shouldPushAll)
          Constructs an address list with the push_all token, if the given boolean is set to true.
AddressList(String address)
          Constructs an address list with a single address.
 
Method Summary
 void add(String address)
          Adds an address to the address list.
 void add(String address, boolean parseBESAddress)
          Adds an address to the address list and parses it as a enterprise (BES) address if requested.
 void addAll(Collection<String> addresses)
          Adds a collection of addresses to the address list.
 void clear()
          Clears the address list of all the existing addresses.
 boolean contains(String address)
          Whether or not the address list contains the specified address.
 boolean containsAll(Collection<String> addresses)
          Whether or not the address list contains the collection of addresses.
 boolean equals(Object obj)
          Returns true if two address lists are found to be equal and false otherwise.
static String formatBESAddress(String address)
          Formats an address so that it is in the expected format for a PAP push sent through enterprise (BES).
 int hashCode()
          Returns a hashcode for this address list.
 boolean isEmpty()
          Whether or not the address list is empty.
static boolean isPushAll(List<String> addresses)
          Determines if the list of addresses is a push_all (i.e.
static boolean isPushAll(String address)
          Determines if the address is the push_all token (the case is ignored).
static String parseBESAddress(String address)
          Parses out the address from how it appears in a PAP push sent through enterprise (BES).
 String print()
          Deprecated. As of release 1.1, replaced by print(boolean).
 String print(boolean usingPublicPush)
          Returns a string containing the address list wrapped in PAP XML tags.
 boolean remove(String address)
          Removes an address from the address list.
 boolean removeAll(Collection<String> addresses)
          Removes a collection of addresses from the address list.
 boolean retainAll(Collection<String> addresses)
          Retains only those addresses in the address list that are also in the specified collection of addresses.
 void setPushSDKProperties(PushSDKProperties pushSDKProperties)
          Deprecated. As of release 1.1, replaced by print(boolean) and validate(boolean, boolean) for indicating whether this address list applies to a public (BIS) operation or an enterprise (BES) operation.
 int size()
          Gets the size of the address list.
 String[] toArray()
          Gets the address list as an array of addresses (strings).
 List<String> toList()
          Gets the address list as a list of addresses (strings).
 Set<String> toSet()
          Gets the address list as a set of addresses (strings).
 String toString()
          Constructs a String with all attributes in name = value format.
 void validate()
          Deprecated. As of release 1.1, replaced by validate(boolean, boolean).
 void validate(boolean allowPushAll)
          Deprecated. As of release 1.1, replaced by validate(boolean, boolean).
 void validate(boolean usingPublicPush, boolean allowPushAll)
          Validates an address list:
- Verify that the address list is not empty.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PUSH_ALL

public static final String PUSH_ALL
Deprecated. Use Constants.PUSH_ALL instead.
See Also:
Constant Field Values

BES_PUSH_ALL_NOT_ALLOWED_ERROR_MSG

public static final String BES_PUSH_ALL_NOT_ALLOWED_ERROR_MSG
Error message indicating that enterprise (BES) does not support performing a push_all.

See Also:
Constant Field Values

BES_ADDRESS_PREFIX

public static final String BES_ADDRESS_PREFIX
Each BES address in PAP must have the specified prefix.

See Also:
Constant Field Values

BES_ADDRESS_SUFFIX

public static final String BES_ADDRESS_SUFFIX
Each BES address in PAP must have the specified suffix.

See Also:
Constant Field Values
Constructor Detail

AddressList

public AddressList()
Default address list constructor.


AddressList

public AddressList(String address)
Constructs an address list with a single address.

Parameters:
address - an address

AddressList

public AddressList(boolean shouldPushAll)
Constructs an address list with the push_all token, if the given boolean is set to true. If false, this constructor is equivalent to the default one.

Parameters:
shouldPushAll - whether or not a push all is requested
Method Detail

setPushSDKProperties

@Deprecated
public void setPushSDKProperties(PushSDKProperties pushSDKProperties)
Deprecated. As of release 1.1, replaced by print(boolean) and validate(boolean, boolean) for indicating whether this address list applies to a public (BIS) operation or an enterprise (BES) operation.

Sets the push SDK properties to be used with the address list. The relevant property for this class is whether or not we are running in public (BIS) mode or enterprise (BES) mode.

Parameters:
pushSDKProperties - the push SDK properties

add

public void add(String address)
Adds an address to the address list.

Parameters:
address - the address to add

add

public void add(String address,
                boolean parseBESAddress)
Adds an address to the address list and parses it as a enterprise (BES) address if requested.

Parameters:
address - the address to add
parseBESAddress - true if the address should be parsed as an enterprise (BES) address; false otherwise

addAll

public void addAll(Collection<String> addresses)
Adds a collection of addresses to the address list.

Parameters:
addresses - a collection of addresses to add

removeAll

public boolean removeAll(Collection<String> addresses)
Removes a collection of addresses from the address list.

Parameters:
addresses - a collection of addresses to remove
Returns:
whether or not the removal was successful

remove

public boolean remove(String address)
Removes an address from the address list.

Parameters:
address - the address to remove
Returns:
whether or not the removal was successful

contains

public boolean contains(String address)
Whether or not the address list contains the specified address.

Parameters:
address - an address
Returns:
true if the address exists in the list; false otherwise

containsAll

public boolean containsAll(Collection<String> addresses)
Whether or not the address list contains the collection of addresses.

Parameters:
addresses - a collection of addresses
Returns:
true if the addresses exist in the list; false otherwise

retainAll

public boolean retainAll(Collection<String> addresses)
Retains only those addresses in the address list that are also in the specified collection of addresses.

Parameters:
addresses - a collection of addresses
Returns:
true if the address list changed as result of this call; false otherwise

clear

public void clear()
Clears the address list of all the existing addresses.


isEmpty

public boolean isEmpty()
Whether or not the address list is empty.

Returns:
true if the address list is empty; false otherwise

size

public int size()
Gets the size of the address list.

Returns:
the number of addresses in the address list

toList

public List<String> toList()
Gets the address list as a list of addresses (strings).

Returns:
a list of addresses

toSet

public Set<String> toSet()
Gets the address list as a set of addresses (strings).

Returns:
a set of addresses

toArray

public String[] toArray()
Gets the address list as an array of addresses (strings).

Returns:
an array of addresses

isPushAll

public static boolean isPushAll(List<String> addresses)
Determines if the list of addresses is a push_all (i.e. there is one and only one address that is equal to Constants.PUSH_ALL.

Parameters:
addresses - the addresses to check
Returns:
true if push_all; false otherwise

isPushAll

public static boolean isPushAll(String address)
Determines if the address is the push_all token (the case is ignored).

Parameters:
address - the address to check
Returns:
true if push_all; false otherwise

print

@Deprecated
public String print()
Deprecated. As of release 1.1, replaced by print(boolean).

Returns a string containing the address list wrapped in PAP XML tags.

Returns:
a string in PAP XML format

print

public String print(boolean usingPublicPush)
Returns a string containing the address list wrapped in PAP XML tags.

Parameters:
usingPublicPush - true if the address list is for a public (BIS) operation; false otherwise
Returns:
a string in PAP XML format
Since:
1.1

formatBESAddress

public static String formatBESAddress(String address)
Formats an address so that it is in the expected format for a PAP push sent through enterprise (BES).

Parameters:
address - the address to be formatted
Returns:
a formatted address

parseBESAddress

public static String parseBESAddress(String address)
Parses out the address from how it appears in a PAP push sent through enterprise (BES).

Parameters:
address - the address formatted for a BES push
Returns:
the extracted address

validate

@Deprecated
public void validate()
Deprecated. As of release 1.1, replaced by validate(boolean, boolean).

Calls the validate(boolean) method with the allowPushAll argument set to true.


validate

@Deprecated
public void validate(boolean allowPushAll)
Deprecated. As of release 1.1, replaced by validate(boolean, boolean).

Validates an address list:
- Verify that the address list is not empty.
- Verify that if allowPushAll is set to false, that the address list does not contain the push_all token.
- Verify that, for enterprise (BES) mode, the push_all token is not in the address list.
- Verify that if a push_all was specified, it is the only item in the address list.

Parameters:
allowPushAll - whether a push_all is allowed

validate

public void validate(boolean usingPublicPush,
                     boolean allowPushAll)
Validates an address list:
- Verify that the address list is not empty.
- Verify that if allowPushAll is set to false, that the address list does not contain the push_all token.
- Verify that if usingPublicPush is set to false, the push_all token is not in the address list.
- Verify that if a push_all was specified, it is the only item in the address list.

Parameters:
usingPublicPush - true if the address list is for a public (BIS) operation; false otherwise
allowPushAll - whether a push_all is allowed
Since:
1.1

hashCode

public int hashCode()
Returns a hashcode for this address list.

Overrides:
hashCode in class Object
Returns:
a hashcode for this address list

equals

public boolean equals(Object obj)
Returns true if two address lists are found to be equal and false otherwise.

Overrides:
equals in class Object
Returns:
whether two address lists are equal

toString

public String toString()
Constructs a String with all attributes in name = value format.

Overrides:
toString in class Object
Returns:
a String representation of this object.


Copyright © 2011 Research In Motion. All Rights Reserved.