Re: JAXP code fragment help

Discussion in 'Java' started by Willian Irving Zumwalt, Aug 25, 2003.

  1. Sorry, here's the correctly pasted code. I'd like to know how the obj
    "Configuration" uses JAXP to retreive settings from a file?

    MyConfig mcfg = (MyConfig) Configuration.load("config.xml");
    String setting1 = mc.getSetting("setting1");
    String param1 = mc.getParameter(setting1, "par1");
     
    Willian Irving Zumwalt, Aug 25, 2003
    #1
    1. Advertising

  2. Darn, I'm really screwing up cut and paste.

    MyConfig mcfg = (MyConfig) Configuration.load("config.xml");
    String setting1 = mcfg.getSetting("setting1");
    String param1 = mcfg.getParameter(setting1, "par1");

    Sorry again, that should do it.
     
    Willian Irving Zumwalt, Aug 25, 2003
    #2
    1. Advertising

  3. Willian Irving Zumwalt

    Roedy Green Guest

    On 25 Aug 2003 11:28:37 -0700, (Willian Irving
    Zumwalt) wrote or quoted :

    >MyConfig mcfg = (MyConfig) Configuration.load("config.xml");
    >String setting1 = mcfg.getSetting("setting1");
    >String param1 = mcfg.getParameter(setting1, "par1");
    >
    >Sorry again, that should do it.


    To understand this, you have to look at the MyConfig class. It might
    just be a pointer to a String representation of the XML file.

    The Configuration.load produces something generic, which is actually a
    MyConfig, hence the cast. That strikes me as odd, unless
    Configuration is using reflection to create a class on the fly based
    on what it sees in the XML.

    getSetting method just looks in the XML file for that parameter, and
    returns the corresponding value. Presumably "setting1" is one of the
    fields of the XML's DTD tags.
    so it is searching inside for something like

    <settting1>yellow</setting1>

    It is possible that MyConfig predigests the XML file into a parse
    tree. You would have to read the docs on MyConfig or its base class
    to figure out how it works.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 25, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Oedenkoven
    Replies:
    1
    Views:
    530
    zinga
    Jan 4, 2005
  2. Mohammed Mazid

    What is wrong with the code fragment?

    Mohammed Mazid, Nov 27, 2003, in forum: Java
    Replies:
    3
    Views:
    348
    SirThanxALot
    Nov 28, 2003
  3. Michael
    Replies:
    1
    Views:
    5,333
    Michael Berg
    Feb 22, 2004
  4. Andy Fish

    what does this code fragment do

    Andy Fish, May 21, 2004, in forum: Java
    Replies:
    15
    Views:
    549
    Tony Morris
    May 22, 2004
  5. Mullin
    Replies:
    0
    Views:
    323
    Mullin
    Feb 24, 2005
Loading...

Share This Page