PageRenderTime 46ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/mpv5/db/common/QueryParameter.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 127 lines | 48 code | 13 blank | 66 comment | 0 complexity | fe2c2fb8558a074dc162c4374a69cdf7 MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  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. */
  17. package mpv5.db.common;
  18. /**
  19. *
  20. * @author andreas
  21. */
  22. public class QueryParameter {
  23. /**
  24. * a = a
  25. */
  26. public static final int EQUALS = 0;
  27. /**
  28. * a <> a
  29. */
  30. public static final int NOTEQUAL = 1;
  31. /**
  32. * UPPER(a) LIKE %A%
  33. */
  34. public static final int LIKE = 2;
  35. /**
  36. * UPPER(a) NOT LIKE %A%
  37. */
  38. public static final int NOTLIKE = 3;
  39. private Context context;
  40. private String key;
  41. private Object value;
  42. private int condition;
  43. /**
  44. *
  45. * @param context
  46. * @param key
  47. * @param value
  48. * @param condition
  49. */
  50. public QueryParameter(Context context, String key, Object value, int condition) {
  51. this.context = context;
  52. this.key = key;
  53. this.value = value;
  54. this.condition = condition;
  55. }
  56. /**
  57. * @return the key
  58. */
  59. public String getKey() {
  60. return getContext().getDbIdentity() + "." + key;
  61. }
  62. /**
  63. * @param key the key to set
  64. */
  65. public void setKey(String key) {
  66. this.key = key;
  67. }
  68. /**
  69. * @return the value
  70. */
  71. public Object getValue() {
  72. return value;
  73. }
  74. /**
  75. * @param value the value to set
  76. */
  77. public void setValue(String value) {
  78. this.setValue(value);
  79. }
  80. /**
  81. * @return the condition
  82. */
  83. public int getCondition() {
  84. return condition;
  85. }
  86. /**
  87. * @param condition the condition to set
  88. */
  89. public void setCondition(int condition) {
  90. this.condition = condition;
  91. }
  92. @Override
  93. public String toString() {
  94. return getKey() + ": " + getValue();
  95. }
  96. /**
  97. * @return the context
  98. */
  99. public Context getContext() {
  100. return context;
  101. }
  102. /**
  103. * @param context the context to set
  104. */
  105. public void setContext(Context context) {
  106. this.context = context;
  107. }
  108. /**
  109. * @param value the value to set
  110. */
  111. public void setValue(Object value) {
  112. this.value = value;
  113. }
  114. }