File2 属性の使用
正規表現 (regex) を使用して文字列のパターンを作成する際に、FILE2 属性を使用できます。ファイルの識別に便利で、FILE パスをサポートしています。
例: FILE2 属性タイプ
インデックス、タイプ、LocalFile、ラベルおよびオプションの説明など、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");
}
}