View Javadoc

1   /*
2    * SameFileValidator.java
3    *
4    * Created on 10 January 2007, 22:53
5    *
6    * To change this template, choose Tools | Template Manager
7    * and open the template in the editor.
8    */
9   
10  package org.wiztools.jenkryptor.validation;
11  
12  import java.io.File;
13  import java.io.IOException;
14  import java.util.ArrayList;
15  import java.util.List;
16  
17  /***
18   *
19   * @author subhash
20   */
21  public class SameFileValidator extends Validator {
22      
23      /*** Creates a new instance of SameFileValidator */
24      public SameFileValidator() {
25      }
26  
27      @Override
28      public void validate(File[] files) throws ValidatorException {
29          List<String> ll = new ArrayList<String>();
30          try{
31              for(File f: files){
32                  String absPath = f.getCanonicalPath();
33                  if(ll.contains(absPath)){
34                      throw new ValidatorException("Duplicate files: "
35                              +absPath);
36                  }
37                  ll.add(absPath);
38              }
39          }
40          catch(IOException ioe){
41              throw new ValidatorException(ioe.getMessage());
42          }
43          
44          if(next != null){
45              next.validate(files);
46          }
47      }
48      
49  }