1 package jp.sourceforge.stigmata.result.history;
4 import java.util.Iterator;
5 import java.util.LinkedHashMap;
8 import jp.sourceforge.stigmata.BirthmarkEnvironment;
9 import jp.sourceforge.stigmata.ExtractionResultSet;
10 import jp.sourceforge.stigmata.result.XmlFileExtractionResultSet;
11 import jp.sourceforge.stigmata.utils.Utility;
15 * @author Haruaki Tamada
17 public class XmlFileExtractedBirthmarkHistory implements ExtractedBirthmarkHistory{
19 private Map<String, File> files = new LinkedHashMap<String, File>();
21 public XmlFileExtractedBirthmarkHistory(){
22 this(new File(BirthmarkEnvironment.getStigmataHome(), "extracted_birthmarks"));
25 public XmlFileExtractedBirthmarkHistory(String path){
29 public XmlFileExtractedBirthmarkHistory(File parent){
36 public void refresh(){
40 for(File file: parent.listFiles()){
42 files.put(file.getName(), file);
49 public void deleteAllResultSets(){
50 for(File file: parent.listFiles()){
52 Utility.deleteDirectory(file);
58 public void deleteResultSet(String id){
59 File file = files.get(id);
61 if(file.isDirectory()){
62 Utility.deleteDirectory(file);
71 public ExtractionResultSet getResultSet(String id){
72 File file = files.get(id);
74 return new XmlFileExtractionResultSet(file);
80 public synchronized String[] getResultSetIds(){
81 return files.keySet().toArray(new String[files.size()]);
85 public Iterator<String> iterator(){
86 return files.keySet().iterator();
89 private boolean isTarget(File file){
90 return file.isDirectory()
91 && file.getName().matches("\\d\\d\\d\\d\\d\\d\\d\\d-\\d\\d\\d\\d\\d\\d.\\d\\d\\d");