# Metadata Extractor Java



## Wozzer (Apr 15, 2012)

Has anyone got any experience in using this API? Could do with a hand.....

http://code.google.com/p/metadata-extractor/


----------



## Kreij (Apr 15, 2012)

Looks pretty straight forward from the "getting started" page.
What's your question, Wasley?


----------



## Wozzer (Apr 15, 2012)

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.


----------



## Aquinus (Apr 15, 2012)

Wasley said:


> I have the program working, but don't fully understand how it's working.
> 
> for (Directory directory : metadata.getDirectories()) {
> for (Tag tag : directory.getTags()) {
> ...



Do you mean the 
	
	



```
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 (Apr 15, 2012)

Yes I do 

How can you tell that's returning an array?


----------



## Kreij (Apr 15, 2012)

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.


----------



## Kreij (Apr 17, 2012)

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.


----------



## Wozzer (Jul 9, 2012)

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!


----------

