commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Price <epr...@ptc.com>
Subject [digester] using digester's exceptions
Date Tue, 11 Mar 2003 18:38:32 GMT
Does it go against the intent/contract of the Digester package to use 
some of its classes out of the context in which they were designed?  I 
want to raise an exception if my field is still null after trying to set 
the field with a Digester instance, but I'm wondering if this is really 
appropriate:

public abstract class AbstractReport implements Report {
     private Criteria criteria;

     /**
      * Generates a Report from information in the passed-in file.
      */
     public AbstractReport(File file) throws IOException {
         Digester digester = new Digester();
         digester.push(this);
         digester.addObjectCreate("criteria",
                                  "com.erikprice.oatmeal.Criteria");
         digester.addSetNext("criteria", "setCriteria");
         // other rules go here
         digester.parse(file);

         if (this.criteria == null) {
------->    throw new XmlLoadException("criteria field not registered");
         }
         // do other processing using this.criteria
     }
}



Thanks,

Erik


Mime
View raw message