[jdom-interest] unsubscribe

RYAN HERRING RYAN.HERRING at morningstar.com
Wed Jul 19 09:23:53 PDT 2000


-----Original Message-----
From: jdom-interest-request at jdom.org
[mailto:jdom-interest-request at jdom.org]
Sent: Wednesday, July 19, 2000 10:32 AM
To: jdom-interest at jdom.org
Subject: jdom-interest digest, Vol 1 #118 - 5 msgs


Send jdom-interest mailing list submissions to
	jdom-interest at jdom.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.denveronline.net/mailman/listinfo/jdom-interest
or, via email, send a message with subject or body 'help' to
	jdom-interest-request at jdom.org

You can reach the person managing the list at
	jdom-interest-admin at jdom.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of jdom-interest digest..."


Today's Topics:

  1. Re: AleXMLOutputter (Alex Chaffee)
  2. Stirring up Trouble (Brett McLaughlin)
  3. Re: getMandatory* (Elliotte Rusty Harold)
  4. Re: Stirring up Trouble (Simon St.Laurent)
  5. Getting attribute name/value pairs (Frank Cohen)

--__--__--

Message: 1
Date: Tue, 18 Jul 2000 21:59:18 -0700
From: Alex Chaffee <guru at edamame.stinky.com>
To: Andrzej Bialecki <abial at webgiro.com>
Cc: tsasala at hifusion.com, Elliotte Rusty Harold <elharo at metalab.unc.edu>,
alex at jguru.com, jdom-interest at jdom.org
Subject: Re: [jdom-interest] AleXMLOutputter
Reply-To: alex at jguru.com



On Mon, Jul 17, 2000 at 04:20:15PM +0200, Andrzej Bialecki wrote:
> On Mon, 17 Jul 2000 tsasala at hifusion.com wrote:
> 
> > 
> > 	I'm a little confused here.  What's the serious problem with 
> > having toString like methods on all the objects?  It would output the 

OK, as for the "why nots..."

Why not toString()?

	Because toString is supposed to print a short debugging
message, not suitable for display to a user. For JDOM, it should (?)
print the element name and possibly a count of its contents, in a
concise string. XML (as output format) is many things, but it is not
concise.

	Furthermore, there is no one XML format that fits all
needs. Sometimes you want line breaks, sometimes you want indents,
sometimes you want comments, sometimes you want whitespace preserved,
sometimes you don't.  Variation -> parameterization -> a separate
outputter/formatter class.  Instead of e.toSerializedForm(), use new
XMLOutputter(true, false, "\n").formatElement(e), or something like
that.

	Naturally, we could define "e.toSerializedForm()" to make a
new XMLOutputter with default parameters, but I recommend against
that, since the definition of XMLOutputter and its defaults could
change. 


Why not Serializable?

	Because the name "Serializable" has been taken already, by the
java.io package, for a binary format.

	Furthermore, see above paragraph beginning "Furthermore."

Why not use XMLOutputter instead of having a separate XMLFormat (or
vice versa)?

	Because arcane issues surrounding character encodings may (or
may not) require refactoring the clean, nice string formatting logic
away from the nasty, brutish encoding logic.

	Personally, I feel this is probably unnecessary, or if it is,
it shuld happen behind the interface, as an implementation detail.


> > > > The issue I see with these is that the API is far more complex than
> > > > it needs to be. This is not sufficient to replace
> > > > getSerializedForm().  Given an Element e (or a Comment c, or a
> > > > Document d) calling getSerializedForm() is easy. Just
> > > >
> > > > String s = e.getSerializedForm();

I agree. I didn't take the time to make simple method signatures for
all node types.  

> > > Anyway: why Elements, PIs, DocType etc.. don't extend the same basic
> > > class?

I agree. There should be a common Node interface/abstract class; we
could easily write a print(Node n) method in the XMLOutputter that
would work for all Nodes.

> > > > The big issue is how to configure the formatting performed by
> > > > XMLOutputter.getSerializedForm(). We could:
> > > 
> > > I don't mind supplying additional object specifying dozens
> > > of serialization parameters. This would buy me extra flexibility of
> > > having different serialization parameters for different document
> > > fragments (e.g. pretty formatting for parts likely to be read by
> > > humans, condensed spaghetti for parts to be stored in the DB).

