Anton Tagunov wrote:

Hello, Berin!

Hello!


Just of academical interest: there may some easier ways then using
Stack, for instance a StringBuffer could be used.

Flavour 1:

when you need to rip off a path element and you know the length of the
name of the element that has just been closed, you just shorten the sb
by this length plus 1 (for the separator)

Flavour 2:

when you need to rip off a path element you just go searching the sb
from back to the begging untill you find the next separator (the '/'
char) and shorten the sb by that amount.

With a StringBuffer the amount of memory used will be way less then
for a Stack (in fact it will depend on the depth of the xml tree and
the lenghes of element names).

The other issue has to do with dynamically creating the configuration objects.

For example, if I am creating a tree, I have to create the leaves before
the parent.  Since there is no parent created yet, I can only put a guestimated
location path.  For example:

DefaultConfiguration leaf = new DefaultCOnfiguration("name","/root/name");
DefaultConfiguration root = new DefaultConfiguration("root","/root");
root.addChild(leaf);

Now what happens when I call the method that creates this configuration
tree, and then add it to another configuration tree?

DefaultConfiguration realRoot = new DefaultConfiguration("problem","/problem");
realRoot.addChild(getConfigFromAbove());

When you look at the path for each element, and traverse the tree, then you
will see something like this:

/problem
  /root
    /root/name

(indents provided to show the logical relationship).

The path is more troublesome than it is worth unless it is always created
by the DocumentBuilder.

--

"They that give up essential liberty to obtain a little temporary safety
 deserve neither liberty nor safety."
                - Benjamin Franklin


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to