Coverage report

  %line %branch
net.sf.infrared.aspects.jdbc.SqlContext
0% 
0% 

 1  
 /* 
 2  
  * Copyright 2005 Tavant Technologies and Contributors
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License")
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  * 
 16  
  *
 17  
  *
 18  
  * Original Author:  binil.thomas (Tavant Technologies)
 19  
  * Contributor(s):   -;
 20  
  *
 21  
  */
 22  
 package net.sf.infrared.aspects.jdbc;
 23  
 
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 
 28  
 import net.sf.infrared.base.model.ExecutionContext;
 29  
 
 30  
 /**
 31  
  * 
 32  
  * @author binil.thomas
 33  
  */
 34  
 public class SqlContext implements ExecutionContext {
 35  0
 	private SqlPrepareContext prepare = null;
 36  0
 	private SqlExecuteContext execute = null;
 37  
 	private String sql;
 38  
 		
 39  0
 	private List children = new ArrayList(3);
 40  
 	
 41  0
 	public SqlContext(String sql) {
 42  0
 		if (sql == null) {
 43  0
 			throw new IllegalArgumentException("sql string cannot be null");
 44  
 		}
 45  0
 		this.sql = sql;
 46  0
 	}
 47  
 	
 48  
 	public SqlContext(String sql, String layer){
 49  0
 		this(sql);
 50  0
 	}
 51  
 	
 52  
 	public String getName() {		
 53  0
 		return sql;
 54  
 	}
 55  
 	
 56  
 	
 57  
 	public ExecutionContext getParent() {
 58  0
 		return null;
 59  
 	}
 60  
 
 61  
 	public String getLayer() {
 62  0
 		return "SQL";
 63  
 	}
 64  
 
 65  
 	public List getChildren() {
 66  0
 		return children;
 67  
 	}
 68  
 
 69  
 	public void addChild(ExecutionContext ctx) {
 70  0
 		if (children.contains(ctx))
 71  0
 			return;
 72  
 
 73  0
 		if (ctx instanceof SqlPrepareContext)
 74  0
 			this.prepare = (SqlPrepareContext) ctx;
 75  0
 		else if (ctx instanceof SqlExecuteContext)
 76  0
 			this.execute = (SqlExecuteContext) ctx;
 77  
 		else
 78  0
 			throw new IllegalArgumentException("invalid child element for SqlContext");
 79  
 
 80  0
 		children.add(ctx);
 81  0
 	}
 82  
 	
 83  
 	public String toString() {
 84  0
 		return sql;
 85  
 	}
 86  
 	
 87  
 	public boolean equals(Object o) {
 88  0
 		if (o == null) return false;
 89  
 		
 90  0
 		if (this == o) return true;
 91  
 		
 92  0
 		if (! (o instanceof SqlContext) ) return false;
 93  
 		
 94  0
 		SqlContext other = (SqlContext) o;
 95  
 		
 96  0
 		return this.sql.equals(other.sql) ;
 97  
 	}
 98  
 
 99  
 	public int hashCode() {
 100  0
 		return 13 * sql.hashCode();
 101  
 	}
 102  
 	
 103  
 	public SqlPrepareContext getPrepareContext() {
 104  0
         synchronized (this) {
 105  0
             if (prepare == null) {
 106  0
                 prepare = new SqlPrepareContext(this);
 107  0
                 children.add(prepare);
 108  
             }
 109  0
         }
 110  0
 		return prepare;
 111  
 	}
 112  
 	
 113  
 	public SqlExecuteContext getExecuteContext() {
 114  0
         synchronized (this) {
 115  0
             if (execute == null) {
 116  0
                 execute = new SqlExecuteContext(this);
 117  0
                 children.add(execute);
 118  
             }
 119  0
         }
 120  0
 		return execute;
 121  
 	}
 122  
 	
 123  
 	public String getSql() {
 124  0
 		return sql;
 125  
 	}
 126  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.