org.openorb.util
Class RepoIDHelper

java.lang.Object
  |
  +--org.openorb.util.RepoIDHelper

public final class RepoIDHelper
extends Object

This class provides helper methods for repositiory id handling.

Version:
$Revision: 1.8 $ $Date: 2004/05/13 02:25:33 $
Author:
Chris Wood

Field Summary
static int TYPE_DEFAULT_FACTORY
          A default factory type (???).
static int TYPE_HELPER
          A helper class type (ITFHelper.java).
static int TYPE_HOLDER
          A holder class type (ITFHolder.java).
static int TYPE_IMPLBASE
          An implbase class type (ITFImplBase.java (BOA)).
static int TYPE_OPERATIONS
          A operations class type (ITFOperations.java).
static int TYPE_PLAIN
          A plain class type (ITF.java).
static int TYPE_POA
          A POA class type (ITFPOA.java).
static int TYPE_POATIE
          A POA tie class type (ITFPOATie.java).
static int TYPE_STUB
          A stub class type (ITFStub.java).
static int TYPE_TIE
          A tie class type (_ITFTie.java).
 
Method Summary
static long calculateStructuralHash(Class clz)
          Calculate the structural hash code as described in 10.6.2 RMI Hashed Format.
static boolean checkID(String id)
          This methods checks whether the passed repository identifier is valid or not.
static boolean checkIdentifier(String name)
          This methods checks an indetifier for validity in the target language.
static Object createIsATest(String id)
          This returns an object which can be used to test if some other repository ID is an instance of this one.
static String decorate(String name, int type)
          This methods decorates a class name with the suffixes depending on the type of the class about to be created.
static String[] extractClassName(Class clz)
          Mangle the java class name into the package and class name parts.
static String getRepoID(Class clz)
          The syntax of the repository ID is the standard OMG RMI Hashed format (10.6.2 RMI Hashed Format) with an initial "RMI:" followed by the Java class name, followed by a hash code string, followed optionally by a serialization Version UID string.
static long getRepoIDHash(Class clz)
          The syntax of the repository ID is the standard OMG RMI Hashed format (10.6.2 RMI Hashed Format) with an initial "RMI:" followed by the Java class name, followed by a hash code string, followed optionally by a serialization Version UID string.
static String idToClass(String name)
          This method tries to extract the class name from the repository id.
static String idToClass(String name, int type)
          This method tries to extract the class name from the repository id.
static String idToClassname(String name)
          Convert the repository id to a class name.
static String idToPackage(String name)
          Extract the Java package name from the IDL repository identifier.
static String[] mangleClassName(Class clz)
          Mangle the java classname, replacing non latin-1 chars with unicode escapes.
static void mangleMemberNames(Class clz, String[] memberNames)
          Mangle the member names.
static String unmangleClassName(String className)
          Unmangle the java classname, replacing the escapes with unicode chars.
static String unmangleRepoIDtoClassName(String repoID)
          Unmangle the repo ID into the class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_PLAIN

public static final int TYPE_PLAIN
A plain class type (ITF.java).

TYPE_STUB

public static final int TYPE_STUB
A stub class type (ITFStub.java).

TYPE_HELPER

public static final int TYPE_HELPER
A helper class type (ITFHelper.java).

TYPE_HOLDER

public static final int TYPE_HOLDER
A holder class type (ITFHolder.java).

TYPE_DEFAULT_FACTORY

public static final int TYPE_DEFAULT_FACTORY
A default factory type (???).

TYPE_OPERATIONS

public static final int TYPE_OPERATIONS
A operations class type (ITFOperations.java).

TYPE_IMPLBASE

public static final int TYPE_IMPLBASE
An implbase class type (ITFImplBase.java (BOA)).

TYPE_POA

public static final int TYPE_POA
A POA class type (ITFPOA.java).

TYPE_POATIE

public static final int TYPE_POATIE
A POA tie class type (ITFPOATie.java).

TYPE_TIE

public static final int TYPE_TIE
A tie class type (_ITFTie.java).
Method Detail

decorate

public static String decorate(String name,
                              int type)
