FileDocCategorySizeDatePackage
AbstractMethodHelper.javaAPI DocGlassfish v2 API10153Fri May 04 22:34:48 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbc

AbstractMethodHelper

public abstract class AbstractMethodHelper extends Object
This is a helper class which extracts the information needed for method code generation of the concrete bean class.
author
Rochelle Raccah

Fields Summary
public static final int
LOCAL_RETURN
Constant representing a local interface return type.
public static final int
REMOTE_RETURN
Constant representing a remote interface return type.
public static final int
NO_RETURN
Constant representing no return type.
private EjbCMPEntityDescriptor
_cmpDescriptor
private List
finders
private List
selectors
private List
createMethods
private Map
methodNames
Constructors Summary
public AbstractMethodHelper(EjbCMPEntityDescriptor descriptor)
Creates a new instance of AbstractMethodHelper

param
descriptor the EjbCMPEntityDescriptor which defines the information for this bean.


	                  	 
	   
	
		_cmpDescriptor = descriptor;
		categorizeMethods();	// Separate methods into categories.
	
Methods Summary
protected voidcategorizeMethods()
Reads all known methods and sorts them by name into specific Collections for further processing.

		EjbCMPEntityDescriptor descriptor = getDescriptor();
		Iterator iterator = descriptor.getMethodDescriptors().iterator();

		while (iterator.hasNext())
		{
			MethodDescriptor methodDescriptor = 
				(MethodDescriptor)iterator.next();
			Method method = methodDescriptor.getMethod(descriptor);
			String methodName = methodDescriptor.getName();

			//if (DEBUG)
			//	System.out.println("Method: " + methodName); // NOI18N

			if (methodName.startsWith(CMPTemplateFormatter.find_))
				finders.add(method);
			else if (methodName.startsWith(CMPTemplateFormatter.ejbSelect_))
				selectors.add(method); 
			else if (methodName.startsWith(CMPTemplateFormatter.create_))
				createMethods.add(method);
			else if (methodName.startsWith(CMPTemplateFormatter.get_) || 
				methodName.startsWith(CMPTemplateFormatter.set_))
			{
				;// skip
			}
			//else
			//	otherMethods.add(method);

			// It is OK to use HashMap here as we won't use it for possible 
			// overloaded methods. 
			methodNames.put(methodName, method);
		}
	
public java.util.ListgetCreateMethods()
Gets the list of ejb create methods for this bean.

return
a list of java.lang.reflect.Method objects which represent the ejb create methods for this bean

 return createMethods; 
protected EjbCMPEntityDescriptorgetDescriptor()
Gets the EjbCMPEntityDescriptor which defines the information for this bean.

return
the EjbCMPEntityDescriptor for the bean specified in the constructor.

 return _cmpDescriptor; 
public java.util.ListgetFinders()
Gets the list of finder methods for this bean.

return
a list of java.lang.reflect.Method objects which represent the finders for this bean

 return finders; 
public abstract java.lang.StringgetJDOFilterExpression(java.lang.reflect.Method method)
Gets the jdo filter expression associated with the specified method if it exists. Note that this method should only be used for CMP 1.1 - use {@link #getQueryString} for CMP 2.0.

param
method the java.lang.reflect.Method object used to find the query filter
return
the jdo filter expression

public abstract java.lang.StringgetJDOOrderingSpecification(java.lang.reflect.Method method)
Gets the jdo ordering specification associated with the specified method if it exists. Note that this method should only be used for CMP 1.1 - use {@link #getQueryString} for CMP 2.0.

param
method the java.lang.reflect.Method object used to find the parameter declaration
return
the jdo ordering specification

public abstract java.lang.StringgetJDOParameterDeclaration(java.lang.reflect.Method method)
Gets the jdo parameter declaration associated with the specified method if it exists. Note that this method should only be used for CMP 1.1 - use {@link #getQueryString} for CMP 2.0.

param
method the java.lang.reflect.Method object used to find the parameter declaration
return
the jdo parameter declaration

public abstract java.lang.StringgetJDOVariableDeclaration(java.lang.reflect.Method method)
Gets the jdo variables declaration associated with the specified method if it exists. Note that this method should only be used for CMP 1.1 - use {@link #getQueryString} for CMP 2.0.

param
method the java.lang.reflect.Method object used to find the parameter declaration
return
the jdo variables declaration

public java.lang.StringgetLocalHome()
Gets the name of the local home which corresponds to this bean.

return
the name of the local home class

		return getDescriptor().getLocalHomeClassName();
	
public java.util.MapgetMethodNames()
Gets a map of the method names for this bean. The keys are the method names and the values are the java.lang.reflect.Method objects. These should represent all methods of this bean.

return
a map of the method names to java.lang.reflect.Method objects for this bean

 return methodNames; 
protected QueryDescriptorgetQueryDescriptor(java.lang.reflect.Method method)
Gets the query descriptor associated with the specified method if it exists.

param
method the java.lang.reflect.Method object used to find the query string
return
a query descriptor for the specified method. Returns null for CMP 1.1 queries.

		PersistenceDescriptor persistenceDescriptor = 
			getDescriptor().getPersistenceDescriptor();
		return persistenceDescriptor.getQueryFor(method);
	
public intgetQueryReturnType(java.lang.reflect.Method method)
Gets the return type associated with the specified method if it exists. If no corresponding query descriptor is found, the value NO_RETURN is returned.

param
method the java.lang.reflect.Method object used to find the query return type
return
the return type for the specified method, one of {@link #LOCAL_RETURN}, {@link #REMOTE_RETURN}, or {@link #NO_RETURN}

		QueryDescriptor queryDescriptor = getQueryDescriptor(method);

		if (queryDescriptor != null)
		{
			if (queryDescriptor.getHasLocalReturnTypeMapping())
				return LOCAL_RETURN;
			if (queryDescriptor.getHasRemoteReturnTypeMapping())
				return REMOTE_RETURN;
		}

		return NO_RETURN;
	
public java.lang.StringgetQueryString(java.lang.reflect.Method method)
Gets the query string associated with the specified method if it exists.

param
method the java.lang.reflect.Method object used to find the query string
return
a query string for the specified method

		QueryDescriptor queryDescriptor = getQueryDescriptor(method);

		return ((queryDescriptor != null) ? queryDescriptor.getQuery() : null);
	
public java.lang.StringgetRemoteHome()
Gets the name of the remote home which corresponds to this bean.

return
the name of the remote home class

		return getDescriptor().getHomeClassName();
	
public java.util.ListgetSelectors()
Gets the list of selector methods for this bean.

return
a list of java.lang.reflect.Method objects which represent the selectors for this bean

 return selectors; 
public abstract booleanisQueryPrefetchEnabled(java.lang.reflect.Method method)
Returns true if prefetch is enabled for the specified method, false otherwise. Prefetch is enabled by default.

param
method the java.lang.reflect.Method object used to find the prefetch setting.
return
a boolean representing the prefetch setting

protected voidsetFinders(java.util.List finderList)

		finders = finderList;
	
protected voidsetSelectors(java.util.List selectorList)

		selectors = selectorList;