fipaos.mts
Class IOR

java.lang.Object
  |
  +--fipaos.mts.IOR

public class IOR
extends java.lang.Object

The IOR class is used to model a CORBA IOR. It allows the retrieval and storage of the component parts of an IOR and the construction and parsing of 'stringified' IORs that can be used in the stringToObject methods of an ORB.


Field Summary
static java.lang.String TAG_GIOP
           
static java.lang.String TAG_IIOP
           
 
Constructor Summary
IOR(java.lang.String hex_ior)
          Constructs an IOR object from a stringified IOR.
IOR(java.lang.String IDL, java.util.List hosts, java.util.List ports, java.util.List object_keys)
          Constructs an IOR object with multiple profiles using the information specified.
IOR(java.lang.String IDL, java.lang.String host, int port, java.lang.String object_key)
          Constructs an IOR object using the information specified.
 
Method Summary
 int addProfile(java.lang.String host, int port, java.lang.String object_key)
          Adds a new profile to the IOR containing the specified information.
 java.lang.String getHost()
          Returns the host name of the current profile of the IOR.
 java.lang.String getHost(int profile)
          Returns the host name of the indicated profile of the IOR.
 java.lang.String getIDL()
          Returns the IDL currently in use by this IOR.
 java.lang.String getObjectKey()
          Returns the object key of the current profile of the IOR.
 java.lang.String getObjectKey(int profile)
          Returns the object key of the indicated profile of the IOR.
 int getPort()
          Returns the port number of the current profile of the IOR.
 int getPort(int profile)
          Returns the port of the indicated profile of the IOR.
 int getProfileCount()
          Returns the number of profiles currently in the IOR.
 java.lang.String getTag()
          Returns the profile type tag of the current profile of the IOR.
 java.lang.String getTag(int profile)
          Returns the profile type tag of the indicated profile of the IOR.
 int insertProfile(int profile, java.lang.String host, int port, java.lang.String object_key)
          Inserts a new profile to the IOR containing the specified information into the specified profile position.
 boolean isBigEndian()
          Indicates whether this IOR is encoded in a big or little endian way.
 void isBigEndian(boolean endian)
          Sets the endianness of this IOR.
static void main(java.lang.String[] args)
          When run from the command line this class will load an IOR from the file specified as an argument, parse it and echo the results back to STDOUT.
 int removeProfile(int profile)
          Removes the specified profile from the IOR.
 void setHost(int profile, java.lang.String host)
          Sets the host name for the indicated profile of the IOR.
 void setHost(java.lang.String host)
          Sets the host name for the current profile of the IOR.
 void setIDL(java.lang.String idl)
          Sets the IDL to use for this IOR.
 void setObjectKey(int profile, java.lang.String obj_key)
          Sets the object key for the indicated profile of the IOR.
 void setObjectKey(java.lang.String obj_key)
          Sets the object key for the current profile of the IOR.
 void setPort(int port)
          Sets the port for the current profile of the IOR.
 void setPort(int profile, int port)
          Sets the port for the indicated profile of the IOR.
 void setTag(int profile, java.lang.String tag)
          Sets the profile type tag for the indicated profile of the IOR.
 void setTag(java.lang.String tag)
          Sets the profile type tag for the current profile of the IOR.
 java.lang.String toString()
          Converts the IOR object to a hexadecimal CDR 'stringified' representation, suitable for transmission to other ORBs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_IIOP

public static final java.lang.String TAG_IIOP

TAG_GIOP

public static final java.lang.String TAG_GIOP
Constructor Detail

IOR

public IOR(java.lang.String hex_ior)
Constructs an IOR object from a stringified IOR. Stringified IORs are returned by ORBs as an easily transmissable form of an IOR, usually by calling the objectToString() method. They are large strings of hexadecimal characters and begin with 'IOR:'.
Parameters:
A - hexadecimal string representing a stringified IOR.

IOR

public IOR(java.lang.String IDL,
           java.lang.String host,
           int port,
           java.lang.String object_key)
Constructs an IOR object using the information specified.
Parameters:
IDL - The IDL that is to be used for the IOR. This will be a string name, for example: 'IDL:FIPA_Agent_97'
host - The host name or IP address of the machine that this IOR represents e.g. host.domain.com
port - The port of the target machine
object_key - The object key section of the actual IOR of the target object. Object keys are ORB specific so this must be supplied by retrieving it from the ORB used to create the original IOR. It can be retrieved either by method call on the ORB, or by parsing a stringified IOR.

