File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When has the hashtable been populated?

 
Kaiser Lautern
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm trying to understand the servlet code below, which is supposed to read the data from an xml file and load it to a hashtable. However, I couldn't figure out exactly at what time has the hashtable been populated.



I don't know the Digester API, but it seems that all it does is to populate the User and Subscription DTO's. Next, in the servlet's init() method (where load() is called) it's assumed that the hashtable is already populated:



Thanks,


Kaiser
 
Tim Baker
Ranch Hand
Posts: 541
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a line that says digster.push(this). The gives the digester a reference to the instance of the class that is calling digester. So either, digster uses and accessor method(s) to manipulate the database object, ie getDatabase(), or addItemToDataBase(..) or database is a public variable in the class? (that is something you can check).

Either way, the actual answer to your question is almost certainly, on this line:
digester.parse(bis);
[ May 15, 2005: Message edited by: Tim Baker ]
 
Kaiser Lautern
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks fr your answer Tim. I went and checked the Digester API. In fact the answer is in the line:


It calls the method addUser on the parent element (position top-1 in the stack and in this case, the servlet itself). And the addUser method in the servlet does the actual job:



Kaiser
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that line sets up the rule.
Nothing happens until you call the parse method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic