FileDocCategorySizeDatePackage
AbstractNameMapper.javaAPI DocGlassfish v2 API14434Fri May 04 22:34:42 BST 2007com.sun.jdo.api.persistence.mapping.ejb

AbstractNameMapper

public abstract class AbstractNameMapper extends Object
This is a class which helps translate between the various names of the CMP (ejb name, abstract schema, abstract bean, concrete bean, local interface, remote interface) and the persistence-capable class name. It also has methods for translation of field names. The basic entry point is ejb name or persistence-capable class name.
author
Rochelle Raccah

Fields Summary
public static final int
USER_DEFINED_KEY_CLASS
public static final int
PRIMARY_KEY_FIELD
public static final int
UNKNOWN_KEY_CLASS
public static final String
GENERATED_KEY_FIELD_NAME
Defines key field name for unknown primary key
public static final String
GENERATED_VERSION_FIELD_PREFIX
Defines version field name prefix for version consistency
protected static final String
GENERATED_CMR_FIELD_PREFIX
Constructors Summary
Methods Summary
public abstract java.lang.StringgetAbstractBeanClassForEjbName(java.lang.String name)
Gets the name of the abstract bean class which corresponds to the specified ejb name.

param
name the name of the ejb
return
the name of the abstract bean for the specified ejb

public abstract java.lang.StringgetAbstractSchemaForEjbName(java.lang.String name)
Gets the name of the abstract schema which corresponds to the specified ejb.

param
name the name of the ejb
return
the name of the abstract schema for the specified ejb

public java.lang.String[]getEjbFieldForGeneratedField(java.lang.String name, java.lang.String fieldName)
Gets the name of the ejb field which corresponds to the specified generated ejb name and field name pair.

param
name the name of the ejb
param
fieldName the name of the field in the ejb
return
a String array of the form {, } which represents the inverse field for the generated field

		List field = (List)getGeneratedFieldsMap().get(
			Arrays.asList(new String[]{name, fieldName}));

		return ((field != null) ? 
			(String[])field.toArray(new String[2]) : null);
	
public abstract java.lang.StringgetEjbFieldForPersistenceField(java.lang.String className, java.lang.String fieldName)
Gets the name of the field in the ejb which corresponds to the specified persistence-capable class name and field name pair.

param
className the name of the persistence-capable
param
fieldName the name of the field in the persistence-capable
return
the name of the field in the ejb for the specified persistence-capable field

public abstract java.lang.StringgetEjbNameForLocalInterface(java.lang.String ejbName, java.lang.String fieldName, java.lang.String interfaceName)
Gets the name of the ejb which corresponds to the specified local interface name.

param
ejbName the name of the ejb which contains fieldName from which to find relationship and therefore the local interface
param
fieldName the name of the field in the ejb
param
interfaceName the name of the local interface
return
the name of the ejb for the specified local interface

public abstract java.lang.StringgetEjbNameForPersistenceClass(java.lang.String className)
Gets the name of the ejb name which corresponds to the specified persistence-capable class name.

param
className the name of the persistence-capable
return
the name of the ejb for the specified persistence-capable

public java.lang.StringgetEjbNameForPersistenceKeyClass(java.lang.String className)
Gets the name of the ejb name which corresponds to the specified persistence-capable key class name. Returns null if the supplied className is not a persistence-capable key class name.

param
className the name of the persistence-capable key class
return
the name of the ejb for the specified persistence-capable key class

		if (className.toUpperCase().endsWith("OID")) {	// NOI18N
			return getEjbNameForPersistenceClass(
				className.substring(0, className.length() - 4));
		}

		return null;
	
public abstract java.lang.StringgetEjbNameForRemoteInterface(java.lang.String ejbName, java.lang.String fieldName, java.lang.String interfaceName)
Gets the name of the ejb which corresponds to the specified remote interface name.

param
ejbName the name of the ejb which contains fieldName from which to find relationship and therefore the remote interface
param
fieldName the name of the field in the ejb
param
interfaceName the name of the remote interface
return
the name of the ejb for the specified remote interface

public java.lang.String[]getGeneratedFieldForEjbField(java.lang.String name, java.lang.String fieldName)
Gets the name of the generated field in the ejb which corresponds to the specified ejb name and field name pair.

param
name the name of the ejb
param
fieldName the name of the field in the ejb
return
a String array of the form {, } which represents the generated field for the ejb field

		List field = (List)getInverseFieldsMap().get(
			Arrays.asList(new String[]{name, fieldName}));

		return ((field != null) ? 
			(String[])field.toArray(new String[2]) : null);
	
protected abstract java.util.MapgetGeneratedFieldsMap()

public java.util.ListgetGeneratedRelationshipsForEjbName(java.lang.String name)
The list contains generated relationship field names.

param
name the name of the ejb
return
a List of generated relationship names

		Map generatedFieldsMap = getGeneratedFieldsMap();
		Iterator iterator = generatedFieldsMap.keySet().iterator();
		List returnList = new ArrayList();

		while (iterator.hasNext()) {
			List nextField = (List)iterator.next();

			if (nextField.get(0).equals(name))
				returnList.add(nextField.get(1));
		}

		return returnList;
	
protected abstract java.util.MapgetInverseFieldsMap()

public abstract java.lang.StringgetKeyClassForEjbName(java.lang.String name)
Gets the name of the key class which corresponds to the specified ejb name.

