FileDocCategorySizeDatePackage
ParameterSupport.javaAPI DocGlassfish v2 API7305Fri May 04 22:34:50 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbqlc

ParameterSupport

public class ParameterSupport extends Object
Helper class to handle EJBQL query parameters.
author
Michael Bouschen
author
Shing Wai Chan

Fields Summary
private Class[]
parameterTypes
The types of the parameters of the finder/selector method.
private String[]
parameterEjbNames
The EJB names corresponding to types of parameters of the finder/selector method.
protected static final ResourceBundle
msgs
I18N support.
Constructors Summary
public ParameterSupport(Method method)
Constructor.

param
method the Method instance of the finder/selector method.


                     
      
    
        this.parameterTypes = 
            (method == null) ? new Class[0] : method.getParameterTypes();
        this.parameterEjbNames = new String[this.parameterTypes.length];
    
Methods Summary
private intgetParamNumber(java.lang.String ejbqlParamDecl)
Internal method to extract the number from a parameter application in EJBQL.

        int paramNum = 0;
        try {
            paramNum = Integer.parseInt(ejbqlParamDecl.substring(1));
        } catch(Exception ex) {
            ErrorMsg.error(I18NHelper.getMessage(
                msgs, "EXC_InvalidParameterIndex", //NOI18N
                ejbqlParamDecl, String.valueOf(parameterTypes.length)));
        }
        if (paramNum < 1 || paramNum > parameterTypes.length) {
            ErrorMsg.error(I18NHelper.getMessage(
                msgs, "EXC_InvalidParameterIndex", //NOI18N
                ejbqlParamDecl, String.valueOf(parameterTypes.length)));
        }
        return paramNum;
    
public intgetParameterCount()
Returns the number of parameters.

return
parameter count.

        return parameterTypes.length;
    
public java.lang.StringgetParameterEjbName(java.lang.String ejbqlParamDecl)
Get EJB name corresponding to the EJBQL parameter by input parameter declaration string.

param
ejbqlParamDecl denotes a parameter application in EJBQL. It has the form "?" where is the parameter number starting with 1.
return
class instance representing the parameter type.

        return getParameterEjbName(getParamNumber(ejbqlParamDecl));
    
public java.lang.StringgetParameterEjbName(int paramNumber)
Get EJB name corresponding to the EJBQL parameter number.

param
paramNumber numbering of parameters starting with 1
return
class instance representing the parameter type.

        return parameterEjbNames[paramNumber - 1];
    
public java.lang.String[]getParameterEjbNames()
Get all EJB names corresponding to the EJBQL parameters.

return
class instance representing the parameter type.

        return parameterEjbNames;
    
public java.lang.StringgetParameterName(java.lang.String ejbqlParamDecl)
Returns the name of the corresponding JDO parameter. The specified string denotes a parameter application in EJBQL. It has the form "?" where is the parameter number starting with 1.

return
name of JDOQL parameter

        return getParameterName(getParamNumber(ejbqlParamDecl));
    
public java.lang.StringgetParameterName(int paramNumber)
Returns the name of the corresponding JDO parameter by parameter number.

return
name of JDOQL parameter

        return "_jdoParam" + String.valueOf(paramNumber);
    
public java.lang.ClassgetParameterType(java.lang.String ejbqlParamDecl)
Returns type of the EJBQL parameter by input parameter declaration string. The specified string denotes a parameter application in EJBQL. It has the form "?" where is the parameter number starting with 1.

return
class instance representing the parameter type.

        return getParameterType(getParamNumber(ejbqlParamDecl));
    
public java.lang.ClassgetParameterType(int paramNumber)
Returns the type of the EJBQL parameter by number. Note, the numbering of EJBQL parameters starts with 1, so the method expects 1 as the number of the first parameter.

return
class instance representing the parameter type.

        // InputParams are numbered starting at 1, so adjust for
        // array indexing.
        return parameterTypes[paramNumber - 1];
    
public voidsetParameterEjbName(java.lang.String ejbqlParamDecl, java.lang.String ejbName)
Set EJB name corresponding to the EJBQL parameter by input parameter declaration string.

param
ejbqlParamDecl denotes a parameter application in EJBQL. It has the form "?" where is the parameter number starting with 1.
param
ejbName
return
class instance representing the parameter type.

        parameterEjbNames[getParamNumber(ejbqlParamDecl) - 1] = ejbName;