Coverage Report - net.admin4j.jdbc.driver.SqlStatementSummaryDataMeasure
 
Classes in this File Line Coverage Branch Coverage Complexity
SqlStatementSummaryDataMeasure
66%
8/12
50%
3/6
1.75
 
 1  
 /*
 2  
  * This software is licensed under the Apache License, Version 2.0
 3  
  * (the "License") agreement; you may not use this file except in compliance with
 4  
  * the License.  You may obtain a copy of the License at
 5  
  * 
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  * 
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package net.admin4j.jdbc.driver;
 15  
 
 16  
 import java.util.HashSet;
 17  
 import java.util.Map;
 18  
 import java.util.Set;
 19  
 import java.util.concurrent.ConcurrentHashMap;
 20  
 
 21  
 import net.admin4j.entity.ExecutionStack;
 22  
 import net.admin4j.timer.SummaryDataMeasure;
 23  
 
 24  
 /**
 25  
  * Tracks timing statistics for a SQL statement
 26  
  * @author D. Ashmore
 27  
  * @since 1.0.1
 28  
  */
 29  
 public class SqlStatementSummaryDataMeasure extends SummaryDataMeasure {
 30  
 
 31  
     private static final long serialVersionUID = 2697140795168204384L;
 32  36
     private Map<ExecutionStack,ExecutionStack> executionStackSet 
 33  
         = new ConcurrentHashMap<ExecutionStack,ExecutionStack>();
 34  
 
 35  
     public SqlStatementSummaryDataMeasure(long firstObservationTime, ExecutionStack executionStack) {
 36  36
         super(firstObservationTime);
 37  36
         if (executionStack != null) {
 38  36
             executionStackSet.put(executionStack, executionStack);
 39  
         }
 40  36
     }
 41  
 
 42  
     /* (non-Javadoc)
 43  
      * @see net.admin4j.timer.SummaryDataMeasure#addNumber(java.lang.Number)
 44  
      */
 45  
     @Override
 46  
     public synchronized void addNumber(Number number) {
 47  0
         this.addNumber(number, null);
 48  0
     }
 49  
     
 50  
     public synchronized void addNumber(Number number, ExecutionStack executionStack) {
 51  180138
         super.addNumber(number);
 52  
         
 53  180138
         if ( executionStack != null && !executionStackSet.containsKey(executionStack)) {
 54  0
             executionStackSet.put(executionStack, executionStack);
 55  
         }
 56  180138
     }
 57  
     
 58  
     public synchronized Set<ExecutionStack> getExecutionStackSet() {
 59  0
         return new HashSet<ExecutionStack>(executionStackSet.keySet());
 60  
     }
 61  
 
 62  
 }