Re: [jruby-user] jruby call method from super java class

Keith Bennett <[email protected]> Thu, 4 Dec 2014 11:51:51 -0500
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CAJR0di5Y=vf7nti1_RFJ7OXqV8LM+EMC1Lhqvc=GmTg96s0S4A@mail.gmail.com>
Why not just use Ruby to sort them?:

sorted_keys = my_properties_object.keys.sort

If you're using Properties objects created by the JVM, you'll call the
Properties class' keys method and not your custom method.

If you're creating your own Properties objects, then you might not want to
use a Ruby subclass of Properties; Java code won't see the subclass, and if
you're only using it in Ruby, then a hash would probably be a lot more
convenient than a Properties object.

- Keith


On Wed, Dec 3, 2014 at 2:31 PM, Jochen Schreiber <[email protected]>
wrote:

> I am trying to create a subclass in jruby which overrides the keys
> method from the super java class properties cause i want to sort the
> entries in the properties class by the keys:
>
> class SortedProperties < java.util.Properties
>  def keys
>   keysEnum = super().keys()
>   keyList = java.util.Vector.new
>   keysEnum.elements.each do |element|
>     puts element.to_s
>     keyList.add(element.to_java(:String))
>   end
>   java.util.Collections.sort(keyList)
>   puts keyList.elements().to_s
>   return keyList.elements()
>  end
> end
>
> I am doing definitly something wrong with the super statement but i
> don't know what. Searched a lot but can't find anything that points me
> to the correct call of the method keys() in the super class properties.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>