commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathis Hofer <mathis.ho...@dreamlab.net>
Subject [configuration] Looping through multiple nodes
Date Thu, 08 Feb 2007 09:43:43 GMT
Hi

I have a question about looping through multiple nodes with
HierarchicalConfiguration.

This is how my data looks like:
    <image>
      <filename>foo.jpg</filename>
      <rank>0</rank>
      <tile>
        <point>
          <x>491</x>
          <y>559</y>
        </point>
        <point>
          <x>451</x>
          <y>612</y>
        </point>
        <point>
          <x>405</x>
          <y>779</y>
        </point>
      </tile>
      <tile>
        ...
      </tile>
      ...
    </image>
    <image>
      <filename>bar.jpg</filename>
      <rank>1</rank>
      ...
    <image>


Now if I get the amount of images with getMaxIndex() I get 2, which is correct:
    int numImages = config.getMaxIndex("image");

But if I get the amount of tiles within the first image I get 0, although there
are a few tiles:
    int numTiles = config.getMaxIndex("image(0).tile");

Also when trying to get the property I get the output from the else statement,
so no collection is available:
    Object prop = config.getProperty("image(0).puzzletile");
    if (prop instanceof Collection) {
        System.out.println("numTiles="+((Collection)prop).size());
    } else {
        System.out.println("is not a Collection");
    }


What am I doing wrong?

Maybe as an addition: The above data structure is simplyfied. The <image> is
already in some other node. There are other single-properties (like integers and
strings) on the same level as image which I can read out, so the path to it
should be alright.

I'm glad if someone can help me...

Regards,
Mathis


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message