Coverage Report - org.kuali.db.jdbc.DelimiterType
 
Classes in this File Line Coverage Branch Coverage Complexity
DelimiterType
0%
0/21
0%
0/12
2
 
 1  
 package org.kuali.db.jdbc;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
 5  
  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 7  
  * License. You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 12  
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 13  
  * specific language governing permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 /**
 17  
  * @author Brian Topping
 18  
  */
 19  
 public class DelimiterType {
 20  
     public static final String NORMAL = "normal";
 21  
 
 22  
     public static final String ROW = "row";
 23  
 
 24  
     /**
 25  
      * The selected value in this enumeration.
 26  
      */
 27  
     protected String value;
 28  
 
 29  
     /**
 30  
      * the index of the selected value in the array.
 31  
      */
 32  0
     private int index = -1;
 33  
 
 34  
     /**
 35  
      * This is the only method a subclass needs to implement.
 36  
      * 
 37  
      * @return an array holding all possible values of the enumeration. The order of elements must be fixed so that
 38  
      *         <tt>indexOfValue(String)</tt> always return the same index for the same value.
 39  
      */
 40  
     public String[] getValues() {
 41  0
         return new String[] { NORMAL, ROW };
 42  
     }
 43  
 
 44  
     /** bean constructor */
 45  0
     protected DelimiterType() {
 46  0
     }
 47  
 
 48  
     /**
 49  
      * Set the delimiterValue. Use DelimiterType.NORMAL or DelimiterType.ROW
 50  
      * 
 51  
      * @param value
 52  
      */
 53  
     public final void setValue(String value) {
 54  0
         int index = indexOfValue(value);
 55  0
         if (index == -1) {
 56  0
             throw new IllegalArgumentException(value + " is not a legal value for this attribute");
 57  
         }
 58  0
         this.index = index;
 59  0
         this.value = value;
 60  0
     }
 61  
 
 62  
     /**
 63  
      * Is this value included in the enumeration?
 64  
      * 
 65  
      * @param value
 66  
      * @return true if this value is supported
 67  
      */
 68  
     public final boolean containsValue(String value) {
 69  0
         return (indexOfValue(value) != -1);
 70  
     }
 71  
 
 72  
     /**
 73  
      * get the index of a value in this enumeration.
 74  
      * 
 75  
      * @param value
 76  
      *            the string value to look for.
 77  
      * @return the index of the value in the array of strings or -1 if it cannot be found.
 78  
      * @see #getValues()
 79  
      */
 80  
     public final int indexOfValue(String value) {
 81  0
         String[] values = getValues();
 82  0
         if (values == null || value == null) {
 83  0
             return -1;
 84  
         }
 85  0
         for (int i = 0; i < values.length; i++) {
 86  0
             if (value.equals(values[i])) {
 87  0
                 return i;
 88  
             }
 89  
         }
 90  0
         return -1;
 91  
     }
 92  
 
 93  
     /**
 94  
      * @return the selected value.
 95  
      */
 96  
     public final String getValue() {
 97  0
         return value;
 98  
     }
 99  
 
 100  
     /**
 101  
      * @return the index of the selected value in the array.
 102  
      * @see #getValues()
 103  
      */
 104  
     public final int getIndex() {
 105  0
         return index;
 106  
     }
 107  
 
 108  
     /**
 109  
      * Convert the value to its string form.
 110  
      * 
 111  
      * @return the string form of the value.
 112  
      */
 113  
     public String toString() {
 114  0
         return getValue();
 115  
     }
 116  
 
 117  
 }