hp.opencall.media.common
Class E164Address

java.lang.Object
  extended byhp.opencall.media.common.Address
      extended byhp.opencall.media.common.E164Address
All Implemented Interfaces:
Cloneable

public class E164Address
extends Address

Holds E164 addresses as an arbitrary number of digits optionally followed by :

- an arbitrary number of #, where # means one digit of any value.
- a *, as a wildcard for any number of digits.

Examples : 0476, 0476####, 0458*, ...

Since:
OCMP 2.0

Constructor Summary
E164Address(String aString, int length)
          Creates a E164Address from a String.
 
Method Summary
 boolean equals(Object anAdd)
          Indicates whether the two E164 addresses are equal.
 String getString()
          Returns the address as a String.
 boolean greater(Address anAddr)
          Indicates whether this address is greater than the passed address.
 boolean isInternalAddress()
          FOR FUTURE USE.
 boolean overlap(Address anAddress)
          Compares E164 addresses containing wildcards.
 String toString()
          Returns the address as a String.
 
Methods inherited from class hp.opencall.media.common.Address
hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

E164Address

public E164Address(String aString,
                   int length)
            throws InvalidAddressFormat
Creates a E164Address from a String.

Parameters:
aString - The E164 address string, e.g. 34###
length - The string length.

For example: E164Address("34###",5)

Method Detail

getString

public String getString()
Returns the address as a String.


equals

public boolean equals(Object anAdd)
Indicates whether the two E164 addresses are equal.

Equality is checked by the following simple rules:

0476 == 0476
0476# == 04769
0476* == 04762584488
0476* == 047645######
0476* == 047##

This method is reflexive and symmetric, but not transitive. If you want to use E164Address as keys in hashtables, you should use a subset of addresse for which the method is also transitive, typically addresses without * or #.

Overrides:
equals in class Address
Returns:
true if the addresses are equal (non wildcard addresses) or if the address is within the range defined by the wildcard.

greater

public boolean greater(Address anAddr)
Indicates whether this address is greater than the passed address.

This method is transitive.
The convention is that a E164Address is greater than any other instance of classes extending Address.

The following rules apply for the comparison :
1. An address with a * is greater than an address without *.
2. If the two addresses have a *, the greatest is the longest. If they have the same length, the digits are compared.
3. For the other addresses, the length is compared first. The longest is the greatest. If they have the same length, digits are compared until a # is found.If they have the same digits up to the first #, the greatest is the one with the largest number of #. Then if they have the same number of # they are equal.

Overrides:
greater in class Address

toString

public String toString()
Returns the address as a String.

This should be equivalent to getString().

Overrides:
toString in class Address

overlap

public boolean overlap(Address anAddress)
Compares E164 addresses containing wildcards.

Overrides:
overlap in class Address
Returns:
true if the two addresses are wildcards and if their ranges overlap.

isInternalAddress

public boolean isInternalAddress()
FOR FUTURE USE.

Returns:
true if this is an Internal address.