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