001
014
015 package com.liferay.util.dao.orm.hibernate;
016
017 import java.sql.Timestamp;
018
019 import org.hibernate.Query;
020
021
026 @Deprecated
027 public class QueryPos {
028
029 public static QueryPos getInstance(Query query) {
030 return new QueryPos(query);
031 }
032
033 public void add(boolean value) {
034 _query.setBoolean(_pos++, value);
035 }
036
037 public void add(Boolean value) {
038 if (value != null) {
039 _query.setBoolean(_pos++, value.booleanValue());
040 }
041 else {
042 addNull();
043 }
044 }
045
046 public void add(double value) {
047 _query.setDouble(_pos++, value);
048 }
049
050 public void add(Double value) {
051 if (value != null) {
052 _query.setDouble(_pos++, value.doubleValue());
053 }
054 else {
055 addNull();
056 }
057 }
058
059 public void add(float value) {
060 _query.setFloat(_pos++, value);
061 }
062
063 public void add(Float value) {
064 if (value != null) {
065 _query.setFloat(_pos++, value.intValue());
066 }
067 else {
068 addNull();
069 }
070 }
071
072 public void add(int value) {
073 _query.setInteger(_pos++, value);
074 }
075
076 public void add(Integer value) {
077 if (value != null) {
078 _query.setInteger(_pos++, value.intValue());
079 }
080 else {
081 addNull();
082 }
083 }
084
085 public void add(long value) {
086 _query.setLong(_pos++, value);
087 }
088
089 public void add(Long value) {
090 if (value != null) {
091 _query.setLong(_pos++, value.longValue());
092 }
093 else {
094 addNull();
095 }
096 }
097
098 public void add(short value) {
099 _query.setShort(_pos++, value);
100 }
101
102 public void add(Short value) {
103 if (value != null) {
104 _query.setShort(_pos++, value.shortValue());
105 }
106 else {
107 addNull();
108 }
109 }
110
111 public void add(String value) {
112 _query.setString(_pos++, value);
113 }
114
115 public void add(String[] values) {
116 add(values, 1);
117 }
118
119 public void add(String[] values, int count) {
120 for (int i = 0; i < values.length; i++) {
121 for (int j = 0; j < count; j++) {
122 add(values[i]);
123 }
124 }
125 }
126
127 public void add(Timestamp value) {
128 _query.setTimestamp(_pos++, value);
129 }
130
131 public int getPos() {
132 return _pos;
133 }
134
135 protected void addNull() {
136 _query.setSerializable(_pos++, null);
137 }
138
139 private QueryPos(Query query) {
140 _query = query;
141 }
142
143 private int _pos;
144 private final Query _query;
145
146 }