gt:         ivFullBeanName = beanName; // d369262.3
context: /*******************************************************************************
   * Copyright (c) 1998, 2015 IBM Corporation and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
   * which accompanies this distribution, and is available at
   * http://www.eclipse.org/legal/epl-v10.html
   *
   * Contributors:
   *     IBM Corporation - initial API and implementation
   *******************************************************************************/
  package com.ibm.ejs.container.util;
  
  import java.util.StringTokenizer;
  
  import com.ibm.websphere.ras.Tr;
  import com.ibm.websphere.ras.TraceComponent;
  import com.ibm.ws.javaee.dd.ejb.ComponentViewableBean;
  import com.ibm.ws.javaee.dd.ejb.EnterpriseBean;
  import com.ibm.ws.javaee.dd.ejb.Entity;
  import com.ibm.ws.javaee.dd.ejb.Session;
  
  /**
   * Common place to get deployed class names which rely on convention.
   * Also a set of utility functions for package and class names. <p>
   * 
   * Note that change of any file name implemented in this class must require
   * a parallel change in the ejbdeploy code generation process, otherwise the
   * container will never be able to find the generated classes to install
   * and/or start bean. <p>
   * 
   * Beginning with EJB 3.0, the EJB interface and class names may be configured
   * using annotations (as well as the deployment descriptor xml), so all of
   * the NameUtil methods were re-written to not require WCCM (EnterpriseBean),
   * however, all of the old method signatures must remain to maintain
   * compatibility with the existing EJBDeploy. Also, to improve performance,
   * the re-written methods were changed to instance methods, rather than static
   * methods; allowing the hashcode suffix to be computed once per EJB. <p>
   * 
   * Also introduced in EJB 3.0 were the Business Remote and Business Local
   * interfaces, and new methods were added to support these. Note that
   * EJBDeploy will not be enhanced to support these, only the new
   * Just-In-Time Deploy. <p>
   * 
   * Note that all methods, whether static or instance, will return the same
   * deployed class names, based on module version. This allows the EJB
   * Container to use the new instance methods, regardless of whether the
   * EJB is deployed using EJBDeploy (i.e. EJB 2.x or 1.x, or CMP) or
   * using the new Just-In-Time Deploy. <p>
   * 
   * For EJB 3.0, the methods produce slightly different deployed names than
   * prior EJB levels; to account for the fact that an EJB may now have
   * multiple local and remote interfaces. <p>
   * 
   * Note: Container Managed Entity beans will NOT be handled by the
   * Just-In-Time Deployer, and must still use the older naming
   * conventions to remain compatible with EJBDeploy. <p>
   * 
   * The actual format for 3.0 DTD and later (i.e. EJB3 naming convention) is:
   * 
   * EJS + (Local | Remote) + (C | N | A | <index>) + <type> + <EjbName> + _ + BuzzHash
   * 
   * Where:
   * C indicates this is for a Component interface (EJB 1.x and 2.x)
   * N indicates this is for a No-Interface View (LocalBean).
   * A indicates this is for an Aggregate view of all business interfaces
   * (local or remote)
   * index indicates this is for a Business interface, and the index
   * value is the array index for the interface in the list of
   * remote or local business interfaces.
   * type indicates the type of the EJB:
   * SG - Singleton
   * SL - Stateless
   * SF - Stateful
   * BMP - Bean Managed Entity
   * MB - ManagedBean
   * EjbName is the <ejb-name> value from the bean's deployment description
   * - ignoring all leading and trailing whites-space
   * - keeping all alphanumeric characters and replacing all other
   * characters with '_'
   * - limited to the first 32 chars
   * BuzzHash is the 8 digit hashcode of the full <ejb-name> value in the
   * bean's dd concatenated with all associated interfaces and
   * classes, including the primary key, and hashes all characters
   * as defined in the dd (i.e. no translation)
   * 
   * E.g.
   * EJSLocalCSLClaim_12345678
   * EJSRemote2SLClaim_12345678
   * EJSLocalCSLClaimHome_12345678
   * EJSCSLClaimHomeBean_12345678
   * 
   * The format for MDB's is:
   * <package name>.MDBProxy<bean name>_<hashcode>
   * 
   * The format is slightly different for WebService Endpoints:
   * 
   * WSEJBProxy + <type> + <EjbName> + _ + BuzzHash
   * 
   * Where the difference is 'WSEJBProxy' in place of EJS + 'Local | Remote',
   * and not including either 'C | <index>', since there is only one type of
   * WebService Endpoint.
   * 
   * E.g.
   * WSEJBProxySLClaim_12345678
   */
  
  public final class NameUtil
  {
      //121558
      private static final TraceComponent tc =
                      Tr.register(NameUtil.class, "EJBContainer",
                                  "com.ibm.ejs.container.container");
  
      public static final String homeRemotePrefix = "EJSRemote";
      public static final String homeBeanPrefix = "EJS";
      public static final String remotePrefix = "EJSRemote";
      public static final String concreteBeanPrefix = "Concrete"; // f110762.2
      public static final String persisterPrefix = "EJSJDBCPersister";
      public static final String endpointPrefix = "WSEJBProxy"; // LI3294-35
      public static final String mdbProxyPrefix = "MDBProxy";
  
      public static final String homeLocalPrefix = "EJSLocal"; // f111627
      public static final String localPrefix = "EJSLocal"; // f111627
  
      public static final String deployPackagePrefix = "com.ibm.ejs.container.deploy."; // F58064
  
      public static final int Max_Gen_File_Size = 100; // d114199
      public static final int Max_EjbName_Size = 32; // d147734
  
      // BeanType constants for all methods that require a beanType parameter
      public static final String UNKNOWN = "UNKNOWN";
      public static final String SINGLETON = "SG"; //F743-508
      public static final String STATELESS = "SL";
      public static final String STATEFUL = "SF";
      public static final String BEAN_MANAGED = "BMP";
      public static final String CONTAINER_MANAGED = "CMP";
      public static final String MESSAGE_DRIVEN = "MDB";
      public static final String MANAGED_BEAN = "MB"; // F743-34301
  
      // Module Version constants for all methods that require a version parameter
      public static final int EJB_1X = 1;
      public static final int EJB_2X = 2;
      public static final int EJB_3X = 3;
  
      // Instance data that is used to formulate the deployed class names
      private String ivBeanName = null;
      private String ivFullBeanName = null; // d369262.3
      private String ivBeanType = null;
      private String ivHashSuffix = null;
      private int ivHashVersion = -1; // d369262.3
      private int ivVersion = -1;
  
      // EJB Interfaces/Classes that require deployed implementations.
      private final String ivRemoteHomeInterface;
      private final String ivRemoteInterface;
      private final String ivLocalHomeInterface;
      private final String ivLocalInterface;
      private final String[] ivBusinessRemote;
      private final String[] ivBusinessLocal;
      private final String ivBeanClass;
      private final String ivPrimaryKey;
  
      // --------------------------------------------------------------------------
      //
      // Static methods that must be maintained for use by the deployutils (Ant
      // task for EJBDeploy).  The EJBDeploy tool itself has its own copies of
      // this logic that would need to be updated if the logic changed (e.g.,
      // com.ibm.etools.ejbdeploy.plugin.NameGeneratorHelper).
      //
      // --------------------------------------------------------------------------
  
      private static String getRemoteInterfaceName(EnterpriseBean enterpriseBean)
      {
          if (enterpriseBean instanceof ComponentViewableBean)
          {
              return ((ComponentViewableBean) enterpriseBean).getRemoteInterfaceName();
          }
  
          return null;
      }
  
      /**
       * Return the name of the deployed class that implements the remote
       * interface of the bean. <p>
       * 
       * @param enterpriseBean bean impl class
       * @param isPost11DD true if bean is defined using later than 1.1 deployment description.
       */
      public static String getRemoteImplClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
      {
          String remoteInterfaceName = getRemoteInterfaceName(enterpriseBean);
  
          if (remoteInterfaceName == null) { // f111627
              return null; // f111627
          } // f111627
          String packageName = packageName(remoteInterfaceName);
          String remoteName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, false, false, false); //d114199 d147734
  
          StringBuffer result = new StringBuffer();
          if (packageName != null) {
              result.append(packageName);
              result.append('.');
          }
          result.append(remotePrefix);
          result.append(getUniquePrefix(enterpriseBean));
          result.append(remoteName);
  
          return result.toString();
      } // getRemoteImplClassName
  
      private static String getLocalInterfaceName(EnterpriseBean enterpriseBean)
      {
          if (enterpriseBean instanceof ComponentViewableBean)
          {
              return ((ComponentViewableBean) enterpriseBean).getLocalInterfaceName();
          }
  
          return null;
      }
  
      /**
       * Return the name of the deployed class that implements the local
       * interface of the bean. <p>
       * 
       * @param enterpriseBean bean impl class
       * @param isPost11DD true if bean is defined using later than 1.1 deployment description.
       */
      public static String getLocalImplClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
      {
          String localInterfaceName = getLocalInterfaceName(enterpriseBean);
  
          if (localInterfaceName == null) {
              return null;
          }
          String packageName = packageName(localInterfaceName);
          String localName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, true, false, false); //d114199 d147734
  
          StringBuffer result = new StringBuffer();
          if (packageName != null) {
              result.append(packageName);
              result.append('.');
          }
          result.append(localPrefix);
          result.append(getUniquePrefix(enterpriseBean));
          result.append(localName);
  
          return result.toString();
      } // getRemoteImplClassName
  
      private static String getHomeInterfaceName(EnterpriseBean enterpriseBean)
      {
          if (enterpriseBean instanceof ComponentViewableBean)
          {
              return ((ComponentViewableBean) enterpriseBean).getHomeInterfaceName();
          }
  
          return null;
      }
  
      /**
       * Return the name of the deployed class that implements the home
       * interface of the bean. <p>
       * 
       * @param enterpriseBean bean impl class
       * @param isPost11DD true if bean is defined using later than 1.1 deployment description.
       */
      public static String getHomeRemoteImplClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
      {
          String homeInterfaceName = getHomeInterfaceName(enterpriseBean);
  
          if (homeInterfaceName == null) {
              return null;
          }
          String remoteInterfaceName = getRemoteInterfaceName(enterpriseBean); // d147362
          String packageName = packageName(remoteInterfaceName); // d147362
          String homeName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, false, true, false); //d114199 d147734
  
          StringBuffer result = new StringBuffer();
          if (packageName != null) {
              result.append(packageName);
              result.append('.');
          }
          result.append(homeRemotePrefix);
          result.append(getUniquePrefix(enterpriseBean));
          result.append(homeName);
  
          return result.toString();
      }
  
      private static String getLocalHomeInterfaceName(EnterpriseBean enterpriseBean)
      {
          if (enterpriseBean instanceof ComponentViewableBean)
          {
              return ((ComponentViewableBean) enterpriseBean).getLocalHomeInterfaceName();
          }
  
          return null;
      }
  
      /**
       * Return the name of the deployed class that implements the local home
       * interface of the bean. <p>
       * 
       * @param enterpriseBean bean impl class
       * @param isPost11DD true if bean is defined using later than 1.1 deployment description.
       */
      public static String getHomeLocalImplClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
      {
          String homeLocalInterfaceName = getLocalHomeInterfaceName(enterpriseBean);
  
          if (homeLocalInterfaceName == null) {
              return null;
          }
          String localInterfaceName = getLocalInterfaceName(enterpriseBean); // d147362
          String packageName = packageName(localInterfaceName); // d147362
          String homeLocalName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, true, true, false); //d114199 d147734
  
          StringBuffer result = new StringBuffer();
          if (packageName != null) {
              result.append(packageName);
              result.append('.');
          }
          result.append(homeLocalPrefix);
          result.append(getUniquePrefix(enterpriseBean));
          result.append(homeLocalName);
  
          return result.toString();
      }
  
      /**
       * Returns the name of the deployed class that implements an aggregation
       * of all business local interfaces of the bean. <p>
       * 
       * The aggregate name is derived from any business local implementation
       * class name by replacing the index with the character 'A'. <p>
       * 
       * See the NameUtil class overview documentation for a complete
       * description of the deployed name format. Some examples for
       * the business remote implementation class names are as follows: <p>
       * 
       * EJB 3.x Aggregate : EJSLocalASLClaim_12345678
       * 
       * @param localImplClassName the first ([0]) business local implementation
       *            class name.
       * 
       * @return the name of the deployed class that implements the local
       *         interfaces.
       */
      // F743-34304
      public static String getAggregateLocalImplClassName(String localImplClassName)
      {
          StringBuilder aggregateName = new StringBuilder(localImplClassName);
          int index = localImplClassName.lastIndexOf(localPrefix);
          aggregateName.setCharAt(index + localPrefix.length(), 'A');
          return aggregateName.toString();
      }
  
      /**
       * Return the name of the deployed home bean class. Assumption here is
       * the package name of the local and remote interfaces are the same. This
       * method uses the last package name found in either the remote or local
       * interface, if one or the other exist. If neither is found, null is returned.
       * 
       * @param enterpriseBean WCCM object for EnterpriseBean
       * @param isPost11DD true if bean is defined using later than 1.1 deployment description.
       */
      public static String getHomeBeanClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
      {
          String packageName = null;
  
          String homeInterfaceName = getHomeInterfaceName(enterpriseBean);
  
          // LIDB2281.24.2 made several changes to code below, to accommodate case
          // where neither a remote home nor a local home is present (EJB 2.1 allows
          // this).
          if (homeInterfaceName == null) { // f111627.1
              homeInterfaceName = getLocalHomeInterfaceName(enterpriseBean); // f111627.1
          }
  
          if (homeInterfaceName != null) {
              packageName = packageName(homeInterfaceName);
  
              StringBuffer result = new StringBuffer();
              if (packageName != null) {
                  result.append(packageName);
                  result.append('.');
              }
              result.append(homeBeanPrefix);
              result.append(getUniquePrefix(enterpriseBean));
  
              String homeName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, false, true, true); // d114199 d147734
              result.append(homeName);
  
              return result.toString();
          } else {
              return null;
          }
  
      }
  
      /**
       * Return the name of the concrete bean class using following
       * template:
       * 
       * concrete bean class name = <package name>.Concrete<bean class>
       **/
      // f110762.2
      public static String getConcreteBeanClassName(EnterpriseBean enterpriseBean)
      {
          String beanClassName = enterpriseBean.getEjbClassName();
          String packageName = packageName(beanClassName);
          String beanName = encodeBeanInterfacesName(enterpriseBean, true, false, false, false); // d147734
  
          StringBuffer result = new StringBuffer();
          if (packageName != null)
          {
              result.append(packageName);
              result.append('.');
          }
  
          result.append(concreteBeanPrefix);
          result.append(beanName);
  
          return result.toString();
      }
  
      /*
       * Return the name of the deployed persister class using following
       * template:
       * 
       * persistence class name = <package name>.EJSJDBCPersister<bean class>
       */
      public static String getDeployedPersisterClassName(EnterpriseBean enterpriseBean)
      {
          String beanClassName = enterpriseBean.getEjbClassName();
          String packageName = packageName(beanClassName);
          String beanName = relativeName(beanClassName);
  
          StringBuffer result = new StringBuffer();
          if (packageName != null) {
              result.append(packageName);
              result.append('.');
          }
          result.append(persisterPrefix);
          result.append(getUniquePrefix(enterpriseBean));
          result.append(beanName);
  
          return result.toString();
      }
  
      // TODO TKB: Delete Me after calling code changed to use instance method
      /**
       * Return the name of the deployed persister class using following
       * template:
       * 
       * persistence class name = <package name>.EJSJDBCPersister<bean class>
       * 
       * This signature was introduced as part of an effort to isolate
       * references in EJB Container to WCCM objects. The original signature
       * (above) must be maintained for compatibility with EJBDeploy.
       */
      // d366807.3
      public static String getDeployedPersisterClassName(Object enterpriseBean)
      {
          return getDeployedPersisterClassName((EnterpriseBean) enterpriseBean);
      }
  
      //
      // Utilities
      //
  
      public static String relativeName(String className)
      {
          return relativeName(className, ".");
      }
  
      public static String relativeName(String className, String delim)
      {
          String tmp = null;
  
          StringTokenizer st = new StringTokenizer(className, delim, false);
          while (st.hasMoreElements()) {
              tmp = st.nextToken();
          }
          return tmp;
      }
  
      public static String packageName(String className)
      {
          int index = className.lastIndexOf('.');
          if (index != -1)
              return className.substring(0, index);
          else
              return null;
      }
  
      /**
       * Returns the bean type specific part of the generated class names. <p>
       * 
       * This value must match the same algorithm as used by the deploytool,
       * and is part of the prefix for the following generated classes:
       * <ul>
       * <li> Remote Wrapper Class Name
       * <li> Local Wrapper Class Name
       * <li> Remote Home Wrapper Class Name
       * <li> Local Home Wrapper Class Name
       * <li> Home Bean Class Name
       * <li> CMP 1.x Persister Class Name
       * </ul> <p>
       * 
       * The possible returned values are:
       * <ul>
       * <li> Singleton - Singleton Session Bean
       * <li> Stateless - Stateless Session Bean
       * <li> Stateful - Stateful Session Bean
       * <li> CMP - Container Managed Persistence Entity Bean
       * <li> BMP - Bean Managed Persistence Entity Bean
       * </ul> <p>
       * 
       * Note that MessageDriven Beans do not have a unique prefix value since
       * they do not have any generated classes. This method should never be
       * called for MDBs. <p>
       **/
      // d170742
      public static String getUniquePrefix(EnterpriseBean enterpriseBean)
      {
          String prefix = "";
  
          switch (enterpriseBean.getKindValue())
          {
              case EnterpriseBean.KIND_SESSION:
                  switch (((Session) enterpriseBean).getSessionTypeValue())
                  {
                      case Session.SESSION_TYPE_STATELESS:
                          prefix = "Stateless";
                          break;
                      case Session.SESSION_TYPE_STATEFUL:
                          prefix = "Stateful";
                          break;
                      case Session.SESSION_TYPE_SINGLETON:
                          prefix = "Singleton";
                          break;
                      default:
                          if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                              Tr.event(tc, "Unknown session bean type");
                          break;
                  }
                  break;
  
              case EnterpriseBean.KIND_ENTITY:
                  if (((Entity) enterpriseBean).getPersistenceTypeValue() == Entity.PERSISTENCE_TYPE_CONTAINER)
                  {
                      prefix = "CMP";
                  }
                  else
                  {
                      prefix = "BMP";
                  }
                  break;
  
              case EnterpriseBean.KIND_MESSAGE_DRIVEN:
                  if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                      Tr.event(tc, "EJB Internal Error - " +
                                   "MessageDriven has no unique prefix");
                  break;
  
              default:
                  if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) //130050
                      Tr.event(tc, "Unknown bean type");
          }
  
          return prefix;
      }
  
      public static String getCreateTableStringsMethodNameBase()
      {
          return "getCreateTableSQLStrings_";
      }
  
      // d149791 Begins
      public static final String getHashStr(EnterpriseBean enterpriseBean)
      {
          StringBuffer hashStr = new StringBuffer(enterpriseBean.getName());
  
          String remoteHomeInterfaceName = getHomeInterfaceName(enterpriseBean);
          if (remoteHomeInterfaceName != null)
          {
              hashStr.append(remoteHomeInterfaceName);
          }
          String remoteBusinessInterfaceName = getRemoteInterfaceName(enterpriseBean);
          if (remoteBusinessInterfaceName != null)
          {
              hashStr.append(remoteBusinessInterfaceName);
          }
          String localHomeInterfaceName = getLocalHomeInterfaceName(enterpriseBean);
          if (localHomeInterfaceName != null)
          {
              hashStr.append(localHomeInterfaceName);
          }
          String localBusinessInterfaceName = getLocalInterfaceName(enterpriseBean);
          if (localBusinessInterfaceName != null)
          {
              hashStr.append(localBusinessInterfaceName);
          }
          String beanClassName = enterpriseBean.getEjbClassName();
          hashStr.append(beanClassName);
          if (enterpriseBean.getKindValue() == EnterpriseBean.KIND_ENTITY)
          {
              hashStr.append(((Entity) enterpriseBean).getPrimaryKeyName());
          }
          return hashStr.toString();
      }
  
      // d149791 Ends
  
      // TODO TKB: Delete Me after calling code changed to use instance method
      /**
       * This signature was introduced as part of an effort to isolate
       * references in EJB Container to WCCM objects. The original signature
       * (above) must be maintained for compatibility with EJBDeploy.
       */
      // d366807.3
      public static final String getHashStr(Object enterpriseBean)
      {
          return getHashStr((EnterpriseBean) enterpriseBean);
      }
  
      // d114199 Begins
      // This returns the encoded name based on the bean class and its interface(s).
      //  The format of the encoded name is:
      //
      //  For 1.1 DTD (i.e. pre V5.0 naming convention)
      //      { remoteInterfaceClassName | localinterfaceClassName } + [ "Bean" ]
      //  E.g.
      //      Claim
      //      ClaimBean
      //
      //  For 2.0 DTD (i.e. V5.0 naming convention)
      //      EjbName + [ "Home" ] + [ "Bean" ] + "_" + BuzzHash
      //  Where:
      //      EjbName is the <ejb-name> value from the bean's deployment description
      //          - ignore all leading and trailing whites-space (i.e. String.trim() )
      //          - keep all alphanumeric characters and replace all other characters with '_'
      //          - limits to the first 32 chars
      //      BuzzHash is the hashcode of the full <ejb-name> value in the bean's dd
      //          - ignore all leading and trailing white-spaces (i.e. String.trim() )
      //          - hash all characters as defined in the dd (i.e. no translation)
      //  E.g.
      //      Claim_012345678
      //      Claim_012345678
      //      ClaimBean_012345678
      //      ClaimHomeBean_012345678
      //
      // @param enterpriseBean bean impl class
      // @param isPost11DD true if bean is defined using later than 1.1 deployment description.
      // @param isLocal true if local interface is requested
      // @param isHome true if home interface is requested
      // @param isBean true if home bean file name is requested
      //
      private static final String encodeBeanInterfacesName(EnterpriseBean enterpriseBean, boolean isPost11DD, boolean isLocal, boolean isHome, boolean isBean) // d147734
      {
          String rtnStr = null;
          if (!isPost11DD)
          { // container managed 1.x bean naming convention
            // pre 2.0 EJB specification don't have local interface, check of isLocal
            //  is a precaution for an invalid call, which returns null back.
              if (isHome)
              { // cm 1.x home interface
                  if (isLocal)
                  { // cm 1.x local home interface
                      rtnStr = getLocalHomeInterfaceName(enterpriseBean); // d149791
                  } else
                  { // cm 1.x remote home interface
                      rtnStr = getHomeInterfaceName(enterpriseBean); // d149791
                  }
                  // d147734 Begins
                  if (isBean)
                  { // move "Bean" append from the caller to here so that the hashcode is the last element
                      rtnStr += "Bean";
                  }
                  // d147734 Ends
              } else
              { // cm 1.x business interface
                  if (isLocal)
                  { // cm 1.x local business interface
                      rtnStr = getLocalInterfaceName(enterpriseBean); // d149791
                  } else
                  { // cm 1.x remote business interface
                      rtnStr = getRemoteInterfaceName(enterpriseBean); // d149791
                  }
              }
              return relativeName(rtnStr);
          } else
          { // container managed 2.x bean naming convention
            // d147734 Begins
            // the if clause's statements replaces the old implementation in the else clause
              String ejbName = enterpriseBean.getName();
              rtnStr = translateEjbName(ejbName);
  
              String hashStr = getHashStr(enterpriseBean); // d149791
  
              if (isHome)
              { // New append to file name to differentiate between business & home wrappers
                  rtnStr += "Home";
              }
              if (isBean)
              { // move "Bean" append from the caller to here so that the hashcode is the last element
                  rtnStr += "Bean";
              }
              // d147734 Ends
              //  append the <ejb-name> BuzzHash as bean's unique identifier
              return rtnStr + "_" + BuzzHash.computeHashStringMid32Bit(hashStr);
          }
      }
  
      // d114199 Ends
  
      // d179573 Begins
      private static boolean allHexDigits(String str, int start, int end)
      {
          boolean rtn = true;
          for (int i = start; i < end; ++i)
          {
              if ("0123456789abcdefABCDEF".indexOf(str.charAt(i)) == -1)
              {
                  rtn = false;
                  break;
              }
          }
          return rtn;
      }
  
      /**
       * Attempts to find the new file name originated from input oldName using the
       * the new modified BuzzHash algorithm.
       * This method detects if the oldName contains a valid trailing hashcode and
       * try to compute the new one. If the oldName has no valid hashcode in the
       * input name, null is return.
       * For ease of invocation regardless of the type of file passes in, this method
       * only changes the hash value and will not recreate the complete file name from
       * the EnterpriseBean.
       * 
       * @return the new file name using the oldName but with a new hash code, or null if no
       *         new name can be constructed.
       */
      public static final String updateFilenameHashCode(EnterpriseBean enterpriseBean, String oldName)
      {
          String newName = null;
          int len = oldName.length();
          int last_ = (len > 9 && (oldName.charAt(len - 9) == '_')) ? len - 9 : -1;
          // input file name must have a trailing "_" follows by 8 hex digits
          // and check to make sure the last 8 characters are all hex digits
          if (last_ != -1 && allHexDigits(oldName, ++last_, len))
          {
              String hashStr = getHashStr(enterpriseBean);
              newName = oldName.substring(0, last_) + BuzzHash.computeHashStringMid32Bit(hashStr, true);
          }
          return newName;
      }
  
      // d179573 Ends
  
      // TODO TKB: Delete Me after calling code changed to use instance method
      /*
       * This signature was introduced as part of an effort to isolate
       * references in EJB Container to WCCM objects. The original signature
       * (above) must be maintained for compatibility with EJBDeploy.
       */// d366807.3
      public static final String updateFilenameHashCode(Object enterpriseBean, String oldName)
      {
          return updateFilenameHashCode((EnterpriseBean) enterpriseBean, oldName);
      }
  
      // d147734 Begins
      /**
       * Translate the input ejbname to be used by ejbdeploy generated file name
       * according to the following rules.
       * 1. Leading and trailing white spaces are trimmed.
       * 2. All non-alphanumeric characters are replaced by "_" to avoid invalid
       * file name character since <ejb-name> can be in any form.
       * 3. Limit the return string to a pre-defined length Max_EjbName_Size.
       */
      private static String translateEjbName(String ejbName)
      {
          // trim leading and trailing blanks
          ejbName = ejbName.trim();
          // limits to the first Max_EjbName_Size characters
          int len = ejbName.length();
          if (len > Max_EjbName_Size)
          {
              len = Max_EjbName_Size;
          }
          // translate non-alphanumeric characters to "_"
          char translated[] = new char[len];
          for (int i = 0; i < len; ++i)
          {
              char curChar = ejbName.charAt(i);
              translated[i] = Character.isLetterOrDigit(curChar) ? curChar : '_';
          }
          return new String(translated);
      }
  
      public static void dumpClassNames(EnterpriseBean enterpriseBean, boolean isPost11DD)
      {
          System.out.println("<NameUtil><EjbName          > " + enterpriseBean.getName() + ":" + isPost11DD);
          System.out.println("<NameUtil><RemoteWrapper    > " + getRemoteImplClassName(enterpriseBean, isPost11DD));
          System.out.println("<NameUtil><RemoteHomeWrapper> " + getHomeRemoteImplClassName(enterpriseBean, isPost11DD));
          System.out.println("<NameUtil><LocalWrapper     > " + getLocalImplClassName(enterpriseBean, isPost11DD));
          System.out.println("<NameUtil><LocalHomeWrapper > " + getHomeLocalImplClassName(enterpriseBean, isPost11DD));
          System.out.println("<NameUtil><HomeBean         > " + getHomeBeanClassName(enterpriseBean, isPost11DD));
          System.out.println("<NameUtil><ConcreateBean    > " + getConcreteBeanClassName(enterpriseBean));
          System.out.println("<NameUtil><Persister        > " + getDeployedPersisterClassName(enterpriseBean));
      }
  
      // d147734 Ends
  
      // --------------------------------------------------------------------------
      //
      // Instance methods used by EJB Container for EJB 3.0 and performance
      //
      // --------------------------------------------------------------------------
  
      /**
       * Creates an instance of NameUtil that pre-formulates common parts
       * of the deployed classes names, providing a significant performance
       * advantage over the use of the static methods. <p>
       * 
       * Also, unlike the static NameUtil methods, the instance construction
       * and instance methods are independent of the metadata source
       * (i.e. independent of WCCM or annotation processing). <p>
       * 
       * Note: MessageDriven beans do not have generated classes, however
       * a NameUtil may be created for a MessageDriven bean to allow
       * the user to have EJB type independent code. <p>
       * 
       * @param beanName the EJB name.
       * @param remoteHomeInterface fully qualified remote home interface name.
       * @param remoteInterface fully qualified remote interface name.
       * @param localHomeInterface fully qualified local home interface name.
       * @param localInterface fully qualified local interface name.
       * @param remoteBusinessInterfaces fully qualified remote business
       *            interface names.
       * @param localBusinessInterfaces fully qualified local business
       *            interface names.
       * @param beanClass fully qualified bean implementation class name.
       * @param primaryKey fully qualified primary key class name.
       * @param beanType bean type constant from NameUtil class.
       * @param version module version constant from NameUtil class.
       * 
       * @throws IllegalArgumentException if the beanName parameter is null or
       *             a valid constant is not specified for either the beanType
       *             or version parameters.
       **/
      // d366807.3
      public NameUtil(String beanName,
                      String remoteHomeInterface,
                      String remoteInterface,
                      String localHomeInterface,
                      String localInterface,
                      String remoteBusinessInterfaces[],
                      String localBusinessInterfaces[],
                      String beanClass,
                      String primaryKey,
                      String beanType,
                      int version)
      {
  
          // The bean name must be specified (as it is integral to determining
          // many of the generated class names, and is required by the spec.
          // Note that not all characters that are allowed for a bean name
          // may be used in a class name, so when saving the bean name, it
          // is first translated (to valid characters) and truncated to a
          // max size.  This translation is then only performed once, and not
          // for each generated class name.
          if (beanName == null)
              throw new IllegalArgumentException("Bean Name not specified.");
  
          ivBeanName = translateEjbName(beanName);
  