1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Metadata Extractor Java

Discussion in 'Programming & Webmastering' started by Wozzer, Apr 15, 2012.

  1. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.47/day)
    Thanks Received:
    68
    Location:
    England
  2. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.76/day)
    Thanks Received:
    5,620
    Location:
    Cheeseland (Wisconsin, USA)
    Looks pretty straight forward from the "getting started" page.
    What's your question, Wasley?
     
  3. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.47/day)
    Thanks Received:
    68
    Location:
    England
    I have the program working, but don't fully understand how it's working.

    for (Directory directory : metadata.getDirectories()) {
    for (Tag tag : directory.getTags()) {
    System.out.println(tag);
    }
    }

    This is the bit thats puzzling me.
     
  4. Aquinus

    Aquinus Resident Wat-man

    Joined:
    Jan 28, 2012
    Messages:
    7,067 (6.42/day)
    Thanks Received:
    2,611
    Location:
    Concord, NH
    Do you mean the
    Code:
    for ( Keyword variable_name : someclass.method_that_returns_array() ) {
    bit? It's like a foreach in PHP, you declare what the variable is going to be, then you provide the array as the second parameter after the colon.
     
    Wozzer says thanks.
  5. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.47/day)
    Thanks Received:
    68
    Location:
    England
    Yes I do :)

    How can you tell that's returning an array?
     
  6. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.76/day)
    Thanks Received:
    5,620
    Location:
    Cheeseland (Wisconsin, USA)
    It doesn't actually have to be an array, it could be any type of collection.
    What it's doing is
    " for every instance of this type of object in this collection (of the same type of objects) "

    It could be an Array, a List, a Dataset, etc.
    As long as the types match (or can be cast to a compatible type) and the collection has an enumerator the compiler is happy. :)
     
    Wozzer says thanks.
  7. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.76/day)
    Thanks Received:
    5,620
    Location:
    Cheeseland (Wisconsin, USA)
    Did you get this working sufficiently for your needs, Wasley?
    We're still willing to answer any questions you may have.

    If you did, let us know what your up to as other people's projects are always interesting to read about. :toast:
     
  8. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.47/day)
    Thanks Received:
    68
    Location:
    England
    Hi Kreij,

    Sorry for the late reply - Only just noticed it.

    Program is now working, thanks for your help. Will post source once it's complete!
     
    Last edited: Nov 9, 2012

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page