cnrg.itx.ds
Class Location

java.lang.Object
  |
  +--cnrg.itx.ds.Location

public class Location
extends java.lang.Object
implements java.io.Serializable

This class provides a abstraction of where the application or system is located.
There are 3 properties:
1. Type - type of location: Telephone or Internet or User (e.g. bergmark@cs.cornell.edu, vmailsrv, etc)
2. Value - hostname:port or areacode-phonenumber or userid
3. Label - alias (standard) name of the location. E.g. "home"; "Spot"

See Also:
Serialized Form

Field Summary
static int DEFAULT
           
static int DYNAMIC
           
static java.lang.String INTERNET_TYPE
           
private  java.lang.String m_label
           
private  java.lang.String m_type
           
private  java.lang.String m_value
           
static int ROAMING
           
private static java.lang.String SEPARATOR_INTERNET
           
private static java.lang.String SEPARATOR_LOCATION
           
private static java.lang.String SEPARATOR_TELEPHONE
           
static java.lang.String TELEPHONE_TYPE
           
static java.lang.String USER_TYPE
           
 
Constructor Summary
Location(Location otherLoc)
          Copy constructor
Location(java.lang.String rawLocationStr)
          Constructor for formatted record string retrieved from the directory database.
Location(java.lang.String type, java.lang.String value, java.lang.String label)
          Constructor
For telephone: type = Location.TELEPHONE_TYPE; value = Areacode-PhoneNumber; label = "home"
e.g.
 
Method Summary
 java.lang.String[] enumerateValue()
          Parses the value of location into a array of string and returns
e.g.
 java.lang.String getIP()
          Return the hostname address if this location can be directly dialed.
 java.lang.String getLabel()
          Get the Location (optional) label
 int getPort()
          Return the port number if this location can be directly dialed.
 java.lang.String getType()
          Get the Location type
 UserID getUID()
          Return the UID of this user-type location (if this is a internet-type location, returns null).
 java.lang.String getValue()
          Get the Location value
 boolean isDialable()
          Determine if this location can be directly dialed (connected)
 boolean isPhone()
          Determine if the Location is destined to the telephone end
 boolean isSameAs(Location otherlocation)
          Compares with other location object to determine if they are identical
 void setLabel(java.lang.String label)
          Set the Location (optional) label
 java.lang.String toString()
          Convert into raw location string format.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

TELEPHONE_TYPE

public static final java.lang.String TELEPHONE_TYPE

INTERNET_TYPE

public static final java.lang.String INTERNET_TYPE

USER_TYPE

public static final java.lang.String USER_TYPE

ROAMING

public static final int ROAMING

DEFAULT

public static final int DEFAULT

DYNAMIC

public static final int DYNAMIC

SEPARATOR_LOCATION

private static final java.lang.String SEPARATOR_LOCATION

SEPARATOR_INTERNET

private static final java.lang.String SEPARATOR_INTERNET

SEPARATOR_TELEPHONE

private static final java.lang.String SEPARATOR_TELEPHONE

m_type

private java.lang.String m_type

m_value

private java.lang.String m_value

m_label

private java.lang.String m_label
Constructor Detail

Location

public Location(Location otherLoc)
Copy constructor
Parameters:
otherLoc - other location object

Location

public Location(java.lang.String rawLocationStr)
Constructor for formatted record string retrieved from the directory database. If the record string is not in expected format, the location remains un-initialized.
Parameters:
rawLocationStr - a raw string from record entry (e.g. "pit052.cs.cornell.edu:5000+I+testapp"; "607-2775627+T"; "vmailsrv+U+voice mail server")

Location

public Location(java.lang.String type,
                java.lang.String value,
                java.lang.String label)
Constructor
For telephone: type = Location.TELEPHONE_TYPE; value = Areacode-PhoneNumber; label = "home"
e.g. SetLocation(Location.TELEPHONE_TYPE, "607-2551595", "home");
For internet: type = Location.INTERNET_TYPE; value = hostname:port; label = App. name
e.g. SetLocation(Location.INTERNET_TYPE, "pnt01.cs.cornell.edu:5001", "Moonlight");
For user: type = Location.USER_TYPE; value = email OR server; label = [applicable name]
e.g. SetLocation(Location.USER_TYPE, "bergmark@cs.cornell.edu", "");
Parameters:
type - type of the location (e.g. Location.TELEPHONE_TYPE or Location.INTERNET_TYPE or Location.USER_TYPE)
value - value of the location
label - label of the location (can be empty)
Method Detail

isDialable

public boolean isDialable()
Determine if this location can be directly dialed (connected)
Returns:
True if it can be dialied; False otherwise

getIP

public java.lang.String getIP()
Return the hostname address if this location can be directly dialed. Otherwise, return null.
Returns:
string value containing the hostname address; null otherwise

getPort

public int getPort()
Return the port number if this location can be directly dialed. Otherwise, returns -1.
Returns:
int value containing the port number; -1 otherwise

getUID

public UserID getUID()
Return the UID of this user-type location (if this is a internet-type location, returns null).
Returns:
UserID object of the user-type location

getType

public java.lang.String getType()
Get the Location type
Returns:
location type in string

getValue

public java.lang.String getValue()
Get the Location value
Returns:
location value in string

getLabel

public java.lang.String getLabel()
Get the Location (optional) label
Returns:
location label in string

setLabel

public void setLabel(java.lang.String label)
Set the Location (optional) label
Parameters:
label - location label in string

isPhone

public boolean isPhone()
Determine if the Location is destined to the telephone end
Returns:
true if the location is destined to the telephone end; false otherwise

isSameAs

public boolean isSameAs(Location otherlocation)
Compares with other location object to determine if they are identical
Parameters:
otherlocation - other location object to be compared
Returns:
true if identical; false otherwise

toString

public java.lang.String toString()
Convert into raw location string format. Returns empty if the location object's properties are not sufficient enough to form a string.
Returns:
string representation of the location object.
Overrides:
toString in class java.lang.Object

enumerateValue

public java.lang.String[] enumerateValue()
Parses the value of location into a array of string and returns
e.g. String[0] = "pnt01.cs.cornell.edu"; String[1] = "5001"
e.g. String[0] = "607"; String[1] = "2551595"
e.g. String[0] = "bergmark@cs.cornell.edu"
Returns:
an array of string; null if not applicable