Coverage Report - org.jtheque.core.managers.schema.Insert
 
Classes in this File Line Coverage Branch Coverage Complexity
Insert
0 %
0/19
0 %
0/8
1.857
 
 1  
 package org.jtheque.core.managers.schema;
 2  
 
 3  
 import org.jtheque.utils.StringUtils;
 4  
 
 5  
 import java.util.ArrayList;
 6  
 import java.util.Collection;
 7  
 import java.util.List;
 8  
 
 9  
 /*
 10  
  * This file is part of JTheque.
 11  
  *
 12  
  * JTheque is free software: you can redistribute it and/or modify
 13  
  * it under the terms of the GNU General Public License as published by
 14  
  * the Free Software Foundation, either version 3 of the License.
 15  
  *
 16  
  * JTheque is distributed in the hope that it will be useful,
 17  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 19  
  * GNU General Public License for more details.
 20  
  *
 21  
  * You should have received a copy of the GNU General Public License
 22  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 23  
  */
 24  
 
 25  
 /**
 26  
  * An insert of HSQL Database file.
 27  
  *
 28  
  * @author Baptiste Wicht
 29  
  */
 30  0
 public final class Insert {
 31  
     private String table;
 32  
     private List<String> values;
 33  
 
 34  
     /**
 35  
      * Return the table of the insert.
 36  
      *
 37  
      * @return The table of the insert.
 38  
      */
 39  
     public String getTable() {
 40  0
         return table;
 41  
     }
 42  
 
 43  
     /**
 44  
      * Set the table of the insert.
 45  
      *
 46  
      * @param table The table of the insert.
 47  
      */
 48  
     public void setTable(String table) {
 49  0
         this.table = table;
 50  0
     }
 51  
 
 52  
     /**
 53  
      * Return the String value at the specified index.
 54  
      *
 55  
      * @param index The index of the value to get.
 56  
      * @return the String value at the specified index or null if there is no values at this index.
 57  
      */
 58  
     private String get(int index) {
 59  0
         return values.get(index);
 60  
     }
 61  
 
 62  
     /**
 63  
      * Return the string value at the position index.
 64  
      *
 65  
      * @param index The position of the value.
 66  
      * @return The value at this position else null if there is no value at this position.
 67  
      */
 68  
     public String getString(int index) {
 69  0
         String value = get(index);
 70  
 
 71  0
         if ("NULL".equalsIgnoreCase(value)) {
 72  0
             value = "";
 73  
         }
 74  
 
 75  0
         return value;
 76  
     }
 77  
 
 78  
     /**
 79  
      * Return the int value at the position index.
 80  
      *
 81  
      * @param index The position of the value.
 82  
      * @return The int value at this position else null if there is no value at this position.
 83  
      */
 84  
     public Integer getInt(int index) {
 85  0
         String value = getString(index);
 86  
 
 87  0
         if ("NULL".equalsIgnoreCase(value) || StringUtils.isEmpty(value)) {
 88  0
             return null;
 89  
         }
 90  
 
 91  0
         return Integer.parseInt(value);
 92  
     }
 93  
 
 94  
     /**
 95  
      * Return the boolean value at the position index.
 96  
      *
 97  
      * @param index The position of the value.
 98  
      * @return The boolean value at this position else null if there is no value at this position.
 99  
      */
 100  
     public Boolean getBoolean(int index) {
 101  0
         String value = getString(index);
 102  
 
 103  0
         if ("NULL".equalsIgnoreCase(value)) {
 104  0
             return null;
 105  
         }
 106  
 
 107  0
         return Boolean.parseBoolean(value);
 108  
     }
 109  
 
 110  
     /**
 111  
      * Set the values of the insert.
 112  
      *
 113  
      * @param values The values of the insert.
 114  
      */
 115  
     public void setValues(Collection<String> values) {
 116  0
         this.values = new ArrayList<String>(values);
 117  0
     }
 118  
 }