001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.util.dao.orm.hibernate;
016    
017    import java.sql.Timestamp;
018    
019    import org.hibernate.Query;
020    
021    /**
022     * @author     Brian Wing Shun Chan
023     * @deprecated Moved to {@link com.liferay.portal.kernel.dao.orm.QueryPos}
024     */
025    public class QueryPos {
026    
027            public static QueryPos getInstance(Query query) {
028                    return new QueryPos(query);
029            }
030    
031            public int getPos() {
032                    return _pos;
033            }
034    
035            public void add(boolean value) {
036                    _query.setBoolean(_pos++, value);
037            }
038    
039            public void add(Boolean value) {
040                    if (value != null) {
041                            _query.setBoolean(_pos++, value.booleanValue());
042                    }
043                    else {
044                            addNull();
045                    }
046            }
047    
048            public void add(double value) {
049                    _query.setDouble(_pos++, value);
050            }
051    
052            public void add(Double value) {
053                    if (value != null) {
054                            _query.setDouble(_pos++, value.doubleValue());
055                    }
056                    else {
057                            addNull();
058                    }
059            }
060    
061            public void add(float value) {
062                    _query.setFloat(_pos++, value);
063            }
064    
065            public void add(Float value) {
066                    if (value != null) {
067                            _query.setFloat(_pos++, value.intValue());
068                    }
069                    else {
070                            addNull();
071                    }
072            }
073    
074            public void add(int value) {
075                    _query.setInteger(_pos++, value);
076            }
077    
078            public void add(Integer value) {
079                    if (value != null) {
080                            _query.setInteger(_pos++, value.intValue());
081                    }
082                    else {
083                            addNull();
084                    }
085            }
086    
087            public void add(long value) {
088                    _query.setLong(_pos++, value);
089            }
090    
091            public void add(Long value) {
092                    if (value != null) {
093                            _query.setLong(_pos++, value.longValue());
094                    }
095                    else {
096                            addNull();
097                    }
098            }
099    
100            public void add(short value) {
101                    _query.setShort(_pos++, value);
102            }
103    
104            public void add(Short value) {
105                    if (value != null) {
106                            _query.setShort(_pos++, value.shortValue());
107                    }
108                    else {
109                            addNull();
110                    }
111            }
112    
113            public void add(String value) {
114                    _query.setString(_pos++, value);
115            }
116    
117            public void add(String[] values) {
118                    add(values, 1);
119            }
120    
121            public void add(String[] values, int count) {
122                    for (int i = 0; i < values.length; i++) {
123                            for (int j = 0; j < count; j++) {
124                                    add(values[i]);
125                            }
126                    }
127            }
128    
129            public void add(Timestamp value) {
130                    _query.setTimestamp(_pos++, value);
131            }
132    
133            private QueryPos(Query query) {
134                    _query = query;
135            }
136    
137            private void addNull() {
138                    _query.setSerializable(_pos++, null);
139            }
140    
141            private Query _query;
142            private int _pos;
143    
144    }