commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Marendo <jmare...@yahoo.com>
Subject Re: Using Digester to store info into a Map
Date Thu, 15 Jun 2006 14:43:09 GMT
Simon,
  
  Thanks for the reply and helpful information.
  
  >>If user is the root level, then you've not got a lot of object in the
  >>map :-)
  
  Yeah, actually, I did have a single file with multiple users listed  within it as you had
suggested, but I later changed the design so that  each user would have his own XML file.
 Part of the reason for  that is because I'm also using Betwixt to save objects as XML.  
Just seemed a bit easier to split the users apart into separate files.
  
  >>The best solution would be to simply *not* use a map.
  [snip]
  >>   private Map<Users> userMap = new HashMap<Users>();
  
  Can you clarify that for me?  The "<Users>" notation next to  the Map and HashMap
classnames is throwing me off, although I think it  just means that they would be storing
User instances.
  
  >>Unfortunately, invoking a custom rule when using the xmlrules module
  >>isn't easy.
  
  Yeah, I was afraid of that.  I really wanted to avoid "defining  the rules", so-to-speak,
within the code.  Right now I have a  generic method in which the Digester is fed a "source"
XML file along  with the "rules" XML file that corresponds to it and parsing happens  from
there.
  
  private void process(String xmlFilename, String xmlRulesFilename) {
          URL xml = null, rules = null;
          try {
              File f = new File(xmlFilename);
              xml = f.toURL();
              rules = this.getClass().getResource(xmlRulesFilename);
  
              Digester digester = DigesterLoader.createDigester(rules);
              digester.push(this);
  
              // parse the info
              digester.parse(xml.openStream());
          } catch (SAXParseException e) {
  [snip]
  
  Anyway, thanks again for the suggestions and help.
  
  Jeff

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message