Coverage Report - org.webslinger.commons.vfs.FileConvertor
 
Classes in this File Line Coverage Branch Coverage Complexity
FileConvertor
77%
10/13
N/A
0
 
 1  
 package org.webslinger.commons.vfs;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.util.HashMap;
 5  
 import java.util.Iterator;
 6  
 import javax.imageio.spi.ServiceRegistry;
 7  
 
 8  4
 public abstract class FileConvertor {
 9  1
     private static final HashMap<String, FileConvertor> convertors = new HashMap<String, FileConvertor>();
 10  
     static {
 11  1
         ClassLoader loader = FileConvertor.class.getClassLoader();
 12  1
         Iterator<FileConvertor> it = ServiceRegistry.lookupProviders(FileConvertor.class, loader);
 13  5
         while (it.hasNext()) {
 14  
             try {
 15  4
                 FileConvertor convertor = it.next();
 16  4
                 convertors.put(convertor.getName(), convertor);
 17  0
             } catch (RuntimeException e) {
 18  0
             } catch (UnsupportedClassVersionError e) {
 19  4
             }
 20  
         }
 21  1
     }
 22  
 
 23  
     public static FileConvertor getConvertor(String name) {
 24  3
         return convertors.get(name);
 25  
     }
 26  
 
 27  
     public String convert(Object context, String fileName, String data, FileResolver resolver) throws IOException {
 28  0
         return convert(fileName, data, resolver);
 29  
     }
 30  
 
 31  
     public abstract String convert(String fileName, String data, FileResolver resolver) throws IOException;
 32  
     public abstract String getName();
 33  
 }