com.ls.lars.communication
Class LarsNaming

java.lang.Object
  |
  +--com.ls.lars.communication.LarsNaming

public class LarsNaming
extends Object

This class represents a simple helper for dealing with agent names. Within this class the following naming conventions are being distinguished:

localName
This name represents an agent's (or party's) name on a lars platform,
which has to be unequivocal on any single platform. This name can be
used for addressing an agent (a party) from within the local platform.
globalName
This name identifies an agent (a party) and its membership to a defined
lars platform. This name has to be unequivocal within a bundle of coupled
lars platforms and can be used for inter-platform communication.
The general format of an agent's global name is [localName]@[platformName].
platformName
This name identifies a single lars platform.
This name is contained within any defined global name.
The general format of a platform name is [ipAddress]-[larsId].
larsId
The lars id is an unequivocal identifier of a single lars platform on a machine.
This id is necessary for distinguishing multiple lars platforms running on the
same machine.

Version:
$Revision: 1.4 $
Author:
Last modified by $Author: MFehrenbach $

Method Summary
static String buildGlobalName(String name)
          returns an agent's global name by appending the '@' symbol and this platforms homePlatform.
static String buildGlobalName(String name, String platformName)
          returns an agent's global name by appending the '@' symbol and the given platform name.
static String createAgentName(String localName, String ipAddress, String larsId)
          creates an agent name from the given elements. if the ipAddress and/or the larsId is null or empty, the current platform's id will be used for creating the agent's name.
static String getLarsId(String name)
          returns the lars id as extracted from the given agent name.
static String getLocalName(String name)
          returns an agent's local name as extracted from the given name.
static String getPlatformIp(String name)
          returns a platform's ip address as extracted from the given agent name.
static String getPlatformName(String name)
          returns the platform name as extracted from the given name.
static boolean isGlobalName(String name)
          returns whether or not the given name is a global name (that is: the name contains any '@...' platform dependent information.
static boolean isLocalName(String name)
          returns whether or not the given name is a local name (that is: the name does not contain any '@...' platform dependent information.
static boolean isValidGlobalName(String name)
          returns whether or not the given name is a valid global name.
static boolean isValidIpAddress(String ipAddress)
          returns whether or not the given String represents a valid ip address.
static boolean isValidLarsId(String larsId)
          returns whether or not the given String represents a valid lars id.
static boolean isValidPlatformName(String name)
          returns whether or not the given name is a valid platform name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isValidGlobalName

public static boolean isValidGlobalName(String name)
returns whether or not the given name is a valid global name.
Parameters:
name - an agent's global name
Returns:
true, if the name is a valid global name

isValidPlatformName

public static boolean isValidPlatformName(String name)
returns whether or not the given name is a valid platform name.
Parameters:
name - a lars platform's name
Returns:
true, if the name is a valid platform name

isValidIpAddress

public static boolean isValidIpAddress(String ipAddress)
returns whether or not the given String represents a valid ip address.
Parameters:
ipAddress - the string to check
Returns:
true, if the given string is a valid representation of an ip address

isValidLarsId

public static boolean isValidLarsId(String larsId)
returns whether or not the given String represents a valid lars id.
Parameters:
larsId - the string to check
Returns:
true, if the given string is a valid lars id

isLocalName

public static boolean isLocalName(String name)
returns whether or not the given name is a local name (that is: the name does not contain any '@...' platform dependent information.
Parameters:
name - the name of the agent
Returns:
true, when the name is an agent's local name, else false

isGlobalName

public static boolean isGlobalName(String name)
returns whether or not the given name is a global name (that is: the name contains any '@...' platform dependent information.
Parameters:
name - the name of the agent
Returns:
true, when the name is an agent's global name, else false

getLocalName

public static String getLocalName(String name)
returns an agent's local name as extracted from the given name.
Parameters:
name - the name of the agent
Returns:
name, if no '@' symbol was found the prefix of name, i.e. all characters preceding the '@'

getPlatformName

public static String getPlatformName(String name)
returns the platform name as extracted from the given name.
Parameters:
name - the name of the agent
Returns:
the name of the platform (all characters trailing the '@'); MessageRouter.getHomePlatform(), if no '@' symbol was found (because then the name is assumed to be local), or name is null

getLarsId

public static String getLarsId(String name)
returns the lars id as extracted from the given agent name.
Parameters:
name - the name of the agent
Returns:
the extracted lars id, when the given name is a global one the lars id of the current platform, if name is a local one or when name is null

getPlatformIp

public static String getPlatformIp(String name)
returns a platform's ip address as extracted from the given agent name.
Parameters:
name - the name of the agent
Returns:
the extracted lars id, when the given name is a global one the lars id of the current platform, if name is a local one or when name is null

buildGlobalName

public static String buildGlobalName(String name)
returns an agent's global name by appending the '@' symbol and this platforms homePlatform.
Parameters:
name - the name of the agent
Returns:
name, if the name is already a global one the name extended by the current platforms id

buildGlobalName

public static String buildGlobalName(String name,
                                     String platformName)
returns an agent's global name by appending the '@' symbol and the given platform name. If the given platform name is null or empty, the current platform's id will be used for building the global name.
Parameters:
name - the name of the agent
platformName - the name of the platform
Returns:
name, if the name is already a global one the name extended by the given platform id

createAgentName

public static String createAgentName(String localName,
                                     String ipAddress,
                                     String larsId)
creates an agent name from the given elements. if the ipAddress and/or the larsId is null or empty, the current platform's id will be used for creating the agent's name.
Parameters:
localName - the agent's local name
ipAddress - the ip address of the agent's home platform
larsId - the id of the agent's home platform
Returns:
the created global name else