param
name the name of the ejb
return
the name of the key class for the ejb

public java.lang.StringgetKeyClassForPersistenceKeyClass(java.lang.String className)
Gets the name of the key class which corresponds to the specified persistence-capable key class name. Returns null if the supplied className is not a persistence-capable key class name.

param
className the name of the persistence-capable key class
return
the name of the key class for the ejb

		// NOI18N

	   

	   

	                            	 
	    

	                                  	 
	    

	                                	 
	    

	                                                   	 
	    
		String ejbName = getEjbNameForPersistenceKeyClass(className);

		return ((ejbName != null) ? getKeyClassForEjbName(ejbName) : null);
	
public abstract intgetKeyClassTypeForEjbName(java.lang.String name)
Get the type of key class of this ejb.

return
the key class type, one of {@link #USER_DEFINED_KEY_CLASS}, {@link #PRIMARY_KEY_FIELD}, or {@link #UNKNOWN_KEY_CLASS}

public abstract java.lang.StringgetLocalInterfaceForEjbName(java.lang.String name)
Gets the name of the local interface which corresponds to the specified ejb name.

param
name the name of the ejb
return
the name of the local interface for the specified ejb

public abstract java.lang.StringgetPersistenceClassForEjbName(java.lang.String name)
Gets the name of the persistence-capable class which corresponds to the specified ejb name.

param
name the name of the ejb
return
the name of the persistence-capable for the specified ejb

public java.lang.StringgetPersistenceClassForLocalInterface(java.lang.String className, java.lang.String fieldName, java.lang.String interfaceName)
Gets the name of the persistence-capable class which corresponds to the specified local interface name.

param
className the name of the persistence-capable class which contains fieldName from which to find relationship and therefore the local interface
param
fieldName the name of the field in the persistence-capable class
param
interfaceName the name of the local interface
return
the name of the persistence-capable for the specified local interface which is related to the specified class name, field name pair

		if (isLocalInterface(interfaceName)) {
			String ejbName = getEjbNameForPersistenceClass(className);
			String ejbField = 
				getEjbFieldForPersistenceField(className, fieldName);

			return getPersistenceClassForEjbName(
				getEjbNameForLocalInterface(ejbName, ejbField, interfaceName));
		}

		return null;
	
public java.lang.StringgetPersistenceClassForRemoteInterface(java.lang.String className, java.lang.String fieldName, java.lang.String interfaceName)
Gets the name of the persistence-capable class which corresponds to the specified remote interface name.

param
className the name of the persistence-capable class which contains fieldName from which to find relationship and therefore the remote interface
param
fieldName the name of the field in the persistence-capable class
param
interfaceName the name of the remote interface
return
the name of the persistence-capable for the specified remote interface which is related to the specified class name, field name pair

		if (isRemoteInterface(interfaceName)) {
			String ejbName = getEjbNameForPersistenceClass(className);
			String ejbField = 
				getEjbFieldForPersistenceField(className, fieldName);

			return getPersistenceClassForEjbName(
				getEjbNameForRemoteInterface(ejbName, ejbField, interfaceName));
		}

		return null;
	
public abstract java.lang.StringgetPersistenceFieldForEjbField(java.lang.String name, java.lang.String fieldName)
Gets the name of the field in the persistence-capable class which corresponds to the specified ejb name and field name pair.

param
name the name of the ejb
param
fieldName the name of the field in the ejb
return
the name of the field in the persistence-capable for the specified ejb field

public abstract java.lang.StringgetRemoteInterfaceForEjbName(java.lang.String name)
Gets the name of the remote interface which corresponds to the specified ejb name.

param
name the name of the ejb
return
the name of the remote interface for the specified ejb

public abstract booleanisEjbName(java.lang.String name)
Determines if the specified name represents an ejb.

param
name the fully qualified name to be checked
return
true if this name represents an ejb; false otherwise.

public booleanisGeneratedEjbRelationship(java.lang.String name, java.lang.String fieldName)
Returns true if the field in the persistence-capable class which corresponds to the specified ejb name and field name pair is one which was generated automatically for 2 way managed relationships in the case that the ejb specifies one way relationships.

param
className the name of the ejb
param
fieldName the name of the field in the ejb
return
true if the field is generated;false otherwise

		return getGeneratedFieldsMap().keySet().contains(
			Arrays.asList(new String[]{name, fieldName}));
	
public booleanisGeneratedField(java.lang.String name, java.lang.String fieldName)
Returns true if the field is a generated field. That includes: relationships generated for 2 way managed relationships, key fields generated for use with {@link #UNKNOWN_KEY_CLASS}, or version fields generated to hold a version consistency column.

param
name the name of the ejb
param
fieldName the name of the field in the ejb
return
true if the field is generated;false otherwise

		return isGeneratedEjbRelationship(name, fieldName) ||
			fieldName.equals(GENERATED_KEY_FIELD_NAME) ||
			fieldName.startsWith(GENERATED_VERSION_FIELD_PREFIX);
	
public abstract booleanisLocalInterface(java.lang.String name)
Determines if the specified name represents a local interface.

param
name the fully qualified name to be checked
return
true if this name represents a local interface; false otherwise.

public abstract booleanisRemoteInterface(java.lang.String name)
Determines if the specified name represents a remote interface.

param
name the fully qualified name to be checked
return
true if this name represents a remote interface; false otherwise.