Greetings.

I am trying to list all keys in a java.util.HashMap field.

The Java code to do this looks like:
#
Collection c = hMap.values();
#

#
//obtain an Iterator for Collection
#
Iterator itr = c.iterator();
#

#
//iterate through HashMap values iterator
#
while(itr.hasNext())
  System.out.println(itr.next());


So, I took a stab at the ruby version:

# I have a java hashmap called fields that was created using iText
thusly

reader = pdfreader.new( "pdf_file.pdf" )
@form = reader.getAcroFields()
fields = @form.getFields()  # this is a hashmap of all fields on form
fields._classname  # entere in irc displays: java.util.HashMap

# So, following the java code above

c = fields.values()
itr = c.iterator()
while itr.hasNext()
 p itr.next()
end

Instead of getting the field names, I get
#<#<Class:0x2d47d74>:0x2c15208>
#<#<Class:0x2d47d74>:0x2c151a4>
#<#<Class:0x2d47d74>:0x2c150b4>

(there are three keys in the hash)

Any ideas?

Thanks,
Dan
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to