Class: RubyObjectWrapperBeanAdapter
- Inherits:
-
Object
- Object
- RubyObjectWrapperBeanAdapter
- Defined in:
- lib/fxmlloader/rorba.rb
Overview
/**
-
Exposes Java Bean properties of an object via the {@link Mapend interface.
-
A call to {@link Map#get(Object)end invokes the getter for the corresponding
-
property, and a call to {@link Map#put(Object, Object)end invokes the
-
property’s setter. Appending a “Property” suffix to the key returns the
-
corresponding property model.
*/
Constant Summary collapse
- GET_PREFIX =
"get"- IS_PREFIX =
"is"- SET_PREFIX =
"set"- PROPERTY_SUFFIX =
"Property"- VALUE_OF_METHOD_NAME =
"valueOf"- @@globalMethodCache =
{}
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #coerce(value, type) ⇒ Object
- #getBean ⇒ Object
- #getPropertyModel(key) ⇒ Object
- #getType(key) ⇒ Object
-
#initialize(bean) ⇒ RubyObjectWrapperBeanAdapter
constructor
Creates a Bean.new adapter.
- #read_only?(key) ⇒ Boolean
Constructor Details
#initialize(bean) ⇒ RubyObjectWrapperBeanAdapter
Creates a Bean.new adapter.
The Bean object to wrap.
84 85 86 |
# File 'lib/fxmlloader/rorba.rb', line 84 def initialize(bean) @bean = bean end |
Instance Method Details
#[](key) ⇒ Object
93 94 95 |
# File 'lib/fxmlloader/rorba.rb', line 93 def [](key) return @bean.send("get#{key[0].upcase}#{key[1..-1]}") end |
#[]=(key, value) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fxmlloader/rorba.rb', line 97 def []=(key, value) dputs "calling setterrorab" if (key == nil) raise "NULL PTR" end ty = getType(key) co = coerce(value, ty) @bean.send("set#{key[0].upcase}#{key[1..-1]}", co); return nil; end |
#coerce(value, type) ⇒ Object
130 131 132 |
# File 'lib/fxmlloader/rorba.rb', line 130 def coerce(value, type) RubyWrapperBeanAdapter.coerce(value, type) end |
#getBean ⇒ Object
89 90 91 |
# File 'lib/fxmlloader/rorba.rb', line 89 def getBean() return @bean; end |
#getPropertyModel(key) ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/fxmlloader/rorba.rb', line 122 def getPropertyModel(key) if (key == nil) raise ArgumentError.new(); end return @bean.send("#{key}Property") end |
#getType(key) ⇒ Object
115 116 117 118 119 120 |
# File 'lib/fxmlloader/rorba.rb', line 115 def getType(key) if (key == nil) raise ArgumentError.new(); end @bean.send(key + "GetType") end |
#read_only?(key) ⇒ Boolean
108 109 110 111 112 113 |
# File 'lib/fxmlloader/rorba.rb', line 108 def read_only?(key) if (key == nil) raise "NULL PTR" end @bean.methods.include? "set#{key[0].upcase}#{key[1..-1]}" end |