MCPcopy Create free account
hub / github.com/androrm/androrm / SelectStatement

Class SelectStatement

src/src/com/orm/androrm/statement/SelectStatement.java:38–261  ·  view source on GitHub ↗

By utilizing this class you can build complex select statements. If no fields are given, SELECT will be assumed. @author Philipp Giese

Source from the content-addressed store, hash-verified

36 * @author Philipp Giese
37 */
38public class SelectStatement implements Cloneable {
39
40 private static final String TAG = "ANDRORM:SELECT";
41
42 private String[] mFields = new String[] { "*" };
43 private String mFrom;
44 private Where mWhere;
45 private OrderBy mOrderBy;
46 private Limit mLimit;
47 private boolean mDistinct = false;
48 private boolean mCount = false;
49
50 private String buildDistinct() {
51 if(mDistinct) {
52 return " DISTINCT";
53 }
54
55 return "";
56 }
57
58 private String buildLimit() {
59 if(mLimit != null) {
60 return mLimit.toString();
61 }
62
63 return "";
64 }
65
66 private String buildOrderBy() {
67 if(mOrderBy != null) {
68 return mOrderBy.toString();
69 }
70
71 return "";
72 }
73
74 private String buildSelect() {
75 if(mCount) {
76 return " COUNT(*) AS " + Model.COUNT;
77 }
78
79 boolean first = true;
80
81 String fields = " ";
82
83 for(int i = 0, length = mFields.length; i < length; i++) {
84 if(first) {
85 fields += mFields[i];
86 first = false;
87 } else {
88 fields += ", " + mFields[i];
89 }
90 }
91
92 return fields;
93 }
94
95 private String buildWhere() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected