VcMethod.java

00001 
00027 package org.objectweb.jonas_ejb.genic;
00028 
00029 
00030 import java.lang.reflect.Method;
00031 import java.util.ArrayList;
00032 import java.util.Iterator;
00033 import java.util.List;
00034 import java.util.StringTokenizer;
00035 import java.util.Vector;
00036 
00037 import org.objectweb.jonas_ejb.deployment.api.BeanDesc;
00038 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp1Desc;
00039 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp2Desc;
00040 import org.objectweb.jonas_ejb.deployment.api.FieldJdbcDesc;
00041 import org.objectweb.jonas_ejb.deployment.api.MethodCmp2Desc;
00042 import org.objectweb.jonas_ejb.deployment.api.MethodDesc;
00043 import org.objectweb.jonas_ejb.deployment.api.MethodJdbcCmp1Desc;
00044 import org.objectweb.jonas_ejb.lib.BeanNaming;
00045 import org.objectweb.jonas_ejb.lib.JavaType;
00046 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
00047 import org.objectweb.jorm.type.api.PType;
00048 
00049 
00058 public class VcMethod {
00059 
00063     static final byte METHOD_CREATE = 0;
00067     static final byte METHOD_EJB_CREATE = 1;
00071     static final byte METHOD_EJB_POST_CREATE = 2;
00075     static final byte METHOD_REMOVE_THIS = 10;
00079     static final byte METHOD_REMOVE_PK = 11;
00083     static final byte METHOD_REMOVE_HANDLE = 12;
00087     static final byte METHOD_EJB_REMOVE = 13;
00091     static final byte METHOD_FINDER_BY_PK = 20;
00095     static final byte METHOD_FINDER_ALL = 21;
00099     static final byte METHOD_FINDER_SIMPLE = 22;
00103     static final byte METHOD_FINDER_ENUM = 23;
00107     static final byte METHOD_FINDER_COL = 24;
00111     static final byte METHOD_EJB_SELECT_SIMPLE = 30;
00115     static final byte METHOD_EJB_SELECT_COL = 31;
00119     static final byte METHOD_EJB_SELECT_SET = 32;
00123     static final byte METHOD_EJB_LOAD = 40;
00127     static final byte METHOD_EJB_STORE = 41;
00131     static final byte METHOD_EJB_SET_ENTITY_CONTEXT = 42;
00135     static final byte METHOD_EJB_ACTIVATE = 43;
00136 
00140     private byte mKind = -1;
00141 
00145     private String  mName = null;
00146 
00150     private String  mCapName = null;
00151 
00155     private StringBuffer mFormalParameters = null;
00156 
00160     private StringBuffer mActualParameters = null;
00161 
00165     private StringBuffer mArrayObjectParameters = null;
00166 
00170     private StringBuffer mExceptionList = null;
00171 
00175     private String mSecuritySignature;
00176 
00180     private int mTxAttribute = MethodDesc.TX_NULL;
00181 
00185     private String mReturnType;
00186 
00190     private Method mMethod = null;
00191 
00195     private int methodIndex = -1;
00196 
00200     private BeanDesc beanDesc = null;
00201 
00202     /*
00203     * For CMP1 only
00204     */
00205 
00209     private String mSqlStmt = null;
00210 
00214     private ArrayList  mParamWhereList = null;
00215 
00216     /*
00217      * For CMP2 only
00218      */
00219 
00225     private boolean isEjbqlReturnRemoteBean = false;
00231     private boolean isEjbqlReturnLocalBean = false;
00237     private org.objectweb.medor.api.Field resFieldOfEjbql = null;
00242     private ArrayList  mParamList = null;
00243 
00247     private Class[] parameterTypes = null;
00251     private boolean canThrowCreate = false;
00252 
00259     VcMethod(Method method, MethodDesc methodDesc, BeanDesc dd) {
00260 
00261         if (methodDesc != null) {
00262             methodIndex = methodDesc.getIndex();
00263         }
00264         beanDesc = dd;
00265         /*
00266          * The 'method' may be
00267          * - a home interface's method
00268          * - a local home interface's method
00269          * - a remote interface's method
00270          * - a local interface's method
00271          * - a bean's method as
00272          * - a beans's ejbSelect() method,
00273          *   setEntityContext(), ejbActivate(), ejbCreate(), ejbLoad(), ejbStore(), ejbRemove().
00274          * - a beans's ejbSelect() method,
00275          * In the last case, the 'methodDesc' is null in case of
00276          * setEntityContext(), ejbActivate(), ejbLoad() and ejbStore().
00277          */
00278 
00279         Class declClass = method.getDeclaringClass();
00280         Class [] params = method.getParameterTypes();
00281         parameterTypes = params;
00282         Class [] exceptions = method.getExceptionTypes();
00283         mMethod = method;
00284 
00285         // Name and CapName
00286         mName = method.getName();
00287         mCapName = BeanNaming.firstToUpperCase(mName);
00288 
00289         // FormalParameters and ActualParameters
00290         mFormalParameters = new StringBuffer();
00291         mActualParameters = new StringBuffer();
00292         mArrayObjectParameters = new StringBuffer();
00293         String var = null;
00294         for (int p = 1; p <= params.length; p++) {
00295             var =  "p" + p;
00296             mFormalParameters.append(JavaType.getName(params[p - 1]) + " " + var);
00297             mActualParameters.append(var);
00298             mArrayObjectParameters.append(JavaType.toStringObject(var, params[p - 1]));
00299             if (p < params.length) {
00300                 mFormalParameters.append(", ");
00301                 mActualParameters.append(", ");
00302                 mArrayObjectParameters.append(", ");
00303             }
00304         }
00305 
00306         // ExceptionList
00307         mExceptionList = new StringBuffer();
00308         for (int e = 0; e < exceptions.length; e++) {
00309             Class ecl = exceptions[e];
00310             if (javax.ejb.CreateException.class.isAssignableFrom(ecl)) {
00311                 canThrowCreate = true;
00312             }
00313             mExceptionList.append(JavaType.getName(ecl));
00314             if (e < exceptions.length - 1) {
00315                 mExceptionList.append(", ");
00316             }
00317         }
00318 
00319         // SecuritySignature
00320         // No methodDesc for bean's methods as ejbLoad(), ejbStore(), ...
00321         if (methodDesc != null) {
00322             mSecuritySignature = "";
00323             if (methodDesc.getRoleName().length > 0 || methodDesc.isExcluded()) {
00324                 mSecuritySignature = BeanNaming.getSignature(dd.getEjbName(), method);
00325             }
00326         }
00327 
00328         // TxAttribute
00329         // No methodDesc for bean's methods as ejbLoad(), ejbStore(), ...
00330         if (methodDesc != null) {
00331             mTxAttribute = methodDesc.getTxAttribute();
00332         }
00333 
00334         // ReturnType
00335         mReturnType = JavaType.getName(method.getReturnType());
00336 
00337         // isFinderXXX
00338         boolean isFinder = false;
00339 
00340         if (mName.startsWith("find")
00341             && (javax.ejb.EJBHome.class.isAssignableFrom(declClass)
00342                 || javax.ejb.EJBLocalHome.class.isAssignableFrom(declClass))
00343             ) {
00344             isFinder = true;
00345         }
00346         if (isFinder) {
00347             if ("findByPrimaryKey".equals(mName)) {
00348                 mKind = METHOD_FINDER_BY_PK;
00349             } else {
00350                 if (java.util.Enumeration.class.equals(method.getReturnType())) {
00351                     mKind = METHOD_FINDER_ENUM;
00352                 } else if (java.util.Collection.class.equals(method.getReturnType())) {
00353                     mKind = METHOD_FINDER_COL;
00354                 } else {
00355                     mKind = METHOD_FINDER_SIMPLE;
00356                 }
00357             }
00358         }
00359 
00360         // isCreate
00361         if (mName.startsWith("create")
00362             && (javax.ejb.EJBHome.class.isAssignableFrom(declClass)
00363                 || javax.ejb.EJBLocalHome.class.isAssignableFrom(declClass))
00364             ) {
00365             mKind = METHOD_CREATE;
00366         }
00367 
00368         // isEjbCreate
00369         if (mName.startsWith("ejbCreate")
00370             && javax.ejb.EnterpriseBean.class.isAssignableFrom(declClass)) {
00371             mKind = METHOD_EJB_CREATE;
00372         }
00373 
00374         // isEjbPostCreate
00375         if (mName.startsWith("ejbPostCreate")
00376             && javax.ejb.EnterpriseBean.class.isAssignableFrom(declClass)) {
00377             mKind = METHOD_EJB_POST_CREATE;
00378         }
00379 
00380         // isRemoveXXX
00381         boolean isRemove = "remove".equals(mName);
00382         if (isRemove) {
00383             if (declClass.equals(javax.ejb.EJBObject.class)
00384                 || declClass.equals(javax.ejb.EJBLocalObject.class)) {
00385                 mKind = METHOD_REMOVE_THIS;
00386             } else if (declClass.equals(javax.ejb.EJBHome.class)
00387                        || declClass.equals(javax.ejb.EJBLocalHome.class)) {
00388                 if (params[0].equals(javax.ejb.Handle.class)) {
00389                     mKind = METHOD_REMOVE_HANDLE;
00390                 } else {
00391                     mKind = METHOD_REMOVE_PK;
00392                 }
00393             }
00394         }
00395 
00396         // isEjbRemove, isEjbLoad, isEjbStore
00397         if (javax.ejb.EnterpriseBean.class.isAssignableFrom(declClass)
00398             && (params.length == 0)) {
00399             if ("ejbRemove".equals(mName)) {
00400                 mKind = METHOD_EJB_REMOVE;
00401             } else if ("ejbLoad".equals(mName)) {
00402                 mKind = METHOD_EJB_LOAD;
00403             } else if ("ejbStore".equals(mName)) {
00404                 mKind = METHOD_EJB_STORE;
00405             }
00406         }
00407 
00408         // isEjbSetEntityContext
00409         if (javax.ejb.EnterpriseBean.class.isAssignableFrom(declClass)) {
00410             if ("setEntityContext".equals(mName)
00411                 && (params.length == 1)
00412                 && javax.ejb.EntityContext.class.equals(params[0])) {
00413                 mKind = METHOD_EJB_SET_ENTITY_CONTEXT;
00414             }
00415         }
00416 
00417         // isEjbActivate
00418         if (javax.ejb.EnterpriseBean.class.isAssignableFrom(declClass)) {
00419             if ("ejbActivate".equals(mName)
00420                 && (params.length == 0)) {
00421                 mKind = METHOD_EJB_ACTIVATE;
00422             }
00423         }
00424 
00425         if (dd instanceof EntityJdbcCmp1Desc) {
00426             // For Entity CMP 1
00427             // SqlStmt, and ParamsWhere in case of FinderSimple, FinderEnum or FinderCol.
00428             EntityJdbcCmp1Desc edd = (EntityJdbcCmp1Desc) dd;
00429             StringBuffer lf = new StringBuffer();
00430             StringBuffer lv = new StringBuffer();
00431             boolean firstLf = true;
00432             boolean firstLv = true;
00433             if (mKind == METHOD_EJB_CREATE) {
00434                 for (Iterator i = edd.getCmpFieldDescIterator(); i.hasNext();) {
00435                     FieldJdbcDesc fd = (FieldJdbcDesc) i.next();
00436                     if (firstLv) {
00437                         firstLv = false;
00438                     } else {
00439                         lf.append(", ");
00440                         lv.append(", ");
00441                     }
00442                     lf.append(fd.getJdbcFieldName());
00443                     lv.append("?");
00444                 }
00445                 mSqlStmt =
00446                     "insert into " + edd.getJdbcTableName()
00447                     + " (" + lf + ") values (" + lv + ")";
00448             } else if (mKind == METHOD_FINDER_BY_PK) {
00449                 for (Iterator i = edd.getCmpFieldDescIterator(); i.hasNext();) {
00450                     FieldJdbcDesc fd = (FieldJdbcDesc) i.next();
00451                     if (fd.isPrimaryKey()) {
00452                         if (firstLv) {
00453                             firstLv = false;
00454                         } else {
00455                             lf.append(", ");
00456                             lv.append(" and ");
00457                         }
00458                         lf.append(fd.getJdbcFieldName());
00459                         lv.append(fd.getJdbcFieldName() + "=?");
00460                     }
00461                 }
00462 
00463                 mSqlStmt =
00464                     "select " + lf + " from " + edd.getJdbcTableName()
00465                     + " where " + lv;
00466             } else if ((mKind == METHOD_FINDER_SIMPLE)
00467                        || (mKind == METHOD_FINDER_ENUM)
00468                        || (mKind == METHOD_FINDER_COL)) {
00469                 if (!((MethodJdbcCmp1Desc) methodDesc).hasWhereClause()) {
00470                     throw new Error("No WHERE clause defined for the finder method '"
00471                                     + method.toString() + "'");
00472                 }
00473                 ArrayList posParams = new ArrayList();
00474                 String clauseWhere = parseWhere (((MethodJdbcCmp1Desc) methodDesc).getWhereClause(), posParams);
00475                 for (Iterator i = edd.getCmpFieldDescIterator(); i.hasNext();) {
00476                     FieldJdbcDesc fd = (FieldJdbcDesc) i.next();
00477                     if (fd.isPrimaryKey()) {
00478                         if (firstLf) {
00479                             firstLf = false;
00480                         } else {
00481                             lf.append(", ");
00482                         }
00483                         lf.append(fd.getJdbcFieldName());
00484                     }
00485                 }
00486 
00487                 mSqlStmt =
00488                     "select " + lf + " from " + edd.getJdbcTableName()
00489                     + " " + clauseWhere;
00490                 mParamWhereList = new ArrayList();
00491                 for (int i = 0; i < posParams.size(); i++) {
00492                     int pos = ((Integer) posParams.get(i)).intValue();
00493                     if (pos >= params.length) {
00494                         throw new Error("Wrong parameters number between the method definition and the WHERE clause of the method '" + method + "'");
00495                     }
00496                     VcParamWhere vpw = new VcParamWhere(params[pos], pos + 1);
00497                     mParamWhereList.add(vpw);
00498                 }
00499             } else if (mKind == METHOD_EJB_REMOVE) {
00500                 for (Iterator i = edd.getCmpFieldDescIterator(); i.hasNext();) {
00501                     FieldJdbcDesc fd = (FieldJdbcDesc) i.next();
00502                     if (fd.isPrimaryKey()) {
00503                         if (firstLv) {
00504                            firstLv = false;
00505                         } else {
00506                            lv.append(" and ");
00507                         }
00508                         lv.append(fd.getJdbcFieldName() + "=?");
00509                     }
00510                 }
00511 
00512                 mSqlStmt =
00513                     "delete from " + edd.getJdbcTableName()
00514                     + " where " + lv;
00515             } else if (mKind == METHOD_EJB_LOAD) {
00516                 for (Iterator i = edd.getCmpFieldDescIterator(); i.hasNext();) {
00517                     FieldJdbcDesc fd = (FieldJdbcDesc) i.next();
00518                     if (firstLf) {
00519                         firstLf = false;
00520                     } else {
00521                         lf.append(", ");
00522                     }
00523                     lf.append(fd.getJdbcFieldName());
00524                     if (fd.isPrimaryKey()) {
00525                         if (firstLv) {
00526                             firstLv = false;
00527                         } else {
00528                             lv.append(" and ");
00529                         }
00530                         lv.append(fd.getJdbcFieldName() + "=?");
00531                     }
00532                 }
00533 
00534                 mSqlStmt =
00535                     "select " + lf + " from " + edd.getJdbcTableName()
00536                     + " where " + lv;
00537             } else if (mKind == METHOD_EJB_STORE) {
00538                 for (Iterator i = edd.getCmpFieldDescIterator(); i.hasNext();) {
00539                     FieldJdbcDesc fd = (FieldJdbcDesc) i.next();
00540                     if (fd.isPrimaryKey()) {
00541                         if (firstLv) {
00542                             firstLv = false;
00543                         } else {
00544                             lv.append(" and ");
00545                         }
00546                         lv.append(fd.getJdbcFieldName() + "=?");
00547                     } else {
00548                         if (firstLf) {
00549                            firstLf = false;
00550                         } else {
00551                             lf.append(", ");
00552                         }
00553                         lf.append(fd.getJdbcFieldName() + "=?");
00554                     }
00555                 }
00556                 mSqlStmt =
00557                     "update " + edd.getJdbcTableName()
00558                     + " set " + lf + " where " + lv;
00559             }
00560         } else if (dd instanceof EntityJdbcCmp2Desc) {
00561             // ejbSelect() methods
00562             boolean isEjbSelect = false;
00563             if (mName.startsWith("ejbSelect")
00564                 && javax.ejb.EntityBean.class.isAssignableFrom(declClass)) {
00565                 isEjbSelect = true;
00566             }
00567             if (isEjbSelect) {
00568                 if (java.util.Collection.class.equals(method.getReturnType())) {
00569                     mKind = METHOD_EJB_SELECT_COL;
00570                 } else if (java.util.Set.class.equals(method.getReturnType())) {
00571                     mKind = METHOD_EJB_SELECT_SET;
00572                 } else {
00573                     mKind = METHOD_EJB_SELECT_SIMPLE;
00574                 }
00575             }
00576             if (isFinder || isEjbSelect) {
00577                 mParamList = new ArrayList();
00578                 for (int p = 0; p < params.length; p++) {
00579                     mParamList.add(new VcParam(params[p], dd));
00580                 }
00581                 // TODO : Change this condition to fix the bug #300676 AFTER the fix of the bug #300533
00582                 //if (mKind != METHOD_FINDER_BY_PK) {
00583                 if (isEjbSelect) {
00584                     try {
00585                         resFieldOfEjbql = ((MethodCmp2Desc) methodDesc).getQueryTreeHolder(null).getResField();
00586                         if (resFieldOfEjbql.getType().getTypeCode() == PType.TYPECODE_REFERENCE) {
00587                             if (((MethodCmp2Desc) methodDesc).isResultTypeMappingRemote()) {
00588                                 isEjbqlReturnRemoteBean = true;
00589                             } else {
00590                                 isEjbqlReturnLocalBean = true;
00591                             }
00592                         }
00593                     } catch (DeploymentDescException e) {
00594                         throw new Error("Error while the EJB-QL parsing of '" + method.toString()
00595                                         + "': " + e.getMessage());
00596                     }
00597                 }
00598             }
00599 
00600         }
00601 
00602         // System.out.print("VcMethod: "+method.toString());
00603         // System.out.println(toString());
00604     }
00605 
00615     private String parseWhere(String fragment, List pos) {
00616         StringTokenizer parseWhere = new StringTokenizer(fragment, "?\n", true);
00617         int numpos = pos.size();
00618         String newWhere = "";
00619         String tok;
00620         while (parseWhere.hasMoreTokens()) {
00621             tok = parseWhere.nextToken();
00622             String numVar = "";
00623             if (Character.isDigit(tok.charAt(0))) {
00624                 for (int i = 0; tok.length() > i && Character.isDigit(tok.charAt(i)); i++) {
00625                     numVar += tok.charAt(i);
00626                 }
00627                 if (numVar.length() > 0) {
00628                     newWhere += tok.substring(numVar.length(), tok.length());
00629                     pos.set(numpos - 1, (Object) new Integer(Integer.parseInt(numVar) - 1));
00630                 }
00631             } else {
00632                 newWhere += tok;
00633                 if (tok.charAt(0) == '?') {
00634                     pos.add(new Integer(numpos++));
00635                 }
00636             }
00637         }
00638         return newWhere;
00639     }
00640 
00644     public String getName() {
00645         return mName;
00646     }
00647 
00651     public String getCapName() {
00652         return mCapName;
00653     }
00654 
00658     public String getFormalParameters() {
00659         return mFormalParameters.toString();
00660     }
00661 
00665     public String getActualParameters() {
00666         return mActualParameters.toString();
00667     }
00668 
00672     public String getExceptionList() {
00673         return mExceptionList.toString();
00674     }
00675 
00679     public boolean canThrowCreate() {
00680         return canThrowCreate;
00681     }
00682 
00686     public String getSecuritySignature() {
00687         if (mSecuritySignature == null) {
00688             throw new Error("VcMethod.getSecuritySignature() not available for the method '"
00689                             + mMethod.toString() + "'");
00690         }
00691         return mSecuritySignature;
00692     }
00693 
00697     public int getTxAttribute() {
00698         if (mTxAttribute == MethodDesc.TX_NULL) {
00699             throw new Error("VcMethod.getTxAttribute() not available for the method '"
00700                             + mMethod.toString() + "'");
00701         }
00702         return mTxAttribute;
00703     }
00704 
00708     public String getReturnType() {
00709         return mReturnType;
00710     }
00711 
00715     public boolean isFinderAll() {
00716         // How to known a finder is a finderAll !?
00717         return false;
00718     }
00719 
00723     public boolean isFinderByPk() {
00724         return (mKind == METHOD_FINDER_BY_PK);
00725     }
00726 
00730     public boolean isFinderSimple() {
00731         return (mKind == METHOD_FINDER_SIMPLE);
00732     }
00733 
00737     public boolean isFinderEnum() {
00738         return (mKind == METHOD_FINDER_ENUM);
00739     }
00740 
00744     public boolean isFinderCol() {
00745         return (mKind == METHOD_FINDER_COL);
00746     }
00747 
00751     public boolean isEjbSelectSimple() {
00752         return (mKind == METHOD_EJB_SELECT_SIMPLE);
00753     }
00754 
00758     public boolean isEjbSelectSet() {
00759         return (mKind == METHOD_EJB_SELECT_SET);
00760     }
00761 
00765     public boolean isEjbSelectCol() {
00766         return (mKind == METHOD_EJB_SELECT_COL);
00767     }
00768 
00772     public boolean isEjbqlReturnRemoteBean() {
00773         return isEjbqlReturnRemoteBean;
00774     }
00775 
00779     public boolean isEjbqlReturnLocalBean() {
00780         return isEjbqlReturnLocalBean;
00781     }
00782 
00786     public boolean isCreate() {
00787         return (mKind == METHOD_CREATE);
00788     }
00789 
00793     public boolean isEjbCreate() {
00794         return (mKind == METHOD_EJB_CREATE);
00795     }
00796 
00800     public boolean isEjbPostCreate() {
00801         return (mKind == METHOD_EJB_POST_CREATE);
00802     }
00803 
00807     public boolean isRemoveThis() {
00808         return (mKind == METHOD_REMOVE_THIS);
00809     }
00810 
00814     public boolean isRemovePk() {
00815         return (mKind == METHOD_REMOVE_PK);
00816     }
00817 
00821     public boolean isRemoveHandle() {
00822         return (mKind == METHOD_REMOVE_HANDLE);
00823     }
00824 
00828     public boolean isEjbRemove() {
00829         return (mKind == METHOD_EJB_REMOVE);
00830     }
00831 
00835     public boolean isEjbLoad() {
00836         return (mKind == METHOD_EJB_LOAD);
00837     }
00838 
00842     public boolean isEjbStore() {
00843         return (mKind == METHOD_EJB_STORE);
00844     }
00845 
00849     public boolean isEjbSetEntityContext() {
00850         return (mKind == METHOD_EJB_SET_ENTITY_CONTEXT);
00851     }
00852 
00856     public boolean isEjbActivate() {
00857         return (mKind == METHOD_EJB_ACTIVATE);
00858     }
00859 
00864     public String getSqlStmt() {
00865         if (mSqlStmt == null) {
00866             throw new Error("VcMethod.getSqlStmt() not available for the method '"
00867                             + mMethod.toString() + "'");
00868         }
00869         return mSqlStmt;
00870     }
00871 
00872 
00876     public Class[] getParameterTypes() {
00877         return parameterTypes;
00878     }
00879 
00883     public int getParametersNumber() {
00884         return parameterTypes.length;
00885     }
00886 
00887 
00892     public Vector getParamWhereList() {
00893         if (mParamWhereList == null) {
00894             throw new Error("VcMethod.getParamWhereList() not available for the method '"
00895                             + mMethod.toString() + "'");
00896         }
00897         return (new Vector(mParamWhereList));
00898     }
00899 
00900 
00904     public Vector getParamList() {
00905         if (mParamList == null) {
00906             throw new Error("VcMethod.getParamList() not available for the method '"
00907                             + mMethod.toString() + "'");
00908         }
00909         return (new Vector(mParamList));
00910     }
00911 
00912 
00916     public int getMethodIndex() {
00917         return methodIndex;
00918     }
00919 
00924     public org.objectweb.medor.api.Field getResFieldOfEjbql() {
00925         return resFieldOfEjbql;
00926     }
00927 
00932     public String getTupleGetter() {
00933         PType type = resFieldOfEjbql.getType();
00934         switch(type.getTypeCode()) {
00935         case PType.TYPECODE_BOOLEAN:
00936             return "getBoolean";
00937         case PType.TYPECODE_BYTE:
00938             return "getByte";
00939         case PType.TYPECODE_CHAR:
00940             return "getChar";
00941         case PType.TYPECODE_DATE:
00942             return "getDate";
00943         case PType.TYPECODE_DOUBLE:
00944             return "getDouble";
00945         case PType.TYPECODE_FLOAT:
00946             return "getFloat";
00947         case PType.TYPECODE_INT:
00948             return "getInt";
00949         case PType.TYPECODE_LONG:
00950             return "getLong";
00951         case PType.TYPECODE_SERIALIZED:
00952             return "getObject";
00953         case PType.TYPECODE_SHORT:
00954             return "getShort";
00955         case PType.TYPECODE_STRING:
00956             return "getString";
00957         case PType.TYPECODE_BIGDECIMAL:
00958         case PType.TYPECODE_REFERENCE:
00959         case PType.TYPECODE_BYTEARRAY:
00960         case PType.TYPECODE_CHARARRAY:
00961         case PType.TYPECODE_OBJBOOLEAN:
00962         case PType.TYPECODE_OBJBYTE:
00963         case PType.TYPECODE_OBJCHAR:
00964         case PType.TYPECODE_OBJDOUBLE:
00965         case PType.TYPECODE_OBJFLOAT:
00966         case PType.TYPECODE_OBJINT:
00967         case PType.TYPECODE_OBJLONG:
00968         case PType.TYPECODE_OBJSHORT:
00969         default:
00970             return "getObject";
00971         }
00972     }
00973 
00978     public boolean isTupleGetterPrimitive() {
00979         PType type = resFieldOfEjbql.getType();
00980         switch(type.getTypeCode()) {
00981         case PType.TYPECODE_BOOLEAN:
00982         case PType.TYPECODE_BYTE:
00983         case PType.TYPECODE_CHAR:
00984         case PType.TYPECODE_DOUBLE:
00985         case PType.TYPECODE_FLOAT:
00986         case PType.TYPECODE_INT:
00987         case PType.TYPECODE_LONG:
00988         case PType.TYPECODE_SHORT:
00989             return true;
00990         default:
00991             return false;
00992         }
00993     }
00994 
00999     public String getTupleGetterObjectClass() {
01000         PType type = resFieldOfEjbql.getType();
01001         switch(type.getTypeCode()) {
01002         case PType.TYPECODE_BOOLEAN:
01003             return "Boolean";
01004         case PType.TYPECODE_BYTE:
01005             return "Byte";
01006         case PType.TYPECODE_CHAR:
01007             return "Char";
01008         case PType.TYPECODE_DOUBLE:
01009             return "Double";
01010         case PType.TYPECODE_FLOAT:
01011             return "Float";
01012         case PType.TYPECODE_INT:
01013             return "Integer";
01014         case PType.TYPECODE_LONG:
01015             return "Long";
01016         case PType.TYPECODE_SHORT:
01017             return "Short";
01018         default:
01019             return "Object";
01020         }
01021     }
01022 
01028     String[] splitPath(String path) {
01029         StringTokenizer st = new StringTokenizer(path, ".");
01030         String[] ret = new String[st.countTokens()];
01031         for (int i = 0; i < ret.length; i++) {
01032             ret[i] = st.nextToken();
01033         }
01034         return ret;
01035     }
01036 
01041     public String getArrayObjectParameters() {
01042         if (mArrayObjectParameters.length() == 0) {
01043             return "new Object[0]";
01044         } else {
01045             return "new Object[] {" + mArrayObjectParameters.toString() + "}";
01046         }
01047     }
01048 
01049 
01053     public String toString() {
01054         StringBuffer ret = new StringBuffer();
01055         ret.append("\n    Name                  = " + getName());
01056         ret.append("\n    CapName               = " + getCapName());
01057         ret.append("\n    FormalParameters      = " + getFormalParameters());
01058         ret.append("\n    ActualParameters      = " + getActualParameters());
01059         ret.append("\n    ExceptionList         = " + getExceptionList());
01060         if (mSecuritySignature != null) {
01061             ret.append("\n    SecuritySignature     = " + getSecuritySignature());
01062         }
01063         if (mTxAttribute != MethodDesc.TX_NULL) {
01064             ret.append("\n    TxAttribute           = " + getTxAttribute());
01065         }
01066         ret.append("\n    ReturnType            = " + getReturnType());
01067         ret.append("\n    isFinderByPk          = " + isFinderByPk());
01068         ret.append("\n    isFinderSimple        = " + isFinderSimple());
01069         ret.append("\n    isFinderEnum          = " + isFinderEnum());
01070         ret.append("\n    isFinderCol           = " + isFinderCol());
01071         ret.append("\n    isCreate              = " + isCreate());
01072         ret.append("\n    isEjbCreate           = " + isEjbCreate());
01073         ret.append("\n    isRemoveThis          = " + isRemoveThis());
01074         ret.append("\n    isRemovePk            = " + isRemovePk());
01075         ret.append("\n    isRemoveHandle        = " + isRemoveHandle());
01076         ret.append("\n    isEjbRemove           = " + isEjbRemove());
01077         ret.append("\n    isEjbLoad             = " + isEjbLoad());
01078         ret.append("\n    isEjbStore            = " + isEjbStore());
01079         ret.append("\n    isEjbSetEntityContext = " + isEjbSetEntityContext());
01080         ret.append("\n    isEjbActivate         = " + isEjbActivate());
01081         ret.append("\n    isEjbSelectSimple     = " + isEjbSelectSimple());
01082         ret.append("\n    isEjbSelectSet        = " + isEjbSelectSet());
01083         ret.append("\n    isEjbSelectCol        = " + isEjbSelectCol());
01084         if (mSqlStmt != null) {
01085             ret.append("\n    SqlStmt               = " + getSqlStmt());
01086         }
01087         if (mParamWhereList != null) {
01088             ret.append("\n    ParamWhereList        = " + getParamWhereList());
01089         }
01090         return (ret.toString());
01091     }
01092 
01093 }

Generated on Tue Feb 15 15:05:48 2005 for JOnAS by  doxygen 1.3.9.1