IOR

public IOR(java.lang.String IDL,
           java.util.List hosts,
           java.util.List ports,
           java.util.List object_keys)
Constructs an IOR object with multiple profiles using the information specified. Multiple profile IORs are very uncommon. The lists passed as parameters must have the corresponding sections for each profile in the correct position in each list and all lists must have the same number of elements.
Parameters:
IDL - The IDL that is to be used for the IOR. This will be a string name, for example: 'IDL:FIPA_Agent_97'
hosts - A list of host names or IP address of the machine that this IOR represents e.g. host.domain.com
port - A list of ports of the target machine
object_key - A list of object key sections of the actual IOR of the target object. Object keys are ORB specific so this must be supplied by retrieving it from the ORB used to create the original IOR. It can be retrieved either by method call on the ORB, or by parsing a stringified IOR.
Method Detail

getIDL

public java.lang.String getIDL()
Returns the IDL currently in use by this IOR. This will be the same for all profiles in the IOR.
Returns:
The IDL used in this IOR

setIDL

public void setIDL(java.lang.String idl)
Sets the IDL to use for this IOR. If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called, the hex output will have been modified to list the new IDL name. This IDL will be the same for all profiles in the IOR.
Parameters:
idl - The IDL to use for this IOR

isBigEndian

public boolean isBigEndian()
Indicates whether this IOR is encoded in a big or little endian way.
Returns:
True if the IOR is big endian, false otherwise

isBigEndian

public void isBigEndian(boolean endian)
Sets the endianness of this IOR.
Parameters:
The - endianness flag- true is big endian, false is little endian

setHost

public void setHost(java.lang.String host)
Sets the host name for the current profile of the IOR. If only one profile is used (in most cases) then this sets the host name for the IOR. If more than one profile is in use, then this method sets the host name for the latest profile to be added to the IOR (i.e. the one with the highest index number). If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new host name.
Parameters:
host - The host name (or IP address) to set in the IOR

setHost

public void setHost(int profile,
                    java.lang.String host)
Sets the host name for the indicated profile of the IOR. If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new host name.
Parameters:
profile - The index number of the profile to modify in this IOR
host - The host name (or IP address) to set in the IOR

getHost

public java.lang.String getHost()
Returns the host name of the current profile of the IOR. If only one profile is in use (most cases) then the host name for the whole IOR is returned. For a multiple profile IOR, then the host name of the latest profile to be added (i.e. the one with the highest index number) is returned.
Returns:
The host name of the IOR, or of the current IOR profile

getHost

public java.lang.String getHost(int profile)
Returns the host name of the indicated profile of the IOR.
Parameters:
profile - The index number of the profile to access
Returns:
The host name of the indicated IOR profile

setPort

public void setPort(int port)
Sets the port for the current profile of the IOR. If only one profile is used (in most cases) then this sets the port for the IOR. If more than one profile is in use, then this method sets the port for the latest profile to be added to the IOR (i.e. the one with the highest index number). If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new port.
Parameters:
port - The port number to set in the IOR

setPort

public void setPort(int profile,
                    int port)
Sets the port for the indicated profile of the IOR. If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new port.
Parameters:
profile - The index number of the profile to modify in this IOR
port - The port to set in the IOR

getPort

public int getPort()
Returns the port number of the current profile of the IOR. If only one profile is in use (most cases) then the port for the whole IOR is returned. For a multiple profile IOR, then the port of the latest profile to be added (i.e. the one with the highest index number) is returned.
Returns:
The port of the IOR, or of the current IOR profile

getPort

public int getPort(int profile)
Returns the port of the indicated profile of the IOR.
Parameters:
profile - The index number of the profile to access
Returns:
The port of the indicated IOR profile

setObjectKey

public void setObjectKey(java.lang.String obj_key)
Sets the object key for the current profile of the IOR. If only one profile is used (in most cases) then this sets the object key for the IOR. If more than one profile is in use, then this method sets the object key for the latest profile to be added to the IOR (i.e. the one with the highest index number). If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new object key.
Parameters:
obj_key - The object key to set in the IOR

