stringpartcomparator.java
字号:
package piy.comparator;
import piy.*;
import java.io.Serializable;
/**
* Compares parts of strings
* @author David Vivash
* @version 1.0, 30/04/01
*/
public class StringPartComparator extends PIYComparator implements Serializable {
private static String[] modes = new String[] {
"Starts With", "Ends With"
};
public StringPartComparator() {
super.init(this);
}
public Class getFirstType() { return String.class; }
public Class getSecondType() { return String.class; }
public String[] getModes() {
return modes;
}
public boolean evaluate() {
FixedProperty first = getFirst();
FixedProperty second = getSecond();
if ( (first == null) || (second == null) ) return false;
String firstVal = (String)first.getActualValue();
String secondVal = (String)second.getActualValue();
if ( (firstVal == null) || (secondVal == null) ) return false;
if (getMode().equalsIgnoreCase("Starts With")) {
return firstVal.startsWith(secondVal) ^ getNegate();
} else {
return firstVal.endsWith(secondVal) ^ getNegate();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -