Coverage Report - org.kuali.student.core.statement.ui.client.widgets.rules.Token
 
Classes in this File Line Coverage Branch Coverage Complexity
Token
0%
0/64
0%
0/24
2.333
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.core.statement.ui.client.widgets.rules;
 17  
 
 18  0
 public class Token implements Cloneable {
 19  
 
 20  0
     public static int And = 1;        //TODO use AndOrButton class int instead?
 21  0
     public static int Or = 2;
 22  0
     public static int StartParenthesis = 3;
 23  0
     public static int EndParenthesis = 4;
 24  0
     public static int Condition = 5;
 25  
     public String value;
 26  
     public int type;
 27  
 
 28  0
     private boolean isCheckBoxOn = false;
 29  0
     private boolean isTokenOperator = false;
 30  0
     private String tokenID = "";
 31  
 
 32  
     public boolean isCheckBoxOn() {
 33  0
         return isCheckBoxOn;
 34  
     }
 35  
 
 36  
     public void setCheckBoxOn(boolean checkBoxOn) {
 37  0
         isCheckBoxOn = checkBoxOn;
 38  0
     }
 39  
 
 40  
     public String getTokenID() {
 41  0
         return tokenID;
 42  
     }
 43  
 
 44  
     public void setTokenID(String tokenID) {
 45  0
         this.tokenID = tokenID;
 46  0
     }
 47  
 
 48  
     public int getType() {
 49  0
         return type;
 50  
     }
 51  
 
 52  
     public void setType(int type) {
 53  0
         this.type = type;
 54  0
     }
 55  
 
 56  
     public boolean isTokenOperator() {
 57  0
         return isTokenOperator;
 58  
     }
 59  
 
 60  
     public void setTokenOperator(boolean tokenOperator) {
 61  0
         isTokenOperator = tokenOperator;
 62  0
     }
 63  
 
 64  
     public static Token createAndToken(){
 65  0
         Token t = new Token();
 66  0
         t.type = And;
 67  0
         t.value = "and";
 68  0
         return t;
 69  
     }
 70  
 
 71  
     public static Token createOrToken(){
 72  0
         Token t = new Token();
 73  0
         t.type = Or;
 74  0
         t.value = "or";
 75  0
         return t;
 76  
     }
 77  
 
 78  
     public Token toggleAndOr(){
 79  0
         Token t = new Token ();
 80  0
         if(type == And){
 81  0
             t.type = Or;
 82  0
             t.value = "Or";
 83  
 
 84  0
         }else if(type == Or){
 85  0
             t.type = And;
 86  0
             t.value = "And";
 87  
         }
 88  0
         return t;
 89  
     }
 90  
     
 91  
     public boolean equals(Object obj){
 92  0
         if(obj instanceof Token == false){
 93  0
             return false;
 94  
         }
 95  0
         Token t = (Token)obj;
 96  0
         if(t.value == null){
 97  0
             return false;
 98  
         }
 99  0
         if(t.value.equals(value) && t.type == type){
 100  0
             return true;
 101  
         }
 102  0
         return false;
 103  
     }
 104  
     
 105  
     public int hashCode(){
 106  0
             int hash =1;
 107  0
             hash = hash * 31 + new Integer(type).hashCode();
 108  0
             hash = hash * 31 + (value == null ? 0 : value.hashCode());
 109  0
             return hash;
 110  
     }
 111  
     
 112  
     public Token clone(){
 113  0
         Token t = new Token();
 114  0
         t.type = type;
 115  0
         t.value = value;
 116  0
         return t;
 117  
     }
 118  
 
 119  
     public String toString() {
 120  0
         if (type == And) {
 121  0
             return "and";
 122  0
         } else if (type == Or) {
 123  0
             return "or";
 124  0
         } else if (type == StartParenthesis) {
 125  0
             return "(";
 126  0
         } else if (type == EndParenthesis) {
 127  0
             return ")";
 128  0
         } else if (type == Condition) {
 129  0
             return value;
 130  
         }
 131  0
         return "";
 132  
     }
 133  
 }