Thomas Thomas wrote:
Oliver,
I could perfectly add elements and attributes how I want,
But I have a problem that I can't solve with the doc.
The "startlist" tag (included in the root tag) was below the proxy "tag",
and when I do this :
((HierarchicalConfiguration)writer).clearTree("startlist");
Iterator it = collection.getDirectoriesToParse();
while (it.hasNext()) {
writer.addProperty("startlist(-1).start(-1)",
(String)it.next());
writer.addProperty("[EMAIL PROTECTED]", Boolean.TRUE);
writer.addProperty("[EMAIL PROTECTED]", Boolean.TRUE);
}
It adds the startlist as last element of the root tag.
It lost its position.
Do u have any idea on how to fix this ?
Thank u for any help.
Okay, this is a hard one.
I think, what you can do is to override the values of the start elements
instead of removing them and then adding them again. This can be done
with the setProperty() method. With
int cnt = ((HierarchicalConfiguration)
writer).getMaxIndex("startlist.start");
you can determine, how many <start> elements exist. Then in a loop you
can do:
for (int i = 0; it.hasNext() && i < cnt; i++) {
writer.setProperty("startlist.start(" + i + ")",
(String)it.next());
writer.setProperty("startlist.start(" + i + ")[EMAIL PROTECTED]",
Boolean.TRUE);
writer.setProperty("startlist.start(" + i + ")[EMAIL PROTECTED]",
Boolean.TRUE);
}
If more elements have to be added then the file did contain before, the
remaining ones can be added in the usual way (as in your code above). If
some elements are no longer needed, they can be removed with clearTree()
specifying the exact index (as in the setProperty() calls above).
Hope that helps. The configuration API gives you only a limited control
over the order of the properties.
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]