📄 simpleexpression.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.util;
/**
* @author sfowler
*
* Provides simple string comparison functionality.
*
*/
public class SimpleExpression {
public static final String EQUAL = "EQUAL";
public static final String NOT_EQUAL = "NOT_EQUAL";
public static final String STARTS_WITH = "STARTS_WITH";
public static final String NOT_STARTS_WITH = "NOT_STARTS_WITH";
public static final String CONTAINS = "CONTAINS";
public static final String NOT_CONTAINS = "NOT_CONTAINS";
public static final String LESS_THAN = "LESS_THAN";
public static final String LESS_OR_EQUAL = "LESS_OR_EQUAL";
public static final String GREATER_THAN = "GREATER_THAN";
public static final String GREATER_OR_EQUAL = "GREAT";
/**
* DOCUMENT ME!
*
* @param lhs_
* @param operator
* @param rhs_
*
* @return
*/
public static boolean compare(String lhs_, String operator, String rhs_) {
String lhs = (lhs_ == null) ? "" : lhs_;
String rhs = (rhs_ == null) ? "" : rhs_;
if (operator.equals(SimpleExpression.STARTS_WITH)) {
if (lhs.startsWith(rhs)) {
return true;
} else {
return false;
}
} else if (operator.equals(SimpleExpression.NOT_STARTS_WITH)) {
if (lhs.startsWith(rhs)) {
return false;
} else {
return true;
}
} else if (operator.equals(SimpleExpression.EQUAL)) {
if (lhs.equals(rhs)) {
return true;
} else {
return false;
}
} else if (operator.equals(SimpleExpression.NOT_EQUAL)) {
if (lhs.equals(rhs)) {
return false;
} else {
return true;
}
} else if (operator.equals(SimpleExpression.CONTAINS)) {
if (lhs.indexOf(rhs) >= 0) {
return true;
} else {
return false;
}
} else if (operator.equals(SimpleExpression.NOT_CONTAINS)) {
if (lhs.indexOf(rhs) >= 0) {
return false;
} else {
return true;
}
} else if (operator.equals(SimpleExpression.LESS_THAN)) {
if (lhs.compareTo(rhs) < 0) {
return true;
} else {
return false;
}
} else if (operator.equals(SimpleExpression.LESS_OR_EQUAL)) {
if (lhs.compareTo(rhs) <= 0) {
return true;
} else {
return false;
}
} else if (operator.equals(SimpleExpression.GREATER_THAN)) {
if (lhs.compareTo(rhs) > 0) {
return true;
} else {
return false;
}
} else if (operator.equals(SimpleExpression.GREATER_OR_EQUAL)) {
if (lhs.compareTo(rhs) >= 0) {
return true;
} else {
return false;
}
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -