You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
5 years ago
|
package com.fr.solution.plugin.design.formula.compat;
|
||
|
|
||
|
import com.fr.design.formula.AbstractNameAndDescription;
|
||
|
import com.fr.general.GeneralContext;
|
||
|
import com.fr.script.CalculatorEmbeddedFunction;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
import com.fr.stable.script.Function;
|
||
|
|
||
|
import java.util.Locale;
|
||
|
|
||
|
/**
|
||
|
* @author richie
|
||
|
* @version 10.0
|
||
|
* Created by richie on 2019-09-03
|
||
|
*/
|
||
|
public class FunctionNAD extends AbstractNameAndDescription {
|
||
|
|
||
|
private Function fn;
|
||
|
|
||
|
FunctionNAD(Function fn) {
|
||
|
this.fn = fn;
|
||
|
}
|
||
|
|
||
|
public String getName() {
|
||
|
return fn == null ? StringUtils.EMPTY : fn.getClass().getSimpleName();
|
||
|
}
|
||
|
|
||
|
public String getDesc() {
|
||
|
if (fn == null) {
|
||
|
return StringUtils.EMPTY;
|
||
|
}
|
||
|
Locale locale = GeneralContext.getLocale();
|
||
|
String describtion = fn.getDescription(locale);
|
||
|
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) {
|
||
|
return Locale.CHINA.equals(locale) ? fn.getCN() : fn.getEN();
|
||
|
}
|
||
|
|
||
|
return describtion;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String searchResult(String keyWord, boolean findDescription) {
|
||
|
String functionName = getName();
|
||
|
String des = getDesc();
|
||
|
if (findDescription && des.contains(keyWord)) {
|
||
|
return functionName;
|
||
|
} else {
|
||
|
return super.searchResult(keyWord, findDescription);
|
||
|
}
|
||
|
}
|
||
|
}
|