これは、ドキュメントから使用する必要がある方法です。
http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#scatter
幸運を。
インライン要素エントリの分散
XML ドキュメント全体に散在する要素は、インライン リストとインライン マップによって収集できます。リストまたはマップが収集する XML 要素名のエントリ名を指定するだけで、それらが抽出されてコレクション オブジェクトに配置されます。たとえば、次の XML 要素を取り上げます。特定の順序ではない include 要素と exclude XML 要素が含まれています。それらは任意の順序ではありませんが、デシリアライゼーション プロセスは、検出された XML 要素を収集することができます。
<fileSet path="/user/niall">
<include pattern=".*.jar"/>
<exclude pattern=".*.bak"/>
<exclude pattern="~.*"/>
<include pattern=".*.class"/>
<exclude pattern="images/.*"/>
</fileSet>
これを達成するために、次のオブジェクトを使用できます。これは、収集するエントリ オブジェクトの名前を指定する 2 つのインライン コレクションを宣言します。entry 属性が指定されていない場合は、代わりにオブジェクトの名前が使用されます。
@Root
public class FileSet {
@ElementList(entry="include", inline=true)
private List<Match> include;
@ElementList(entry="exclude", inline=true)
private List<Match> exclude;
@Attribute
private File path;
private List<File> files;
public FileSet() {
this.files = new ArrayList<File>();
}
@Commit
public void commit() {
scan(path);
}
private void scan(File path) {
File[] list = path.listFiles();
for(File file : list) {
if(file.isDirectory()) {
scan(path);
} else {
if(matches(file)) {
files.add(file);
}
}
}
}
private boolean matches(File file) {
for(Match match : exclude) {
if(match.matches(file)) {
return false;
}
}
for(Match match : include) {
if(match.matches(file)) {
return true;
}
}
return false;
}
public List<File> getFiles() {
return files;
}
@Root
private static class Match {
@Attribute
private String pattern;
public boolean matches(File file) {
Stirng path = file.getPath();
if(!file.isFile()) {
return false;
}
return path.matches(pattern);
}
}
}