Issues trying to create an Array with org.openrdf.model.Resource[]

Hi

I am trying to create an array of org.openrdf.model.Resource[], but am
unable to.

e.g.

eval java_import ‘org.openrdf.model.Resource’

eval Resource
Java::OrgOpenrdfModel::Resource

eval [URIImpl.new(’
http://www.bbc.co.uk/instance/sport/football/teams’)].to_java:Resource
NameError Exception: cannot load Java class Resource

Is the syntax correct?

I have no issues with String[]

eval [‘1’,‘2’].to_java:String
#<#Class:01x1e59f7c:0xf64084>

thanks James

On Wed, Jul 20, 2011 at 6:06 PM, James S. [email protected]
wrote:

[URIImpl.new(‘http://www.bbc.co.uk/instance/sport/football/teams’)].to_java:Resource

NameError Exception: cannot load Java class Resource

Is the syntax correct?

I have no issues with String[]

eval [‘1’,‘2’].to_java:String
#<#Class:01x1e59f7c:0xf64084>

:String and a few others are recognized as being the appropriate Java
types. I think what you want is to remove the colon from Resource and
just pass the class directly in. That should work.

irb(main):002:0> import java.util.ArrayList
=> Java::JavaUtil::ArrayList
irb(main):003:0> [].to_java ArrayList
=> #<#Class:0x11477696b:0x2ba9fa4c>

  • Charlie

thanks Charlie

that’s worked a treat!

rdf_context_names.collect { |rdf_context_name|
URIImpl.new(rdf_context_name)
}.to_java Resource

thanks James

On Wed, Jul 20, 2011 at 10:25 PM, Charles Oliver N.
<[email protected]