001/*
002 * (C) Copyright 2006-2012 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Arnaud Kervern <akervern@nuxeo.com>
016 */
017
018package org.nuxeo.ecm.directory.sql.filter;
019
020import org.nuxeo.ecm.core.storage.sql.jdbc.db.Column;
021
022import java.io.Serializable;
023import java.sql.PreparedStatement;
024import java.sql.SQLException;
025
026/**
027 * Simple SQLComplexFilter to handle a different operator than = It may be >, <, >=, <= Nothing is done on the right
028 * side part.
029 *
030 * @since 5.7
031 */
032public class SQLOperatorFilter extends SQLComplexFilter {
033
034    private Serializable value;
035
036    public SQLOperatorFilter(String operator, Serializable value) {
037        super(operator);
038        this.value = value;
039    }
040
041    @Override
042    public int doSetFieldValue(PreparedStatement ps, int index, Column column) throws SQLException {
043        column.setToPreparedStatement(ps, index, value);
044        return index + 1;
045    }
046}