Gak! Please read my earlier message explaining that OOP means that the
object *is* its own options class. There's no need to make a separate
redundant options object. Instance variables/ properties are adequate
for the purposes of configuring an object.

E.g. XMLOutputter outHuman = new XMLOutputter();
     outHuman.setPreserveWhitespace(true);
     outHuman.setNewline("\r\n");
     ...

     XMLOutputter outDB = new XMLOutputt();
     outDB.setNewline(null);
     outDB.setIndent("");
     ...

-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

--__--__--

Message: 2
Date: Wed, 19 Jul 2000 09:20:50 -0500
From: "Brett McLaughlin" <brett.mclaughlin at lutris.com>
Organization: Lutris Technologies
To: jdom-interest at jdom.org
Subject: [jdom-interest] Stirring up Trouble

OK, guys, I'm about to wreak some potential havok.

Because of my book being out, I've been forced to do a bit of "technical
support" on a lot of Java and XML questions. I'm sure Jason and
Elliotte, as well as Simon, know what I'm talknig about here. Lots of
people have latched on to the word "intuitive" in JDOM, as in "it is
intuitive to use", and warped that thing all out of content. So let's
set the record straight (for myself, as well).

"Intuitive to use" and "does what the developer expects" are perhaps
deceiving terms. JDOM isn't some sort of smart compiler that does the
right thing even when you tell it to do the wrong thing. It can't fix
your mistakes, and it won't make up for a complete lack of knowledge
about XML. In fact, I would say that if you don't know Java or XML at
all, you have no business complaining about why JDOM doesn't work (you'd
be surprised at how many mails I get from people who "don't really know
Java" but find "the examples don't work"). Feel free to lurk and ask
questions, but don't complain that something you have no idea about
doesn't magically fix your errors.

So what does that mean? That I am finding that intuitive is a tough
word. It means "does what the developer expects, as long as the
developer's expectations are correct." Sort of tricky, huh? In light of
that, I find that JDOM should /not/ be intuitive in the case where the
developer is wrong, as that could encourage really bad concepts and
practices.

So, here's the crux of (at least) this email:

getContent(boolean preserveWhitespace);

is perfectly intuitive.

But what does

getContent()

do? I'll be the first to admit that I argued and argued that this should
not return whitespace, because that wasn't intuitive to the user. But if
the user things XML content ignores whitespace around textual content,
they would be WRONG. And I would be WRONG to encourage that belief. So
I'm now advocating that getContent() simply call getContent(true) and
return text with whitespace around it. I'm so convinced I'm willing to
make the /very/ painful changes in my book and defend the decision to
roughly 25000 readers (already!). So let the talks begin, I'm wanting
this resolved ASAP.

-Brett


-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org

--__--__--

Message: 3
<397426AA.89CADFA4 at epo.org>
Date: Wed, 19 Jul 2000 10:01:55 -0400
To: jdom-interest at jdom.org
From: Elliotte Rusty Harold <elharo at metalab.unc.edu>
Subject: Re: [jdom-interest] getMandatory*

At 11:43 AM +0200 7/18/00, Andre Van Delft wrote:
>Jason Hunter wrote:
>
>> Being that we had an overwhelming set of +1 votes for "null" including
>> the binding votes of Brett and myself (so glad we agree), I've now made
>> the change in the tree.  I changed getChild(), getAttribute(),
>> getRootElement(), and getProcessingInstruction() to return null if no
>> such item was found.  I also removed NoSuch* classes from the tree.  I'm
>> -1 on adding hasChild() because a null check is sufficient.  No reason
>> to bloat the API.
>
>Reluctantly I start the discussion again.
>

Please let's not go there again. Just last week I watched 30 out of 
40 of this semester's students incorrectly intuit that 
Applet.getParameter() threw an exception rather than returning null 
when the HTML file omitted the parameter. And 5 of the 10 who didn't 
think it threw an exception neglected to check for the possible null 
value despite being explicitly instructed  to check for all plausible 
error conditions and having been shown exactly how to handle this 
specific case in class. So I'm more convinced than ever that throwing 
the exception is the right thing to do.

