001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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 As of 6.2.0, moved to {@link
024     *             com.liferay.portal.kernel.dao.orm.QueryPos}
025     */
026    public class QueryPos {
027    
028            public static QueryPos getInstance(Query query) {
029                    return new QueryPos(query);
030            }
031    
032            public void add(boolean value) {
033                    _query.setBoolean(_pos++, value);
034            }
035    
036            public void add(Boolean value) {
037                    if (value != null) {
038                            _query.setBoolean(_pos++, value.booleanValue());
039                    }
040                    else {
041                            addNull();
042                    }
043            }
044    
045            public void add(double value) {
046                    _query.setDouble(_pos++, value);
047            }
048    
049            public void add(Double value) {
050                    if (value != null) {
051                            _query.setDouble(_pos++, value.doubleValue());
052                    }
053                    else {
054                            addNull();
055                    }
056            }
057    
058            public void add(float value) {
059                    _query.setFloat(_pos++, value);
060            }
061    
062            public void add(Float value) {
063                    if (value != null) {
064                            _query.setFloat(_pos++, value.intValue());
065                    }
066                    else {
067                            addNull();
068                    }
069            }
070    
071            public void add(int value) {
072                    _query.setInteger(_pos++, value);
073            }
074    
075            public void add(Integer value) {
076                    if (value != null) {
077                            _query.setInteger(_pos++, value.intValue());
078                    }
079                    else {
080                            addNull();
081                    }
082            }
083    
084            public void add(long value) {
085                    _query.setLong(_pos++, value);
086            }
087    
088            public void add(Long value) {
089                    if (value != null) {
090                            _query.setLong(_pos++, value.longValue());
091                    }
092                    else {
093                            addNull();
094                    }
095            }
096    
097            public void add(short value) {
098                    _query.setShort(_pos++, value);
099            }
100    
101            public void add(Short value) {
102                    if (value != null) {
103                            _query.setShort(_pos++, value.shortValue());
104                    }
105                    else {
106                            addNull();
107                    }
108            }
109    
110            public void add(String value) {
111                    _query.setString(_pos++, value);
112            }
113    
114            public void add(String[] values) {
115                    add(values, 1);
116            }
117    
118            public void add(String[] values, int count) {
119                    for (int i = 0; i < values.length; i++) {
120                            for (int j = 0; j < count; j++) {
121                                    add(values[i]);
122                            }
123                    }
124            }
125    
126            public void add(Timestamp value) {
127                    _query.setTimestamp(_pos++, value);
128            }
129    
130            public int getPos() {
131                    return _pos;
132            }
133    
134            protected void addNull() {
135                    _query.setSerializable(_pos++, null);
136            }
137    
138            private QueryPos(Query query) {
139                    _query = query;
140            }
141    
142            private int _pos;
143            private Query _query;
144    
145    }