Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 79   Methods: 3
NCLOC: 51   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BaseXMLHandler.java 58,3% 84,6% 100% 78%
coverage coverage
 1    /*
 2    * BaseXMLHandler.java
 3    *
 4    * Created on 3. Februar 2003, 22:41
 5    */
 6   
 7    package org.jconfig.handler;
 8   
 9    import java.io.File;
 10    import java.io.FileWriter;
 11   
 12    import org.jconfig.Configuration;
 13    import org.jconfig.ConfigurationManagerException;
 14    import org.jconfig.error.ErrorReporter;
 15    /**
 16    * This class is used internally to save a configuration to a file.
 17    *
 18    * @author Andreas Mecky andreas.mecky@xcom.de
 19    * @author Terry Dye terry.dye@xcom.de
 20    */
 21    public abstract class BaseXMLHandler extends AbstractHandler {
 22   
 23    private String encoding;
 24   
 25   
 26  2 public void setEncoding(String encoding) {
 27  2 this.encoding = encoding;
 28    }
 29    /**
 30    * This method will save the current categories and their properties to a
 31    * file
 32    *
 33    *@param file the file that will be generated
 34    *@exception ConfigurationManagerException Description of the Exception
 35    */
 36  5 protected void store(File file,Configuration config) throws ConfigurationManagerException {
 37    // this will store the properties for all categories
 38  5 try {
 39    // let's open the file
 40  5 FileWriter fw = new FileWriter(file);
 41  5 fw.write(config.getXMLAsString());
 42    // close the file because we are done
 43  5 fw.close();
 44    } catch (Exception e) {
 45  0 ErrorReporter.getErrorHandler().reportError("The file cannot be saved",e);
 46  0 throw new ConfigurationManagerException("The file cannot be saved:"+e.getMessage());
 47    }
 48    }
 49   
 50  2 public String getEncodingType(String str) {
 51  2 if (str != null) {
 52  2 final String ENCODING = "encoding";
 53  2 int start = str.indexOf(ENCODING);
 54  2 String rest = str.substring(start + ENCODING.length());
 55  2 if ( rest.indexOf("'") != -1 ) {
 56  1 int beginQuote = rest.indexOf("'");
 57  1 if(beginQuote > -1) {
 58  1 rest = rest.substring(beginQuote + 1);
 59    }
 60  1 int endQuote = rest.indexOf("'");
 61  1 if(beginQuote > -1) {
 62  1 return rest.substring(0, endQuote);
 63    }
 64    }
 65    else {
 66  1 int beginQuote = rest.indexOf("\"");
 67  1 if(beginQuote > -1) {
 68  1 rest = rest.substring(beginQuote + 1);
 69    }
 70  1 int endQuote = rest.indexOf("\"");
 71  1 if(beginQuote > -1) {
 72  1 return rest.substring(0, endQuote);
 73    }
 74    }
 75  0 return str.substring(start + ENCODING.length());
 76    }
 77  0 return null;
 78    }
 79    }