KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > deployment > api > MethodJdbcCmp1Desc


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: MethodJdbcCmp1Desc.java,v 1.6 2005/03/11 12:34:28 joaninh Exp $
23  * --------------------------------------------------------------------------
24  */

25
26
27 package org.objectweb.jonas_ejb.deployment.api;
28
29 import java.lang.reflect.Method JavaDoc;
30 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
31
32 /**
33  * Class to hold meta-information related to CMP v1 attributes of a method when a jdbc
34  * data store is used.
35  * @author Christophe Ney [cney@batisseurs.com] : Initial developer
36  * @author Helene Joanin
37  */

38 public class MethodJdbcCmp1Desc extends MethodDesc {
39
40     protected String JavaDoc whereClause = null;
41     protected int whereClauseStatus = APPLY_TO_BEAN;
42
43     /**
44      * constructor to be used by parent node
45      */

46     public MethodJdbcCmp1Desc(BeanDesc beanDesc,Method JavaDoc meth, Class JavaDoc classDef, int index) {
47         super(beanDesc,meth, classDef,index);
48     }
49
50     /**
51      * Overwrite JdbcWhereClause
52      * @param jdbcWhereClause new value for jdbcWhereClause
53      * @param status applicability of given transAttribute parameter
54      */

55     void overwriteJdbcWhereClause(String JavaDoc jdbcWhereClause,int status)
56             throws DeploymentDescException {
57         if (status<this.whereClauseStatus)
58             return;
59         // Replace special characters (as line-feed, carriage-return) by a white space
60
char[] iwc = jdbcWhereClause.toCharArray();
61         char[] owc = new char[iwc.length];
62         for (int i = 0; i < iwc.length; i++) {
63             if (Character.isWhitespace(iwc[i])) {
64                 owc[i] = ' ';
65             } else {
66                 owc[i] = iwc[i];
67             }
68         }
69         whereClause = new String JavaDoc(owc);
70         whereClauseStatus = status;
71     }
72
73     /**
74      * Assessor for 'WHERE' clause set
75      * @return true if where clause has been set
76      */

77     public boolean hasWhereClause(){
78         return whereClause!=null;
79     }
80
81     /**
82      * Get 'WHERE' clause for the method
83      * @return String containing 'WHERE' clause
84      */

85     public String JavaDoc getWhereClause(){
86         if (whereClause==null) {
87             throw new Error JavaDoc("No whereClause defined for this method");
88         }
89         return whereClause;
90     }
91
92     /**
93      * Get 'WHERE' clause status for the method
94      */

95     public int getWhereClauseStatus(){
96         return whereClauseStatus;
97     }
98
99     /**
100      * String representation of the object for test purpose
101      * @return String representation of this object
102      */

103     public String JavaDoc toString() {
104         StringBuffer JavaDoc ret = new StringBuffer JavaDoc();
105         ret.append(super.toString());
106         if (hasWhereClause()) {
107             ret.append("\ngetWhereClause()="+getWhereClause());
108             ret.append("\ngetWhereClauseStatus()="+APPLY_TO[getWhereClauseStatus()]);
109         }
110         return ret.toString();
111     }
112
113 }
114
Popular Tags