setObjectKey

public void setObjectKey(int profile,
                         java.lang.String obj_key)
Sets the object key for the indicated profile of the IOR. If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new object key.
Parameters:
profile - The index number of the profile to modify in this IOR
obj_key - The object key to set in the IOR

getObjectKey

public java.lang.String getObjectKey()
Returns the object key of the current profile of the IOR. If only one profile is in use (most cases) then the object key for the whole IOR is returned. For a multiple profile IOR, then the object key of the latest profile to be added (i.e. the one with the highest index number) is returned.
Returns:
The object key of the IOR, or of the current IOR profile

getObjectKey

public java.lang.String getObjectKey(int profile)
Returns the object key of the indicated profile of the IOR.
Parameters:
profile - The index number of the profile to access
Returns:
The object key of the indicated IOR profile

setTag

public void setTag(java.lang.String tag)
Sets the profile type tag for the current profile of the IOR. If only one profile is used (in most cases) then this sets the profile type tag for the IOR. If more than one profile is in use, then this method sets the profile type tag for the latest profile to be added to the IOR (i.e. the one with the highest index number). If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new profile type tag.
Parameters:
tag - The profile type tag to set in the IOR

setTag

public void setTag(int profile,
                   java.lang.String tag)
Sets the profile type tag for the indicated profile of the IOR. If the IOR was constructed from a stringified IOR then when the toString method of this IOR is called then the hex output will be modified to show the new profile type tag.
Parameters:
profile - The index number of the profile to modify in this IOR
tag - The profile type tag to set in the IOR

getTag

public java.lang.String getTag()
Returns the profile type tag of the current profile of the IOR. If only one profile is in use (most cases) then the profile type tag for the whole IOR is returned. For a multiple profile IOR, then the profile type tag of the latest profile to be added (i.e. the one with the highest index number) is returned.
Returns:
The profile type tag of the IOR, or of the current IOR profile

getTag

public java.lang.String getTag(int profile)
Returns the profile type tag of the indicated profile of the IOR.
Parameters:
profile - The index number of the profile to access
Returns:
The profile type tag of the indicated IOR profile

addProfile

public int addProfile(java.lang.String host,
                      int port,
                      java.lang.String object_key)
Adds a new profile to the IOR containing the specified information. The new profile is added to the end of the profile chain, and has an index number equal to the total number of profiles currently in the IOR. The index number is incremented after addition to reflect the inclusion of the new profile.
Parameters:
host - The host name or IP address to use in this profile
port - The port number to use in this profile
object_key - The object key to use in this profile
Returns:
The number of profiles now present in the IOR (including the one just added)

insertProfile

public int insertProfile(int profile,
                         java.lang.String host,
                         int port,
                         java.lang.String object_key)
Inserts a new profile to the IOR containing the specified information into the specified profile position. The new profile is inserted into the profile chain at the index number specified and all of the profiles following it are re-indexed.
Parameters:
profile - The index number at which to insert this profile
host - The host name or IP address to use in this profile
port - The port number to use in this profile
object_key - The object key to use in this profile
Returns:
The number of profiles now present in the IOR (including the one just inserted)

removeProfile

public int removeProfile(int profile)
Removes the specified profile from the IOR. After removal, all of the other profiles in the IOR are renumbered to reflect their new positions (if they have moved). The number of profiles left in the IOR is returned by this method.
Parameters:
profile - The index number of the profile to remove
Returns:
The number of profile left in the IOR after the removal operation

getProfileCount

public int getProfileCount()
Returns the number of profiles currently in the IOR.
Returns:
The profile count

toString

public java.lang.String toString()
Converts the IOR object to a hexadecimal CDR 'stringified' representation, suitable for transmission to other ORBs. This representation is properly encoded and can be used in the stringToObject methods of ORBs in order to invoke remote method calls on the object represented by this IOR.
Overrides:
toString in class java.lang.Object
Returns:
A stringified representation of this IOR

main

public static void main(java.lang.String[] args)
When run from the command line this class will load an IOR from the file specified as an argument, parse it and echo the results back to STDOUT. This is useful as a debugging tool, as it can show you the IORs contents in a human readable form. A second optional argument can be given - verbose mode (-v) - which prints out more information.