Module: Java

Defined in:
lib/jinx/import/java.rb

Defined Under Namespace

Modules: JavaUtil

Constant Summary collapse

NAME_SPLITTER_REGEX =
/^([\w.]+)\.(\w+)$/

Class Method Summary collapse

Class Method Details

.expand_to_class_path(path) ⇒ Object

See Also:

  • ClassPathModifier#expand_to_class_path


14
15
16
# File 'lib/jinx/import/java.rb', line 14

def self.expand_to_class_path(path)
  @cp_mod.expand_to_class_path(path)
end

.load_properties(name) ⇒ Hash?

Returns the properties content, or nil if the file is not on the classpath.

Parameters:

  • name (String)

    the properties file name

Returns:

  • (Hash, nil)

    the properties content, or nil if the file is not on the classpath



20
21
22
23
24
25
# File 'lib/jinx/import/java.rb', line 20

def self.load_properties(name)
  url = JRuby.runtime.jruby_class_loader.findResource(name) || return
  props = JavaUtil::Properties.new
  props.load(url.openStream)
  props
end

.nowObject



187
188
189
# File 'lib/jinx/import/java.rb', line 187

def self.now
  JavaUtil::Date.from_ruby_date(DateTime.now)
end

.split_class_name(name_or_class) ⇒ String

Returns the package and base for the given name.

Parameters:

  • the (Class, String)

    JRuby class or the full Java class name

Returns:

  • (String, String)

    the package and base for the given name



193
194
195
196
197
# File 'lib/jinx/import/java.rb', line 193

def self.split_class_name(name_or_class)
  name = Class === name_or_class ? name_or_class.java_class.name : name_or_class
  match = NAME_SPLITTER_REGEX.match(name)
  match ? match.captures : [nil, name]
end