⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtltexpression.java

📁 JoSQL 1.5的源代码。JoSQL(SQL for Java Objects)为Java开发者提供运用SQL语句来操作Java对象集的能力.利用JoSQL可以像操作数据库中的数据一样对任何Java
💻 JAVA
字号:
/* * Copyright 2004-2005 Gary Bentley  *  * Licensed under the Apache License, Version 2.0 (the "License"); you may  * not use this file except in compliance with the License.  * You may obtain a copy of the License at  *    http://www.apache.org/licenses/LICENSE-2.0  * * Unless required by applicable law or agreed to in writing, software  * distributed under the License is distributed on an "AS IS" BASIS,  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  * See the License for the specific language governing permissions and  * limitations under the License. */package org.josql.expressions;import java.util.Collection;import java.util.Iterator;import java.util.List;import org.josql.Query;import org.josql.QueryExecutionException;import org.josql.internal.Utilities;/** * This class represents one of the following: * <ul> *   <li><b>></b> - Greater than</li> *   <li><b><</b> - Less than</li> *   <li><b>>=</b> - Greater than or equal to</li> *   <li><b><=</b> - Less than or equal to</li> * </ul> * <p> * You can also force a "string" comparison by prefixing with "$".  This will force * both sides to be strings via the <code>toString</code> method. * <p> *  Last Modified By: $Author: barrygently $<br /> *  Last Modified On: $Date: 2005/01/07 17:08:07 $<br /> *  Current Revision: $Revision: 1.4 $<br /> */public class GTLTExpression extends BinaryExpression{    private int type = -1;    private boolean ignoreCase = false;    public int getType ()    {	return this.type;    }    /**     * Type is an integer here for speed purposes, however one of the constants     * should be used.     *     * @param t The type of expression.     */    public void setType (int t)    {	this.type = t;    }    public void setIgnoreCase (boolean v)    {	this.ignoreCase = v;    }    public boolean isIgnoreCase ()    {	return this.ignoreCase;    }    /**     * Return whether this expression evaluates to true.  The actual comparison     * is performed by: {@link Utilities#compare(Object,Object)} which copes with     * the object types.     *     * @param o The current object to evaluate the expression on.     * @param q The Query object.     * @return <code>true</code> if the expression evaluates to <code>true</code>.     * @throws QueryExecutionException If the expression cannot be evaluated.     */    public boolean isTrue (Object o,			   Query  q)	                   throws QueryExecutionException    {	// Get the lhs.	Object l = this.left.getValue (o,				       q);	Object r = this.right.getValue (o,					q);	if ((l == null)	    &&	    (r == null)	   )	{	    if ((this.type == 1)		||		(this.type == 3)	       )	    {		return true;	    }	}	if ((l == null)	    ||	    (r == null)	   )	{	    return false;	    	}	return Utilities.matches (l,				  r,				  this.ignoreCase,				  this.type,				  false);    }    /**     * Return a string version of the expression.     * In the form: {@link Expression#toString() Expression} [ $ ] <|> [ = ] {@link Expression#toString() Expression}     *     * @return A string version of the expression.     */    public String toString ()    {	String pred = "<";	if (this.type == Utilities.GT)	{	    pred = ">";	}	if (this.type == Utilities.GTE)	{	    pred = ">=";	}	if (this.type == Utilities.LTE)	{	    pred = "<=";	}	if (this.ignoreCase)	{	    pred = "$" + pred;	}		if (this.isBracketed ())	{	    return "(" + this.left.toString () + " " + pred + " " + this.right.toString () + ")";	}	return this.left.toString () + " " + pred + " " + this.right.toString ();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -