Module: Rjb::JMethod
- Included in:
- Rjb_JavaClass, Rjb_JavaProxy
- Defined in:
- lib/rjb.rb
Instance Method Summary collapse
- #format_sigs(s) ⇒ Object
- #instance_method?(m) ⇒ Boolean
- #jmethods(org, klass, &blk) ⇒ Object
- #make_snake(nm) ⇒ Object
- #public_method?(m) ⇒ Boolean
- #rjb_respond_to?(sym, klass, priv) ⇒ Boolean
Instance Method Details
#format_sigs(s) ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/rjb.rb', line 106 def format_sigs(s) if s.size < 0 '' elsif s.size == 1 s[0] else "[#{s.map{|m|m.nil? ? 'void' : m}.join(', ')}]" end end |
#instance_method?(m) ⇒ Boolean
93 94 95 |
# File 'lib/rjb.rb', line 93 def instance_method?(m) m.modifiers & MODIFIER.STATIC == 0 end |
#jmethods(org, klass, &blk) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/rjb.rb', line 99 def jmethods(org, klass, &blk) (org + klass.getMethods.select do |m| blk.call(m) end.map do |m| m.name.to_sym end).uniq end |
#make_snake(nm) ⇒ Object
115 116 117 |
# File 'lib/rjb.rb', line 115 def make_snake(nm) nm.gsub(/(.)([A-Z])/) { "#{$1}_#{$2.downcase}" } end |
#public_method?(m) ⇒ Boolean
96 97 98 |
# File 'lib/rjb.rb', line 96 def public_method?(m) (m.modifiers & MODIFIER.PUBLIC) == MODIFIER.PUBLIC end |
#rjb_respond_to?(sym, klass, priv) ⇒ Boolean
119 120 121 122 123 124 125 126 127 |
# File 'lib/rjb.rb', line 119 def rjb_respond_to?(sym, klass, priv) return true if (klass ? self : getClass).getMethods.select do |m| (klass && !instance_method?(m) && (priv || public_method?(m))) || (!klass && instance_method?(m) && (priv || public_method?(m))) end.map do |m| [m.name.to_sym, make_snake(m.name).to_sym] end.flatten.include?(sym.to_sym) rjb_org_respond_to?(sym, priv) end |