Nonetheless, I think it's more important to move forward and stick 
with the decision that we've made rather than continually arguing the 
same points.

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+

--__--__--

Message: 4
Date: Wed, 19 Jul 2000 11:05:39 -0400
To: "Brett McLaughlin" <brett.mclaughlin at lutris.com>, jdom-interest at jdom.org
From: "Simon St.Laurent" <simonstl at simonstl.com>
Subject: Re: [jdom-interest] Stirring up Trouble

At 09:20 AM 7/19/00 -0500, Brett McLaughlin wrote:
>Because of my book being out, I've been forced to do a bit of "technical
>support" on a lot of Java and XML questions. I'm sure Jason and
>Elliotte, as well as Simon, know what I'm talknig about here. Lots of
>people have latched on to the word "intuitive" in JDOM, as in "it is
>intuitive to use", and warped that thing all out of content. So let's
>set the record straight (for myself, as well).

Readers read some amazing things _into_ books, independent of the author.
It's actually been pretty interesting...

>[...uninformed readers...]

>So what does that mean? That I am finding that intuitive is a tough
>word. It means "does what the developer expects, as long as the
>developer's expectations are correct." Sort of tricky, huh? In light of
>that, I find that JDOM should /not/ be intuitive in the case where the
>developer is wrong, as that could encourage really bad concepts and
>practices.

I like that stand very much - I'm trying to do similar things in various
simplification projects I'm working on.

>So, here's the crux of (at least) this email:
>
>getContent(boolean preserveWhitespace);
>
>is perfectly intuitive.
>
>But what does
>
>getContent()
>
>do? I'll be the first to admit that I argued and argued that this should
>not return whitespace, because that wasn't intuitive to the user. But if
>the user things XML content ignores whitespace around textual content,
>they would be WRONG. And I would be WRONG to encourage that belief. So
>I'm now advocating that getContent() simply call getContent(true) and
>return text with whitespace around it. I'm so convinced I'm willing to
>make the /very/ painful changes in my book and defend the decision to
>roughly 25000 readers (already!). So let the talks begin, I'm wanting
>this resolved ASAP.

I suspect the changes in your book can probably be made without drastic
evil breaking loose, though there may be pain in doing it.  I think what
you're doing here is downright admirable, and I think getContent(true)
makes a lot of sense. XML's creators made a tough decision, and I think
this approach at least puts people into better contact with that decision,
while letting them reverse it _when appropriate_.


Simon St.Laurent
XML Elements of Style / XML: A Primer, 2nd Ed.
http://www.simonstl.com - XML essays and books

--__--__--

Message: 5
From: "Frank Cohen" <fcohen at inclusion.net>
To: <jdom-interest at jdom.org>
Date: Wed, 19 Jul 2000 08:31:30 -0700
boundary="----=_NextPart_000_0008_01BFF15B.BCC22020"
Subject: [jdom-interest] Getting attribute name/value pairs

This is a multi-part message in MIME format.

------=_NextPart_000_0008_01BFF15B.BCC22020
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm using JDOM Beta 4 with JDK 122 from Sun. I'm rewriting an =
application to use XML-coded property files. The property file contains =
a list of property elements with simple attribute name=3Dvalue pairs.=20

I am having problems using the getAttributes() method. My code looks for =
the <load_init_values> element, a list of property elements is =
containined within. I get a list of the property elements and iterate =
through the list. When I find a property element in the list I ask for =
the attributes using getAttributes(). This gives me a List. When I =
iterate through the list I find the list is composed of Elements, not =
Attributes. So when I do:

   Object q =3D iterator.next();
   Attribute r =3D (Attribute) q;

I get a java.lang.ClassCastException: org.jdom.Element

Any idea what I'm doing wrong?

-Frank

--

<load>

  <!-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -->
  <!-- Initialization values                                             =
  -->
  <!-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -->

  <load_init_values>

    <echo message=3D"Starting Load 2.0 alpha 1"/>

    <property name=3D"scripts_directory" value=3D"./scripts"/>
    <property name=3D"accept_script_versions" value=3D"2"/>

    <property name=3D"log.file" value=3D"./load.log"/>
    <property name=3D"log.append" value=3D"true"/>
    <property name=3D"log.level" value=3D"6"/>

    <property name=3D"url" value=3D""/>
    <property name=3D"cookieok" value=3D"true"/>
    <property name=3D"bad_string" value=3D""/>
    <property name=3D"timeout" value=3D"0"/>
    <property name=3D"sleeptime" value=3D"0"/>
    <property name=3D"threadcount" value=3D"0"/>

  </load_init_values>

