SimpleCondition.java :  » Database-ORM » XORM » org » xorm » query » Java Open Source

Java Open Source » Database ORM » XORM 
XORM » org » xorm » query » SimpleCondition.java
/*
    $Header: /cvsroot/xorm/xorm/src/org/xorm/query/SimpleCondition.java,v 1.8 2003/04/10 03:13:33 wbiggs Exp $

    This file is part of XORM.

    XORM is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    XORM is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with XORM; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package org.xorm.query;

import org.xorm.datastore.Column;

public class SimpleCondition extends Condition {
    private Column column;
    private Operator operator;
    private Object value;

    public SimpleCondition(Column column, Operator operator, Object value) {
  this.column = column;
  this.operator = operator;
  this.value = value;
    }
    public Column getColumn() { return column; }
    public Operator getOperator() { return operator; }
    public Object getValue() { return value; }

    public Object clone() {
  SimpleCondition clone = (SimpleCondition) super.clone();
  if (value instanceof Selector) {
      clone.value = ((Selector) value).clone();
  }
  return clone;
    }

    public String toString() {
  StringBuffer local = new StringBuffer();
  if (isInverted()) {
      local.append("!(");
  }
  local.append((column == null ? "null" : column.getName()))
      .append(' ')
      .append(operator)
      .append(' ');
  if (value instanceof Character) {
      local.append('\'')
    .append(value)
    .append('\'');
  } else if (value instanceof String) {
      local.append('"')
    .append(value)
    .append('"');
  } else {
      local.append(value);
  }
  if (isInverted()) {
      local.append(")");
  }
  return local.toString();
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.