1 23 24 package com.sun.enterprise.deployment; 25 26 import java.lang.reflect.Method ; 27 import java.util.logging.*; 28 import com.sun.enterprise.deployment.util.LogDomains; 29 30 37 38 public final class QueryDescriptor extends Descriptor { 39 40 private String query; 43 44 private String sql; 46 47 private MethodDescriptor methodDescriptor; 48 private Method method; 49 50 51 57 private static final int NO_RETURN_TYPE_MAPPING = 0; 58 private static final int RETURN_LOCAL_TYPES = 1; 59 private static final int RETURN_REMOTE_TYPES = 2; 60 61 private int returnTypeMapping; 62 63 66 static Logger _logger = LogDomains.getLogger(LogDomains.DPL_LOGGER); 67 68 public QueryDescriptor() 69 { 70 this.query = null; 71 this.sql = null; 72 this.returnTypeMapping = NO_RETURN_TYPE_MAPPING; 73 } 74 75 public QueryDescriptor(QueryDescriptor otherQuery, Method m) { 76 this.query = otherQuery.query; 77 this.sql = otherQuery.sql; 78 this.method = m; 79 this.returnTypeMapping = otherQuery.returnTypeMapping; 80 } 81 82 93 94 public void setQueryMethod(Method m) 95 { 96 this.method = m; 97 } 98 99 public Method getQueryMethod() 100 { 101 return method; 102 } 103 104 public void setQueryMethodDescriptor(MethodDescriptor m) { 105 methodDescriptor = m; 106 } 107 108 public MethodDescriptor getQueryMethodDescriptor() { 109 return methodDescriptor; 110 } 111 112 public boolean getIsEjbQl() 113 { 114 return (query != null); 115 } 116 117 122 public void setQuery(String query) 123 { 124 _logger.log(Level.FINE,"input query = '" + query + "'"); 125 126 String newQuery = (query != null) ? query.trim() : null; 127 if( (newQuery != null) && newQuery.equals("") ) { 128 newQuery = null; 129 } 130 if( newQuery == null ) { 131 _logger.log(Level.FINE,"query has no content -- setting to NULL"); 132 } else { 133 _logger.log(Level.FINE,"setting query to '" + newQuery + "'"); 134 } 135 this.query = newQuery; 136 } 137 138 141 public String getQuery() 142 { 143 return query; 144 } 145 146 public boolean getHasSQL() { 147 return (this.sql != null); 148 } 149 150 public void setSQL(String sql) 151 { 152 this.sql = sql; 153 } 154 155 public String getSQL() 156 { 157 return sql; 158 } 159 160 161 public boolean getHasNoReturnTypeMapping() { 163 return (returnTypeMapping == NO_RETURN_TYPE_MAPPING); 164 } 165 166 public boolean getHasLocalReturnTypeMapping() { 168 return (returnTypeMapping == RETURN_LOCAL_TYPES); 169 } 170 171 public boolean getHasRemoteReturnTypeMapping() { 173 return (returnTypeMapping == RETURN_REMOTE_TYPES); 174 } 175 176 public void setHasNoReturnTypeMapping() { 177 returnTypeMapping = NO_RETURN_TYPE_MAPPING; 178 } 179 180 public void setHasLocalReturnTypeMapping() { 181 returnTypeMapping = RETURN_LOCAL_TYPES; 182 } 183 184 public void setHasRemoteReturnTypeMapping() { 185 returnTypeMapping = RETURN_REMOTE_TYPES; 186 } 187 188 public int getReturnTypeMapping() { 189 return returnTypeMapping; 190 } 191 192 public void print(StringBuffer toStringBuffer) { 193 toStringBuffer.append("Query "); 194 if(getQueryMethodDescriptor() != null) 195 getQueryMethodDescriptor().print(toStringBuffer); 196 toStringBuffer.append("\n"); 197 if (getHasSQL()) { 198 toStringBuffer.append("SQL : ").append(getSQL()); 199 return; 200 } 201 if (getIsEjbQl()) { 202 toStringBuffer.append("EJB QL: ").append(query); 203 return; 204 } 205 toStringBuffer.append(" No query associated"); 206 } 207 208 } 209 210 | Popular Tags |