</load>



Exception occurred during event dispatching:
java.lang.ClassCastException: org.jdom.Element
        at load.commander.start(commander.java:159)
        at load.loadui.buttonRun_actionPerformed(loadui.java:208)
        at load.loadui$4.actionPerformed(loadui.java:124)
        at =
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:10
66)
        at =
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1101)
        at =
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:378)
        at =
javax.swing.JToggleButton$ToggleButtonModel.setPressed(Compiled Code)

        at =
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:217)



  public void start()
  {
    // Load the entire document into memory
    // from the network or file system
    try
    {
      // Gets the Load settings file, parses it into a DOM tree
     Document doc =3D load_info_builder.build( default_settings );

      // If there are no well-formedness errors,
      // then no exception is thrown
      uiframe.show( default_settings + " is well formed.");

   // Only read Load setting files
      Element load_set =3D doc.getRootElement();
      if ( load_set.getName().equals("load") )
      {
    // This is a load setting file so parse its contents

       loadui.show( default_settings + " parsing contents");

        // Within the load element is the load_init_values group
        // These are the elements we want to set the defaults for Load
        List children =3D =
load_set.getChild("load_init_values").getMixedContent();

        Iterator iterator =3D children.iterator();
        while (iterator.hasNext())
        {
          Object o =3D iterator.next();

          if (o instanceof Element)
          {
            Element p =3D (Element) o;

            // echo elements are comments that get displayed in the UI
            if ( p.getName().equals("echo") )
            {
              echo( p.getAttribute("message").getValue() );
            }

            // property elements are simple name =3D value pairs that =
set a
            // public variable in the commander object
      if ( p.getName().equals("property") )
            {

              List property_list =3D p.getAttributes();
              Iterator property_iterator =3D property_list.iterator();

              echo( property_list.size() + " =3D property list size");

              while ( property_iterator.hasNext() )
              {
                Object q =3D iterator.next();


// The problem seems to happen here. I get a runtime exception =
complaining that Java couldn't
// handle the ClassCast.


                Attribute r =3D (Attribute) q;

                echo(r.getName());
                echo(r.getValue());


// I added these if statements to see what kind of object Java thinks =
the Attribute class actuall is
// It turns out that q is always an instance of Element, not Attribute.


                if (q instanceof Attribute) { echo("attribute");}
                if (q instanceof Element) { echo("element> " + =
((Element) q).getName() );}
                if (q instanceof String) { echo("string");}

              }

         }

          }
        }

      }
      else
      {
       loadui.show( default_settings + "does not appear to be a Load =
settings file");
      }
    }
    catch (JDOMException e) { // indicates a well-formedness or other =
error
      uiframe.show( default_settings + " is not well formed.");
      uiframe.show( e.getMessage() );
    }
  }
}

------=_NextPart_000_0008_01BFF15B.BCC22020
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I'm using JDOM Beta 4 with JDK 122 from =
Sun. I'm=20
rewriting an application to use XML-coded property files. The property =
file=20
contains a list of property elements with simple attribute name=3Dvalue =
pairs.=20
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am having problems using the =
getAttributes()=20
method. My code&nbsp;looks for the &lt;load_init_values&gt; element, a =
list of=20
property elements is containined within.&nbsp;I get a list of the =
property=20
elements and iterate through the list. When I find a property element in =
the=20
list I ask for the attributes using getAttributes(). This gives me a =
List. When=20
I iterate through the list I find the list is composed of Elements, not=20
Attributes. So when I do:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Object q =3D =
iterator.next();
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Attribute r =3D =
(Attribute)=20
q;</FONT></DIV></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I get a java.lang.ClassCastException:=20
org.jdom.Element</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any idea what I'm doing =
wrong?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Frank</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;load&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; &lt;!--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
--&gt;<BR>&nbsp; &lt;!-- Initialization=20
values&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
--&gt;<BR>&nbsp; &lt;!--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
--&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; =
&lt;load_init_values&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;echo =
message=3D"Starting Load=20
2.0 alpha 1"/&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;property=20
name=3D"scripts_directory" =
value=3D"./scripts"/&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;property name=3D"accept_script_versions" =
value=3D"2"/&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;property =
name=3D"log.file"=20
value=3D"./load.log"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property =
name=3D"log.append"=20
value=3D"true"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property =
name=3D"log.level"=20
value=3D"6"/&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;property =
name=3D"url"=20
value=3D""/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property name=3D"cookieok"=20
value=3D"true"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property =
name=3D"bad_string"=20
value=3D""/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property name=3D"timeout"=20
value=3D"0"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property name=3D"sleeptime"=20
value=3D"0"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;property name=3D"threadcount" =

