使用 File2 屬性
在使用規則運算式 (regex) 建立字串模式時,您可以使用 FILE2 屬性。其有助於識別檔案並支援檔案路徑。
範例:FILE2 屬性類型
定義 FILE2 的使用值,例如索引、類型、本機檔案、標籤和選擇性描述。
@BotCommand
@CommandPkg(label = "[[File2TypeDemo.label]]",
description = "[[File2TypeDemo.description]]", icon = "sample.svg", name = "file2TypeDemo")
public class File2TypeDemo {
private static Logger logger = LogManager.getLogger(File2TypeDemo.class);
@Execute
public void regexFile(
@Idx(index = "1", type = AttributeType.FILE2)
@Pkg(label = "[[File2TypeDemo.localFile.label]]")
@NotEmpty
@LocalFile
FileValue fileValue)
{
if (fileValue.isRegex()) {
RegexFile regexFile = fileValue.getRegex();
logger.debug("folder name {}", regexFile.getFolder());
logger.debug("local file location {}", regexFile.getFileNamePattern().toString());
}
else {
logger.debug("Regex option is not selected");
}
}