1 package jp.sourceforge.stigmata.result.history;
8 import java.util.Iterator;
9 import java.util.LinkedHashMap;
12 import jp.sourceforge.stigmata.BirthmarkEnvironment;
13 import jp.sourceforge.stigmata.ExtractionResultSet;
14 import jp.sourceforge.stigmata.result.XmlFileExtractionResultSet;
15 import jp.sourceforge.stigmata.utils.Utility;
19 * @author Haruaki Tamada
22 public class XmlFileExtractedBirthmarkHistory implements ExtractedBirthmarkHistory{
24 private Map<String, File> files = new LinkedHashMap<String, File>();
26 public XmlFileExtractedBirthmarkHistory(){
27 this(new File(BirthmarkEnvironment.getStigmataHome(), "extracted_birthmarks"));
30 public XmlFileExtractedBirthmarkHistory(String path){
34 public XmlFileExtractedBirthmarkHistory(File parent){
41 public void refresh(){
45 for(File file: parent.listFiles()){
47 files.put(file.getName(), file);
54 public void deleteAllResultSets(){
55 for(File file: parent.listFiles()){
57 Utility.deleteDirectory(file);
63 public void deleteResultSet(String id){
64 File file = files.get(id);
66 if(file.isDirectory()){
67 Utility.deleteDirectory(file);
76 public ExtractionResultSet getResultSet(String id){
77 File file = files.get(id);
79 return new XmlFileExtractionResultSet(file);
85 public synchronized String[] getResultSetIds(){
86 return files.keySet().toArray(new String[files.size()]);
90 public Iterator<String> iterator(){
91 return files.keySet().iterator();
94 private boolean isTarget(File file){
95 return file.isDirectory()
96 && file.getName().matches("\\d\\d\\d\\d\\d\\d\\d\\d-\\d\\d\\d\\d\\d\\d.\\d\\d\\d");