Module: Jena::Util

Defined in:
lib/jena_jruby.rb,
lib/jena_jruby/utils.rb

Class Method Summary collapse

Class Method Details

.as_prefix_map(map) ⇒ Object

Return the given prefix map object as a ‘PrefixMapping`. Convert a hash to a `PrefixMapping` if necessary



5
6
7
8
9
10
11
12
13
# File 'lib/jena_jruby/utils.rb', line 5

def self.as_prefix_map( map )
  return nil unless map
  return map if map.is_a? com.hp.hpl.jena.shared.PrefixMapping
  pm = com.hp.hpl.jena.shared.impl.PrefixMappingImpl.new
  map.each_pair do |k,v|
    pm.setNsPrefix k.to_s, v.to_s
  end
  pm
end

.nowObject

Return the current time as a literal



21
22
23
24
25
# File 'lib/jena_jruby/utils.rb', line 21

def self.now
  cal = java.util.Calendar.getInstance
  cal.setTime( java.util.Date.new )
  Core::ResourceFactory.createTypedLiteral( cal )
end

.uuid_resource(model = nil) ⇒ Object

Return a new resource URN made from a UUID. If the given



16
17
18
# File 'lib/jena_jruby/utils.rb', line 16

def self.uuid_resource( model = nil )
  (model || Core::ResourceFactory).createResource( Util::JenaUUID.factory.generate.asURN )
end