[jdom-interest] questions about org.jdom.ProcessingInstruction
brett.mclaughlin at lutris.com
Tue Sep 12 16:20:16 PDT 2000
Ed Morehouse wrote:
> I've been looking at org.jdom.ProcessingInstruction and have a few questions:
> - The "data" portion of a ProcessingInstruction seems to be stored as both a
> String and a Map; is this, in fact, the case?
> - If so, what is the rationale for this, as opposed to just using one or the
Honestly, I don't remember ;-) Most likely because in some cases, one
works /really/ well, and in others, the other does.
> - Would a Map alone suffice to store all the possible "data payloads" a
> processing instruction could legally have?
Not really. Remember that a PI does not have to be in attribute-value
format. This is perfectly legal:
Here, there is no "key" for the map. But it would be fairly simple to
write the map in a way where some NO_NAME type key was set up, and the
value inserted. Of course, you could have multiple values with no name,
and you need different keys, but storage in a Map completely, (or in
String completely) is simple.
> - If so, it seems to me that the Map would be more powerful (and more OO), and
> would relieve the application programer from having to do a good deal of String
> processing. Does this seem right? Am i missing something?
Maybe just the odd PI case above.
> - There is a constructor that takes a Map and an internal Map already, but there
> doesn't seem to be any way to get a Map back out from a ProcessingInstruction;
> is this so?
It is so, because of the special case. It's one thing to store these
values internally with some sort of special NO_NAME key or whatever -
but giving that back to the developer I am against. That's why we let
them look up by attribute name, or get the whole thing raw, but not give
back the Map itself - if we store things completely in a Map, that Map
will sometimes have weird keys.
> - If yes, what would be the implications of adding a public Map getDataMap()
> method to ProcessingInstruction? If there weren't also a shadow data String,
> manipulating the Map directly seems like it would be okay and wouldn't cause
> corruption. This seems like it would fit in with the philosophy of using Java's
> native Collection interfaces to simplify XML programming, as in the case of the
> live child List in Element. Does this sound right?
Hope this starts us down improving the PI class - it's been dormant for
a long time.
> I'd appreciate feedback and comments, especially from Jason and Brett, but also
> from anyone with insight into this topic.
> - Ed
> - The happiest of people aren't the ones
> who always have the best of everything;
> they are the ones who always make the best
> of everything they have.
> Ed Morehouse
> Software Engineer/Evil Genius
> The Motley Fool
> To control your jdom-interest membership:
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc.
1200 Pacific Avenue, Suite 300
Santa Cruz, CA 95060 USA
More information about the jdom-interest