value=3D"0"/&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; =
&lt;/load_init_values&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;/load&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Exception occurred during event=20
dispatching:<BR>java.lang.ClassCastException:=20
org.jdom.Element<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at=20
load.commander.start(commander.java:159)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
at=20
load.loadui.buttonRun_actionPerformed(loadui.java:208)<BR>&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
at=20
load.loadui$4.actionPerformed(loadui.java:124)<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
at=20
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:10<BR>=
66)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
at=20
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra<BR>=
ctButton.java:1101)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
at=20
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel<BR>=
.java:378)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Compiled=20
Code)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at=20
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL<BR>=
istener.java:217)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; public void start()<BR>&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; // Load the entire document into=20
memory<BR>&nbsp;&nbsp;&nbsp; // from the network or file=20
system<BR>&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Gets the Load settings file, =
parses it=20
into a DOM tree<BR>&nbsp;&nbsp;&nbsp;&nbsp; Document doc =3D=20
load_info_builder.build( default_settings );</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If =
there are no=20
well-formedness errors,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // then no =
exception=20
is thrown<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uiframe.show( =
default_settings + "=20
is well formed.");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;// Only read Load =
setting=20
files<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Element load_set =3D=20
doc.getRootElement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (=20
load_set.getName().equals("load") )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// This is a load setting file so parse its =

contents</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;loadui.show(=20
default_settings + " parsing contents");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //=20
Within the load element is the load_init_values=20
group<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // These are the =
elements we=20
want to set the defaults for =
Load<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
List children =3D=20
load_set.getChild("load_init_values").getMixedContent();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iterator=20
iterator =3D =
children.iterator();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
while (iterator.hasNext())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object o =3D =

iterator.next();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (o =
instanceof=20
Element)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Element=20
p =3D (Element) o;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; //=20
echo elements are comments that get displayed in the=20
UI<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
if (=20
p.getName().equals("echo")=20
)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
&nbsp;echo( p.getAttribute("message").getValue()=20
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; //=20
property elements are simple name =3D value pairs that set=20
a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
//=20
public variable in the commander=20
object<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (=20
p.getName().equals("property")=20
)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
List property_list =3D=20
p.getAttributes();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Iterator property_iterator =3D property_list.iterator();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
echo( property_list.size() + " =3D property list size");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
while ( property_iterator.hasNext()=20
)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
Object q =3D iterator.next();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// The problem seems to happen here. I =
get a=20
runtime exception complaining that Java couldn't</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>// handle the ClassCast.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
Attribute r =3D (Attribute) q;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
echo(r.getName());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
echo(r.getValue());</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>// I added these if statements to see =
what kind of=20
object Java thinks the Attribute class actuall is</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>// It turns out that q is always an =
instance of=20
Element, not Attribute.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
if (q instanceof Attribute) {=20
echo("attribute");}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
if (q instanceof Element) { echo("element&gt; " + ((Element) =
q).getName()=20
);}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
if (q instanceof String) { echo("string");}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;loadui.show( default_settings =
+ "does=20
not appear to be a Load settings =
file");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; catch (JDOMException e) =
{ //=20
indicates a well-formedness or other =
error<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
uiframe.show( default_settings + " is not well=20
formed.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uiframe.show( =
e.getMessage()=20
);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }<BR>}</FONT></DIV></BODY></HTML>

------=_NextPart_000_0008_01BFF15B.BCC22020--



--__--__--

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com

End of jdom-interest Digest_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list