This methods decorates a class name with the suffixes depending on the type of the class about to be created.
Parameters:
name - The class name to be decorated.
type - The type of the class about to be created.
Returns:
The decorated name.

checkID

public static boolean checkID(String id)
This methods checks whether the passed repository identifier is valid or not.
Parameters:
id - The repository id to check.
Returns:
True if id is a valid repository identifier, false otherwise.

checkIdentifier

public static boolean checkIdentifier(String name)
This methods checks an indetifier for validity in the target language. The identifier must match the following pattern ([a-z][A-Z])+([a-z][A-Z_][0-9])*.
Parameters:
name - The identifier to check.
Returns:
True if ??? false otherwise.

idToPackage

public static String idToPackage(String name)
Extract the Java package name from the IDL repository identifier.
Parameters:
name - The repository id to extract the package name from.
Returns:
The package information converted from the repository id.

idToClassname

public static String idToClassname(String name)
Convert the repository id to a class name.
Parameters:
name - The repository id to extract the class name from.
Returns:
The name of the class extracted from the repository id.

idToClass

public static String idToClass(String name)
This method tries to extract the class name from the repository id.
Parameters:
name - The repository id name.
Returns:
The Java class name for the repository id.

idToClass

public static String idToClass(String name,
                               int type)
This method tries to extract the class name from the repository id.
Parameters:
name - The repository id name.
type - The type of the class to create.
Returns:
The Java class name for the repository id.

createIsATest

public static Object createIsATest(String id)
This returns an object which can be used to test if some other repository ID is an instance of this one.

Examples:

 RepoIDHelper.createIsATest( "IDL:MyObj:1.0" ).equals(
         "IDL:MyObj:1.0" ) == true
 RepoIDHelper.createIsATest( "IDL:MyObj:1.1" ).equals(
         "IDL:MyObj:1.0" ) == true
 RepoIDHelper.createIsATest( "IDL:MyObj:1.0" ).equals(
         "IDL:MyObj:1.1" ) == false
 RepoIDHelper.createIsATest( "IDL:MyObj:2.0" ).equals(
         "IDL:MyObj:1.1" ) == false
 
Parameters:
id - The repository id to test.
Returns:
The test object or the id if the parsing failed.

mangleClassName

public static String[] mangleClassName(Class clz)
Mangle the java classname, replacing non latin-1 chars with unicode escapes. This returns a two element array, the first is the mangled class name, the second is the short name. These are used in repository IDs.
Parameters:
clz - The class name to mangle.
Returns:
The two element string array.

unmangleClassName

public static String unmangleClassName(String className)
Unmangle the java classname, replacing the escapes with unicode chars.
Parameters:
className - The class name to unmangle.
Returns:
the unmangled class name.

extractClassName

public static String[] extractClassName(Class clz)
Mangle the java class name into the package and class name parts.
Parameters:
clz - The fully qualified class name.
Returns:
A 2 element string array, first element is the package name, second element is the class name.

mangleMemberNames

public static void mangleMemberNames(Class clz,
                                     String[] memberNames)
Mangle the member names. The array elements will be replaced with the mangled names.
Parameters:
clz - The class name to check for member name collisions.
memberNames - The members to mangle.

unmangleRepoIDtoClassName

public static String unmangleRepoIDtoClassName(String repoID)
Unmangle the repo ID into the class name.
Parameters:
repoID - The repository id to unmangle.
Returns:
the classname, or null for failure.

getRepoID

public static String getRepoID(Class clz)
The syntax of the repository ID is the standard OMG RMI Hashed format (10.6.2 RMI Hashed Format) with an initial "RMI:" followed by the Java class name, followed by a hash code string, followed optionally by a serialization Version UID string.

getRepoIDHash

public static long getRepoIDHash(Class clz)
The syntax of the repository ID is the standard OMG RMI Hashed format (10.6.2 RMI Hashed Format) with an initial "RMI:" followed by the Java class name, followed by a hash code string, followed optionally by a serialization Version UID string.

calculateStructuralHash

public static long calculateStructuralHash(Class clz)
Calculate the structural hash code as described in 10.6.2 RMI Hashed Format.
Parameters:
clz - The class to calculate the structural hash code for.
Returns:
The structural hash code.