/**
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
 * If a copy of the MPL was not distributed with this file, You can obtain one at
 * http://mozilla.org/MPL/2.0/.
 * 
 * This Source Code Form is also subject to the terms of the Health-Related Additional
 * Disclaimer of Warranty and Limitation of Liability available at
 * http://www.carewebframework.org/licensing/disclaimer.
 */
package org.carewebframework.maven.plugin.help;

import java.io.File;
import java.io.FileFilter;

import org.apache.commons.io.filefilter.WildcardFileFilter;

import org.carewebframework.maven.plugin.iterator.DirectoryIterator;
import org.carewebframework.maven.plugin.iterator.IResourceIterator;

/**
 * Definition file for a source archive loader.
 */
public class SourceLoader {
    
    private String formatSpecifier;
    
    private String loaderClass;
    
    private String helpSetPattern;
    
    private FileFilter helpSetFilter;
    
    public SourceLoader() {
        
    }
    
    public SourceLoader(String formatSpecifier, String helpSetPattern, String loaderClass) {
        this.formatSpecifier = formatSpecifier;
        this.helpSetPattern = helpSetPattern;
        this.loaderClass = loaderClass;
    }
    
    public String getLoaderClass() {
        return loaderClass;
    }
    
    public void setLoaderClass(String loaderClass) {
        this.loaderClass = loaderClass;
    }
    
    public String getHelpSetPattern() {
        return helpSetPattern;
    }
    
    public void setHelpSetPattern(String helpSetPattern) {
        this.helpSetPattern = helpSetPattern;
    }
    
    public String getFormatSpecifier() {
        return formatSpecifier;
    }
    
    public void setFormatSpecifier(String formatSpecifier) {
        this.formatSpecifier = formatSpecifier;
    }
    
    public boolean isHelpSetFile(String fileName) {
        if (helpSetFilter == null) {
            helpSetFilter = new WildcardFileFilter(helpSetPattern);
        }
        
        return helpSetFilter.accept(new File(fileName));
    }
    
    /**
     * Returns an ISourceArchive implementation for the given archive name.
     * 
     * @param archiveName Name of the archive file.
     * @return An ISourceArchive instance.
     * @throws Exception Unspecified exception.
     */
    public IResourceIterator load(String archiveName) throws Exception {
        File file = new File(archiveName);
        
        if (file.isDirectory()) {
            return new DirectoryIterator(file);
        }
        
        @SuppressWarnings("unchecked")
        Class<? extends IResourceIterator> clazz = (Class<? extends IResourceIterator>) Class.forName(loaderClass);
        return clazz.getConstructor(String.class).newInstance(archiveName);
        
    }
    
}

@@ -861,29 +861,31 @@
 vate String 
-loade
+iterato
 rClass;%0A    
@@ -996,28 +996,24 @@
 der() %7B%0A    
-    
 %0A    %7D%0A    %0A
@@ -1086,29 +1086,31 @@
 ern, String 
-loade
+iterato
 rClass) %7B%0A  
@@ -1206,37 +1206,39 @@
 n;%0A        this.
-loade
+iterato
 rClass = loaderC
@@ -1222,37 +1222,39 @@
 iteratorClass = 
-loade
+iterato
 rClass;%0A    %7D%0A  
@@ -1277,21 +1277,23 @@
 ring get
-Loade
+Iterato
 rClass()
@@ -1310,21 +1310,23 @@
  return 
-loade
+iterato
 rClass;%0A
@@ -1355,21 +1355,23 @@
 void set
-Loade
+Iterato
 rClass(S
@@ -1376,21 +1376,23 @@
 (String 
-loade
+iterato
 rClass) 
@@ -1406,21 +1406,23 @@
    this.
-loade
+iterato
 rClass =
@@ -1422,21 +1422,23 @@
 Class = 
-loade
+iterato
 rClass;%0A
@@ -2704,21 +2704,23 @@
 forName(
-loade
+iterato
 rClass);

Rename property to better reflect purpose.