Between.java

biz/hammurapi/sql/syntax/Between.java

Violations

Inspector Message Severity Location
Java Inspector 048 Copyrights information should be present in each file. 1
Java Inspector 086 Use equals() instead of == or != to compare objects. 1 109:32
Java Inspector 070-A Cyclomatic complexity is too high: 16, maximum allowed is 12 2 104:9
Java Inspector 082 Parenthesis are redundant. 2 98:36
Java Inspector 082 Parenthesis are redundant. 2 99:44
Java Inspector 082 Parenthesis are redundant. 2 100:44
Java Inspector 089 Type documentation is too short. It is only 1 words. Should be at least 3 words. 2 14:1
Java Inspector 089 Undocumented constructor 2 20:9
Java Inspector 089 Undocumented constructor 2 26:9
Java Inspector 089 Undocumented constructor 2 32:9
Java Inspector 089 Undocumented constructor 2 38:9
Java Inspector 089 Undocumented constructor 2 44:9
Java Inspector 089 Undocumented constructor 2 50:9
Java Inspector 089 Undocumented constructor 2 56:9
Java Inspector 089 Undocumented constructor 2 62:9
Java Inspector 089 Undocumented constructor 2 68:9
Java Inspector 089 Undocumented constructor 2 74:9
Java Inspector 089 Undocumented constructor 2 80:9
Java Inspector 089 Undocumented method 2 86:9
Java Inspector 089 Undocumented method 2 90:9
Java Inspector 089 Undocumented method 2 94:9
Java Inspector 089 Undocumented method 2 104:9
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 106:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 108:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 110:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 114:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 116:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 119:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 121:25
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 124:33
Java Inspector 003 do, while, if, and for statements need a brace enclosed block 3 126:25
Java Inspector 025 Avoid hardwired numeric literals. Allowed literals: [1, -1, 0] 3 95:35
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 87:37
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 20:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 26:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 32:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 38:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 44:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 50:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 56:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 62:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 68:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 74:9
Java Inspector 051 It is good practice to call in any case super() in a constructor. 3 80:9

Source code

1package biz.hammurapi.sql.syntax;
2
3import java.io.Serializable;
4import java.sql.PreparedStatement;
5import java.sql.SQLException;
6
7import biz.hammurapi.sql.Variant;
8
9/**
10 * Equalt
11 * @author Pavel
12 *
13 */
14public class Between implements StatementFragment, Serializable {
15
16 private Variant lower;
17 private Variant upper;
18 private String columnName;
19
20 public Between(String columnName, boolean lower, boolean upper) {
21 this.lower = new Variant(lower);
22 this.upper = new Variant(upper);
23 this.columnName = columnName;
24 }
25
26 public Between(String columnName, byte lower, byte upper) {
27 this.lower = new Variant(lower);
28 this.upper = new Variant(upper);
29 this.columnName = columnName;
30 }
31
32 public Between(String columnName, char lower, char upper) {
33 this.lower = new Variant(lower);
34 this.upper = new Variant(upper);
35 this.columnName = columnName;
36 }
37
38 public Between(String columnName, double lower, double upper) {
39 this.lower = new Variant(lower);
40 this.upper = new Variant(upper);
41 this.columnName = columnName;
42 }
43
44 public Between(String columnName, float lower, float upper) {
45 this.lower = new Variant(lower);
46 this.upper = new Variant(upper);
47 this.columnName = columnName;
48 }
49
50 public Between(String columnName, int lower, int upper) {
51 this.lower = new Variant(lower);
52 this.upper = new Variant(upper);
53 this.columnName = columnName;
54 }
55
56 public Between(String columnName, long lower, long upper) {
57 this.lower = new Variant(lower);
58 this.upper = new Variant(upper);
59 this.columnName = columnName;
60 }
61
62 public Between(String columnName, String lower, String upper) {
63 this.lower = new Variant(lower);
64 this.upper = new Variant(upper);
65 this.columnName = columnName;
66 }
67
68 public Between(String columnName, Object lower, Object upper) {
69 this.lower = new Variant(lower);
70 this.upper = new Variant(upper);
71 this.columnName = columnName;
72 }
73
74 public Between(String columnName, Object lower, Object upper, int sqlType) {
75 this.lower = new Variant(lower, sqlType);
76 this.upper = new Variant(upper, sqlType);
77 this.columnName = columnName;
78 }
79
80 public Between(String columnName, short lower, short upper) {
81 this.lower = new Variant(lower);
82 this.upper = new Variant(upper);
83 this.columnName = columnName;
84 }
85
86 public String toSqlString() {
87 return columnName + " BETWEEN ? AND ?";
88 }
89
90 public int parameterize(PreparedStatement ps, int idx) throws SQLException {
91 return upper.parameterize(ps, lower.parameterize(ps, idx));
92 }
93
94 public int hashCode() {
95 final int prime = 31;
96 int result = 1;
97 result = prime * result
98 + ((columnName == null) ? 0 : columnName.hashCode());
99 result = prime * result + ((lower == null) ? 0 : lower.hashCode());
100 result = prime * result + ((upper == null) ? 0 : upper.hashCode());
101 return result;
102 }
103
104 public boolean equals(Object obj) {
105 if (this == obj)
106 return true;
107 if (obj == null)
108 return false;
109 if (getClass() != obj.getClass())
110 return false;
111 final Between other = (Between) obj;
112 if (columnName == null) {
113 if (other.columnName != null)
114 return false;
115 } else if (!columnName.equals(other.columnName))
116 return false;
117 if (lower == null) {
118 if (other.lower != null)
119 return false;
120 } else if (!lower.equals(other.lower))
121 return false;
122 if (upper == null) {
123 if (other.upper != null)
124 return false;
125 } else if (!upper.equals(other.upper))
126 return false;
127 return true;
128 }
129
130}
131