Class: RubyObjectWrapperBeanAdapter

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(bean) ⇒ RubyObjectWrapperBeanAdapter

Creates a Bean.new adapter.

The Bean object to wrap.

Parameters:

  • @bean


59
60
61
# File 'lib/fxmlloader/rorba.rb', line 59

def initialize(bean)
  @bean = bean
end

Instance Method Details

#[](key) ⇒ Object



68
69
70
# File 'lib/fxmlloader/rorba.rb', line 68

def [](key)
  return @bean.send("get#{key[0].upcase}#{key[1..-1]}")
end

#[]=(key, value) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/fxmlloader/rorba.rb', line 72

def []=(key, value)
  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



104
105
106
# File 'lib/fxmlloader/rorba.rb', line 104

def coerce(value, type)
  RubyWrapperBeanAdapter.coerce(value, type)
end

#getBeanObject



64
65
66
# File 'lib/fxmlloader/rorba.rb', line 64

def getBean()
  return @bean;
end

#getPropertyModel(key) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/fxmlloader/rorba.rb', line 96

def getPropertyModel(key)
  if (key == nil)
    raise ArgumentError.new();
  end

  return @bean.send("#{key}Property")
end

#getType(key) ⇒ Object



89
90
91
92
93
94
# File 'lib/fxmlloader/rorba.rb', line 89

def getType(key)
  if (key == nil)
    raise ArgumentError.new();
  end
  @bean.send(key + "GetType")
end

#read_only?(key) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
# File 'lib/fxmlloader/rorba.rb', line 82

def read_only?(key)
  if (key == nil)
    raise "NULL PTR"
  end
  @bean.methods.include? "set#{key[0].upcase}#{key[1..-1]}"
end