Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 134   Methods: 5
NCLOC: 60   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
Operator.java 75% 87.5% 100% 86.2%
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/02/21
 7   
  */
 8   
 package org.asyrinx.brownie.core.sql;
 9   
 
 10   
 import java.util.HashSet;
 11   
 import java.util.Iterator;
 12   
 import java.util.Set;
 13   
 
 14   
 /**
 15   
  * DynamicSQLで使用する演算子を表すクラスです。
 16   
  */
 17   
 public class Operator {
 18  72
     public Operator(String code) {
 19  72
         super();
 20  72
         this.code = code;
 21  72
         operators.add(this);
 22   
     }
 23   
 
 24   
     final private String code;
 25   
 
 26   
     /**
 27   
      * @see java.lang.Object#equals(java.lang.Object)
 28   
      */
 29  17
     public boolean equals(Object obj) {
 30  17
         if (obj instanceof Operator) {
 31  3
             return obj == this;
 32   
         } else {
 33  14
             return code.equalsIgnoreCase(String.valueOf(obj));
 34   
         }
 35   
     }
 36   
     
 37   
     /* (non-Javadoc)
 38   
      * @see java.lang.Object#hashCode()
 39   
      */
 40  72
     public int hashCode() {
 41  72
         return code.hashCode();
 42   
     }
 43   
 
 44  57
     public String toString() {
 45  57
         return code;
 46   
     }
 47   
 
 48   
     private static final Set operators = new HashSet();
 49   
 
 50   
     /** none (null object) */
 51   
     public static final Operator NONE = new Operator("");
 52   
 
 53   
     /** = */
 54   
     public static final Operator EQUAL = new Operator("=");
 55   
 
 56   
     /** == */
 57   
     public static final Operator EQUAL2 = new Operator("==");
 58   
 
 59   
     /** <> */
 60   
     public static final Operator NOT_EQUAL = new Operator("<>");
 61   
 
 62   
     /** != */
 63   
     public static final Operator NOT_EQUAL2 = new Operator("!=");
 64   
 
 65   
     /** > */
 66   
     public static final Operator GREATER_THAN = new Operator(">");
 67   
 
 68   
     /** >= */
 69   
     public static final Operator GREATER_EQUAL = new Operator(">=");
 70   
 
 71   
     /** => */
 72   
     public static final Operator GREATER_EQUAL2 = new Operator("=>");
 73   
 
 74   
     /** < */
 75   
     public static final Operator LESS_THAN = new Operator("<");
 76   
 
 77   
     /** >= */
 78   
     public static final Operator LESS_EQUAL = new Operator("<=");
 79   
 
 80   
     /** => */
 81   
     public static final Operator LESS_EQUAL2 = new Operator("=<");
 82   
 
 83   
     /** like */
 84   
     public static final Operator LIKE = new Operator("like");
 85   
 
 86   
     /** not like */
 87   
     public static final Operator NOT_LIKE = new Operator("not like");
 88   
 
 89   
     /** is */
 90   
     public static final Operator IS = new Operator("is");
 91   
 
 92   
     /** not is */
 93   
     public static final Operator NOT_IS = new Operator("not is");
 94   
 
 95   
     /** in */
 96   
     public static final Operator IN = new Operator("in");
 97   
 
 98   
     /** not in */
 99   
     public static final Operator NOT_IN = new Operator("not in");
 100   
 
 101   
     /** exists */
 102   
     public static final Operator EXISTS = new Operator("exists");
 103   
 
 104   
     /** not exists */
 105   
     public static final Operator NOT_EXISTS = new Operator("not exists");
 106   
 
 107   
     /** between */
 108   
     public static final Operator BETWEEN = new Operator("between");
 109   
 
 110   
     /** not between */
 111   
     public static final Operator NOT_BETWEEN = new Operator("not between");
 112   
 
 113   
     /** and */
 114   
     public static final Operator AND = new Operator("and");
 115   
 
 116   
     /** or */
 117   
     public static final Operator OR = new Operator("or");
 118   
 
 119   
     /** xor */
 120   
     public static final Operator XOR = new Operator("xor");
 121   
 
 122  3
     public static Operator get(Object value) {
 123  3
         if (value instanceof Operator)
 124  0
             return (Operator) value;
 125  3
         final Iterator iterator = operators.iterator();
 126  14
         while (iterator.hasNext()) {
 127  14
             final Operator operator = (Operator) iterator.next();
 128  14
             if (operator.equals(value))
 129  3
                 return operator;
 130   
         }
 131  0
         return null;
 132   
     }
 133   
 
 134   
 }