Changeset 47

Show
Ignore:
Timestamp:
02/16/06 17:37:35 (3 years ago)
Author:
schst
Message:

moved the passing of the class loader from the constructor to the parse() method

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/net/schst/XJConf/Examples/Example1.java

    r34 r47  
    1717/** 
    1818 * @author sschmidt 
    19  * 
    20  * TODO To change the template for this generated type comment go to 
    21  * Window - Preferences - Java - Code Style - Code Templates 
    2219 */ 
    2320public class Example1 { 
  • trunk/src/net/schst/XJConf/XmlReader.java

    r41 r47  
    8787    } 
    8888 
    89     /** 
    90      * Constructor 
    91      *  
    92      * You may pass a classloader to the constructor which will be 
    93      * used to: 
    94      * - load extension classes 
    95      * - load dynamically created clases 
    96      *  
    97      * @param loader 
    98      */ 
    99     public XmlReader(ClassLoader loader) { 
    100         super(); 
    101         this.loader = loader; 
    102     } 
    103      
    10489   /** 
    10590    * Set the tag definitions 
     
    152137     */ 
    153138    public void addExtension(String name) throws UnknownExtensionException { 
     139        this.addExtension(name, this.getClass().getClassLoader()); 
     140    } 
     141 
     142    /** 
     143     * Add a new extension 
     144     *  
     145     * @param name          full-qualified class name 
     146     * @param classLoader   class loader that should be used 
     147     * @throws UnknownExtensionException 
     148     */ 
     149    public void addExtension(String name, ClassLoader classLoader) throws UnknownExtensionException { 
    154150        Extension ext; 
    155151        try { 
    156             Class c = Class.forName(name,true,this.loader); 
     152            Class c = Class.forName(name, true, classLoader); 
    157153            ext = (Extension)c.newInstance(); 
    158154        } catch (Exception e) { 
     
    162158        this.addExtension(ns, ext); 
    163159    } 
     160 
     161    /** 
     162     * Parse a configuration file, that you already 
     163     * opened. 
     164     *  
     165     * @param    file      File object to parse 
     166     * @param    classLoader 
     167     * @throws   XJConfException 
     168     * @throws IOException 
     169     */ 
     170    public void parse(File file, ClassLoader classLoader) throws XJConfException, IOException { 
     171        this.loader = classLoader; 
     172        this.parse(file); 
     173     } 
    164174     
    165175   /** 
     
    193203    } 
    194204 
    195     /** 
    196      * Get the file that currently is being parsed 
    197      *  
    198      * @return 
    199      */ 
    200     public File getCurrentFile() { 
    201         return (File)this.openFiles.peek(); 
    202     } 
    203      
    204    /** 
    205     * Parse a configuration file. 
     205   /** 
     206    * Parse a configuration file. 
    206207    *  
    207208    * @param    filename    filename of the configuration file 
    208209    * @throws IOException 
    209210    * @throws XJConfException 
    210     */ 
    211     public void parse(String filename) throws XJConfException, IOException { 
    212         File file = new File(filename); 
    213         this.parse(file); 
    214     } 
    215      
     211    */ 
     212    public void parse(String filename, ClassLoader classLoader) throws XJConfException, IOException { 
     213        File file = new File(filename); 
     214        this.parse(file, classLoader); 
     215    } 
     216     
     217   /** 
     218    * Parse a configuration file. 
     219    *  
     220    * @param    filename    filename of the configuration file 
     221    * @throws IOException 
     222    * @throws XJConfException 
     223    */ 
     224    public void parse(String filename) throws XJConfException, IOException { 
     225        File file = new File(filename); 
     226        this.parse(file); 
     227    } 
     228     
     229    /** 
     230     * Get the file that currently is being parsed 
     231     *  
     232     * @return 
     233     */ 
     234    public File getCurrentFile() { 
     235        return (File)this.openFiles.peek(); 
     236    } 
     237     
    216238   /** 
    217239    * Start element 
     
    310332            } 
    311333        } 
    312  
    313334    } 
    314335 
  • trunk/version.properties

    r11 r47  
    1 version.number=0.9 
     1version.number=0.9.1