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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    734
    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:
    430
    SirThanxALot
    Nov 28, 2003
  3. Andy Fish

    what does this code fragment do

    Andy Fish, May 21, 2004, in forum: Java
    Replies:
    15
    Views:
    684
    Tony Morris
    May 22, 2004
  4. Mullin
    Replies:
    0
    Views:
    406
    Mullin
    Feb 24, 2005
  5. Chris
    Replies:
    7
    Views:
    646
    BigBrian
    Feb 9, 2005
  6. Mateusz
    Replies:
    3
    Views:
    882
    Neredbojias
    Aug 25, 2006
  7. Donald Welker

    Code fragment to revise CustomSD SDDL for Event Log

    Donald Welker, Sep 27, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    255
    Donald Welker
    Sep 27, 2005
  8. Amishera Amishera

    why getting error for this code fragment

    Amishera Amishera, Mar 31, 2010, in forum: Ruby
    Replies:
    3
    Views:
    182
    Brian Candler
    Mar 31, 2010
Loading...