001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: MethodJdbcCmp1Desc.java 6407 2005-03-11 12:34:28Z joaninh $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_ejb.deployment.api;
025:
026: import java.lang.reflect.Method;
027: import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
028:
029: /**
030: * Class to hold meta-information related to CMP v1 attributes of a method when a jdbc
031: * data store is used.
032: * @author Christophe Ney [cney@batisseurs.com] : Initial developer
033: * @author Helene Joanin
034: */
035: public class MethodJdbcCmp1Desc extends MethodDesc {
036:
037: protected String whereClause = null;
038: protected int whereClauseStatus = APPLY_TO_BEAN;
039:
040: /**
041: * constructor to be used by parent node
042: */
043: public MethodJdbcCmp1Desc(BeanDesc beanDesc, Method meth,
044: Class classDef, int index) {
045: super (beanDesc, meth, classDef, index);
046: }
047:
048: /**
049: * Overwrite JdbcWhereClause
050: * @param jdbcWhereClause new value for jdbcWhereClause
051: * @param status applicability of given transAttribute parameter
052: */
053: void overwriteJdbcWhereClause(String jdbcWhereClause, int status)
054: throws DeploymentDescException {
055: if (status < this .whereClauseStatus)
056: return;
057: // Replace special characters (as line-feed, carriage-return) by a white space
058: char[] iwc = jdbcWhereClause.toCharArray();
059: char[] owc = new char[iwc.length];
060: for (int i = 0; i < iwc.length; i++) {
061: if (Character.isWhitespace(iwc[i])) {
062: owc[i] = ' ';
063: } else {
064: owc[i] = iwc[i];
065: }
066: }
067: whereClause = new String(owc);
068: whereClauseStatus = status;
069: }
070:
071: /**
072: * Assessor for 'WHERE' clause set
073: * @return true if where clause has been set
074: */
075: public boolean hasWhereClause() {
076: return whereClause != null;
077: }
078:
079: /**
080: * Get 'WHERE' clause for the method
081: * @return String containing 'WHERE' clause
082: */
083: public String getWhereClause() {
084: if (whereClause == null) {
085: throw new Error("No whereClause defined for this method");
086: }
087: return whereClause;
088: }
089:
090: /**
091: * Get 'WHERE' clause status for the method
092: */
093: public int getWhereClauseStatus() {
094: return whereClauseStatus;
095: }
096:
097: /**
098: * String representation of the object for test purpose
099: * @return String representation of this object
100: */
101: public String toString() {
102: StringBuffer ret = new StringBuffer();
103: ret.append(super .toString());
104: if (hasWhereClause()) {
105: ret.append("\ngetWhereClause()=" + getWhereClause());
106: ret.append("\ngetWhereClauseStatus()="
107: + APPLY_TO[getWhereClauseStatus()]);
108: }
109: return ret.toString();
110: }
111:
112: }
|