/src/mpv5/db/common/QueryParameter.java
Java | 127 lines | 48 code | 13 blank | 66 comment | 0 complexity | fe2c2fb8558a074dc162c4374a69cdf7 MD5 | raw file
1/* 2 * This file is part of YaBS. 3 * 4 * YaBS is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * YaBS is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with YaBS. If not, see <http://www.gnu.org/licenses/>. 16 */ 17package mpv5.db.common; 18 19/** 20 * 21 * @author andreas 22 */ 23public class QueryParameter { 24 25 /** 26 * a = a 27 */ 28 public static final int EQUALS = 0; 29 /** 30 * a <> a 31 */ 32 public static final int NOTEQUAL = 1; 33 /** 34 * UPPER(a) LIKE %A% 35 */ 36 public static final int LIKE = 2; 37 /** 38 * UPPER(a) NOT LIKE %A% 39 */ 40 public static final int NOTLIKE = 3; 41 private Context context; 42 private String key; 43 private Object value; 44 private int condition; 45 46 /** 47 * 48 * @param context 49 * @param key 50 * @param value 51 * @param condition 52 */ 53 public QueryParameter(Context context, String key, Object value, int condition) { 54 this.context = context; 55 this.key = key; 56 this.value = value; 57 this.condition = condition; 58 } 59 60 /** 61 * @return the key 62 */ 63 public String getKey() { 64 return getContext().getDbIdentity() + "." + key; 65 } 66 67 /** 68 * @param key the key to set 69 */ 70 public void setKey(String key) { 71 this.key = key; 72 } 73 74 /** 75 * @return the value 76 */ 77 public Object getValue() { 78 return value; 79 } 80 81 /** 82 * @param value the value to set 83 */ 84 public void setValue(String value) { 85 this.setValue(value); 86 } 87 88 /** 89 * @return the condition 90 */ 91 public int getCondition() { 92 return condition; 93 } 94 95 /** 96 * @param condition the condition to set 97 */ 98 public void setCondition(int condition) { 99 this.condition = condition; 100 } 101 102 @Override 103 public String toString() { 104 return getKey() + ": " + getValue(); 105 } 106 107 /** 108 * @return the context 109 */ 110 public Context getContext() { 111 return context; 112 } 113 114 /** 115 * @param context the context to set 116 */ 117 public void setContext(Context context) { 118 this.context = context; 119 } 120 121 /** 122 * @param value the value to set 123 */ 124 public void setValue(Object value) { 125 this.value = value; 126 } 127}