Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 205   Methods: 21
NCLOC: 93   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Conditions.java 0% 48.6% 42.9% 43.5%
coverage coverage
 1   
 /*
 2   
  * Joey and its relative products are published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 /*
 6   
  * Created on 2004/03/01
 7   
  */
 8   
 package org.asyrinx.brownie.core.sql2;
 9   
 
 10   
 import java.util.Date;
 11   
 
 12   
 import org.asyrinx.brownie.core.sql.Operator;
 13   
 
 14   
 /**
 15   
  * @author akima
 16   
  */
 17   
 public class Conditions extends Elements {
 18   
 
 19  20
     public void accept(Visitor visitor) {
 20  20
         visitor.visit(this);
 21   
     }
 22   
 
 23   
     private Operator connection = Operator.AND;
 24   
 
 25   
     /**
 26   
      * @return
 27   
      */
 28  19
     public Operator getConnection() {
 29  19
         return connection;
 30   
     }
 31   
 
 32   
     /**
 33   
      * @param operator
 34   
      */
 35  8
     public void setConnection(Operator operator) {
 36  8
         connection = operator;
 37   
     }
 38   
 
 39   
     /**
 40   
      * 条件群を追加します。
 41   
      */
 42  0
     public Conditions addNewCondition() {
 43  0
         return addNewConditions(this.getConnection());
 44   
     }
 45   
 
 46   
     /**
 47   
      * 条件群を追加します。
 48   
      */
 49  8
     public Conditions addNewConditions(Operator conn) {
 50  8
         final Conditions result = new Conditions();
 51  8
         result.setConnection(conn);
 52  8
         super.addImpl(result);
 53  8
         return result;
 54   
     }
 55   
 
 56   
     /**
 57   
      * 条件文を追加します。
 58   
      * 
 59   
      * @param condition
 60   
      */
 61  0
     public Conditions addPlainCondition(String condition) {
 62  0
         return add(null, condition, Operator.NONE);
 63   
     }
 64   
 
 65  26
     public Conditions add(String field, Object value, Operator operator) {
 66  26
         final Condition result = new Condition();
 67  26
         result.setFieldName(field);
 68  26
         result.setOperator(operator);
 69  26
         result.setValue(value);
 70  26
         result.setConditions(this);
 71  26
         super.addImpl(result);
 72  26
         return this;
 73   
     }
 74   
 
 75  0
     public Conditions addRange(String field, Object min, Object max) {
 76  0
         return addRange(field, min, max, true, true);
 77   
     }
 78   
 
 79  0
     public Conditions addRange(String field, Object min, Object max,
 80   
             boolean includeMin, boolean includeMax) {
 81  0
         final Conditions conditions = addNewConditions(Operator.AND);
 82  0
         if (includeMin)
 83  0
             conditions.add(field, min, Operator.GREATER_EQUAL);
 84   
         else
 85  0
             conditions.add(field, min, Operator.GREATER_THAN);
 86  0
         if (includeMax)
 87  0
             conditions.add(field, max, Operator.LESS_EQUAL);
 88   
         else
 89  0
             conditions.add(field, max, Operator.LESS_THAN);
 90  0
         return this;
 91   
     }
 92   
 
 93   
     /**
 94   
      * 文字列比較の条件を追加します。 <br>
 95   
      * 指定された比較する値は、シングルクォートで囲まれます。
 96   
      * 
 97   
      * @param field
 98   
      *            比較されるフィールド名
 99   
      * @param value
 100   
      *            比較する値
 101   
      * @param operater
 102   
      *            比較演算子
 103   
      */
 104  7
     public Conditions add(String field, String value) {
 105  7
         return add(field, value, Operator.EQUAL);
 106   
     }
 107   
 
 108   
     /**
 109   
      * 文字列比較の条件を追加します。 <br>
 110   
      * 指定された比較する値は、シングルクォートで囲まれます。
 111   
      * 
 112   
      * @param field
 113   
      *            比較されるフィールド名
 114   
      * @param value
 115   
      *            比較する値
 116   
      * @param operater
 117   
      *            比較演算子
 118   
      */
 119  7
     public Conditions add(String field, String value, Operator operater) {
 120  7
         return add(field, (Object) value, operater);
 121   
     }
 122   
 
 123   
     /**
 124   
      * フィールドの整数(int)として同じかどうかという条件を追加します。
 125   
      * 
 126   
      * @param field
 127   
      *            比較されるフィールド名
 128   
      * @param value
 129   
      *            比較する値
 130   
      */
 131  13
     public Conditions add(String field, int value) {
 132  13
         return add(field, value, Operator.EQUAL);
 133   
     }
 134   
 
 135   
     /**
 136   
      * フィールドの整数(int)として比較する条件を追加します。
 137   
      * 
 138   
      * @param field
 139   
      *            比較されるフィールド名
 140   
      * @param value
 141   
      *            比較する値
 142   
      * @param operater
 143   
      *            比較演算子
 144   
      */
 145  13
     public Conditions add(String field, int value, Operator operater) {
 146  13
         return add(field, new Integer(value), operater);
 147   
     }
 148   
 
 149  0
     public Conditions addRange(String field, int min, int max,
 150   
             boolean includeMin, boolean includeMax) {
 151  0
         return addRange(field, new Integer(min), new Integer(max), includeMin,
 152   
                 includeMax);
 153   
     }
 154   
 
 155   
     /**
 156   
      * フィールドの整数(long)として同じかどうかという条件を追加します。
 157   
      * 
 158   
      * @param field
 159   
      *            比較されるフィールド名
 160   
      * @param value
 161   
      *            比較する値
 162   
      */
 163  0
     public Conditions add(String field, long value) {
 164  0
         return add(field, value, Operator.EQUAL);
 165   
     }
 166   
 
 167   
     /**
 168   
      * フィールドの整数(long)として比較する条件を追加します。
 169   
      * 
 170   
      * @param field
 171   
      *            比較されるフィールド名
 172   
      * @param value
 173   
      *            比較する値
 174   
      * @param operater
 175   
      *            比較演算子
 176   
      */
 177  0
     public Conditions add(String field, long value, Operator operater) {
 178  0
         return add(field, new Long(value), operater);
 179   
     }
 180   
 
 181  0
     public Conditions addRange(String field, long min, long max,
 182   
             boolean includeMin, boolean includeMax) {
 183  0
         return addRange(field, new Long(min), new Long(max), includeMin,
 184   
                 includeMax);
 185   
     }
 186   
 
 187  0
     public Conditions add(String field, Date value) {
 188  0
         return add(field, value, Operator.EQUAL);
 189   
     }
 190   
 
 191  0
     public Conditions add(String field, Date value, Operator operater) {
 192  0
         return add(field, (Object) value, operater);
 193   
     }
 194   
 
 195  0
     public Conditions addRange(String field, Date beginDate, Date endDate) {
 196  0
         return addRange(field, beginDate, endDate, true, true);
 197   
     }
 198   
 
 199  0
     public Conditions addRange(String field, Date beginDate, Date endDate,
 200   
             boolean includeMin, boolean includeMax) {
 201  0
         return addRange(field, (Object) beginDate, (Object) endDate,
 202   
                 includeMin, includeMax);
 203   
     }
 204   
 
 205   
 }