Class: RubyWrapperBeanAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/fxmlloader/rrba.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"
OBJECT_PUBLIC_METHODS =
Object.new.public_methods
@@method_cache =
{}
@@mapper =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bean) ⇒ RubyWrapperBeanAdapter

The Bean object to wrap.

Parameters:

  • @bean


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fxmlloader/rrba.rb', line 49

def initialize(bean)
  @bean = bean
  type = @bean.java_class
  javas = []
  while type != java.lang.Object.java_class && !@@method_cache.has_key?(type)
    javas += build_cache_for(type)
    type = type.superclass
  end
  #    class_methods = {}
  #    (@bean.public_methods - OBJECT_PUBLIC_METHODS - javas.map{|x|x.name.to_sym}).each do |method_name|
  #      puts "ruby method: #{method_name}"
  #      name = method_name.to_s
  #      unless class_methods.has_key? name
  #        class_methods[name] = []
  #      else
  #        class_methods[name]
  #      end << method_name.to_sym
  #    end
  #    @@method_cache[@bean.class] =
end

Class Method Details

.coerce(value, type) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/fxmlloader/rrba.rb', line 248

def self.coerce( value,  type)
  if (type == nil)
    raise "ArgumentError.new();"
  end
  if (value.class == Java::JavaObject)
    value = value.to_java
  end

  coercedValue = nil;
  if (value == nil)
    # Null values can only be coerced to nil
    coercedValue = nil;
  elsif type == java.lang.Object.java_class || (value.is_a?(EventHandlerWrapper) && type == Java.javafx.event.EventHandler.java_class) || (value.respond_to?(:java_class) && !value.is_a?(EventHandlerWrapper) && type.assignable_from?(value.java_class))
    # Value doesn't require coercion
    coercedValue = value;
  elsif !value.respond_to?(:java_class) && !type.enum?
    # its a ruby value

    if mapper[[value.class, type]]
      coercedValue = mapper[[value.class, type]]
      if coercedValue.arity == 1
        coercedValue = coercedValue.call(value)
      else
        coercedValue = coercedValue.call(value, type)
      end
    else
      raise "Unknown Coercion map: (#{value}, #{type}) (#{value.inspect}, [#{value.class}, #{type.inspect}]; Please file a bug on this."
    end
    # Ruby String :D
  elsif value.class ==  String && type.enum?
    if value[0] == value[0].downcase
      puts "WHOA Value is not #{value}"
      #TODO: does this need proper snake casing when upcasting?
      value = value.upcase
    end
    coercedValue = type.ruby_class.valueOf(value)
  elsif value.respond_to?(:java_class) && value.java_class == Java::java.net.URL.java_class && type == Java::java.lang.String.java_class
    # TODO: HACK!
    dputs "COnverting url to string"
    coercedValue = value.to_s
  else
    raise "!! Non-normal coerce (#{value}, #{type}) (#{value.inspect}, #{type.inspect})"
  end
  return coercedValue;
end

.for(names) ⇒ Object



762
763
764
765
766
767
768
# File 'lib/fxmlloader/rrba.rb', line 762

def self.for(names)
  if names.is_a? java.lang.Object or (names.is_a? Java::JavaObject and (names = names.to_java))
    RubyWrapperBeanAdapter.new(names)
  else
    RubyObjectWrapperBeanAdapter.new(names)
  end
end

.get3(target, sourceType, key) ⇒ Object

/**

 * Invokes the static getter method for the given property.
 *
 * @param target
 * The object to which the property is attached.
 *
 * @param sourceType
 * The class that defines the property.
 *
 * @param key
 * The property name.
 *
 * @return
 * The value returned by the method, or <tt>nil</tt> if no such method
 * exists.
 */
@SuppressWarnings("unchecked")


311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/fxmlloader/rrba.rb', line 311

def self.get3(target,  sourceType,  key)
  value = nil;

  targetType = target.java_class();
  getterMethod = getStaticGetterMethod(sourceType, key, targetType);

  if (getterMethod != nil)
    begin
      value =  MethodUtil.invoke(getterMethod, nil, [target ] );
    rescue InvocationTargetException => exception
      raise RuntimeException.new(exception);
    rescue IllegalAccessException => exception
      raise RuntimeException.new(exception);
    end
  end

  return value;
end

.getConstantValue(type, name) ⇒ Object

/**

* Returns the value of a named constant.
*
* @param type
* The type that defines the constant.
*
* @param name
* The name of the constant.
*/


591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/fxmlloader/rrba.rb', line 591

def self.getConstantValue( type,  name)
  if (type == nil)
    raise IllegalArgumentException.new();
  end

  if (name == nil)
    raise IllegalArgumentException.new();
  end

  field = nil
  begin
    field = FieldUtil.getField(type, name);
  rescue NoSuchFieldException => exception
    raise IllegalArgumentException.new(exception);
  end

  int fieldModifiers = field.modifiers();
  if ((fieldModifiers & Modifier.STATIC) == 0            || (fieldModifiers & Modifier.FINAL) == 0)
    raise IllegalArgumentException.new("Field is not a constant.");
  end

  value = nil
  begin
    value = field.get(nil);
  rescue IllegalAccessException => exception
    raise IllegalArgumentException.new(exception);
  end

  return value;
end

.getGenericListItemType(listType) ⇒ Object

/**

* Determines the type of a list item.
*
* @param listType
*/


488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/fxmlloader/rrba.rb', line 488

def self.getGenericListItemType(listType)
  itemType = nil;

  parentType = listType;
  while (parentType != nil)
    if (parentType.is_a? ParameterizedType)
      parameterizedType = parentType;
      rawType = parameterizedType.getRawType();
      if (List.java_class.assignable_from?(rawType))
        itemType = parameterizedType.getActualTypeArguments()[0];
      end

      break;
    end

    classType = parentType;
    genericInterfaces = classType.generic_interfaces();

    genericInterfaces.each do |genericInterface|
      if (genericInterface.is_a? ParameterizedType)
        parameterizedType = genericInterface;
        interfaceType = parameterizedType.getRawType();
        if (List.java_class.assignable_from?(interfaceType.java_class)) || (List.java_class.assignable_from?(interfaceType.java_object))
          itemType = parameterizedType.getActualTypeArguments()[0];
          break;
        end
      end
    end

    if (itemType != nil)
      break;
    end

    parentType = classType.generic_superclass();
  end

  if (itemType != nil && itemType.is_a?(java.lang.reflect.TypeVariable))
    itemType = Java::java.lang.Object.java_class;
  end

  return itemType;
end

.getGenericMapValueType(mapType) ⇒ Object

/**

* Determines the type of a map value.
*
* @param mapType
*/


536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/fxmlloader/rrba.rb', line 536

def self.getGenericMapValueType( mapType)
  valueType = nil;

  parentType = mapType;
  while (parentType != nil)
    if (parentType.is_a? ParameterizedType)
      parameterizedType = parentType;
      rawType = parameterizedType.getRawType();

      if (java.util.Map.java_class.assignable_from?(rawType))
        valueType = parameterizedType.getActualTypeArguments()[1];
      end

      break;
    end

    classType = parentType;
    genericInterfaces = classType.getGenericInterfaces();

    genericInterfaces.each do |genericInterface|

      if (genericInterface.is_a? ParameterizedType)
        parameterizedType = genericInterface;
        interfaceType = parameterizedType.getRawType();

        if (java.util.Map.java_class.assignable_from?(interfaceType))
          valueType = parameterizedType.getActualTypeArguments()[1];
          break;
        end
      end
    end

    if (valueType != nil)
      break;
    end

    parentType = classType.getGenericSuperclass();
  end

  if valueType != nil && valueType.is_a?(TypeVariable)
    valueType = Java::java.lang.Object.java_class;
  end

  return valueType;
end

.getGenericType(sourceType, key, targetType) ⇒ Object

/**

* Returns the generic type of a static property.
*
* @param sourceType
* The class that defines the property.
*
* @param key
* The property name.
*
* @param targetType
* The type of the object to which the property applies.
*/


449
450
451
452
# File 'lib/fxmlloader/rrba.rb', line 449

def self.getGenericType( sourceType,  key,  targetType)
  Method getterMethod = getStaticGetterMethod(sourceType, key, targetType);
  return (getterMethod == nil) ? nil : getterMethod.getGenericReturnType();
end

.getListItemType(listType) ⇒ Object

/**

* Determines the type of a list item.
*
* @param listType
*/


459
460
461
462
463
464
465
466
# File 'lib/fxmlloader/rrba.rb', line 459

def self.getListItemType(listType)
  itemType = getGenericListItemType(listType);

  if (itemType.is_a? ParameterizedType)
    itemType = (itemType).getRawType();
  end
  return itemType;
end

.getMapValueType(mapType) ⇒ Object

/**

* Determines the type of a map value.
*
* @param listType
*/


473
474
475
476
477
478
479
480
481
# File 'lib/fxmlloader/rrba.rb', line 473

def self.getMapValueType( mapType)
  valueType = getGenericMapValueType(mapType);

  if (valueType.is_a? ParameterizedType)
    valueType = (valueType).getRawType();
  end

  return valueType;
end

.getStaticGetterMethod(sourceType, key, targetType) ⇒ Object



622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/fxmlloader/rrba.rb', line 622

def self.getStaticGetterMethod( sourceType,  key,         targetType)
  if (sourceType == nil)
    raise ArgumentError.new();
  end

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

  method = nil;

  if (targetType != nil)
    key = key[0].upcase + key[1..-1];

    getMethodName = GET_PREFIX + key;
    isMethodName = IS_PREFIX + key;

    begin
      method = MethodUtil.getMethod(sourceType, getMethodName, [ targetType ]);
    rescue NoSuchMethodException => exception
      # No-op
    end

    if (method == nil)
      begin
        method = MethodUtil.getMethod(sourceType, isMethodName, [targetType ]);
      rescue NoSuchMethodException => exception
        # No-op
      end
    end

    # Check for interfaces
    if (method == nil)
      interfaces = targetType.interfaces();
      interfaces.length.times do |i|
        begin
          method = MethodUtil.getMethod(sourceType, getMethodName, [ interfaces[i] ]);
        rescue NoSuchMethodException => exception
          # No-op
        end

        if (method == nil)
          begin
            method = MethodUtil.getMethod(sourceType, isMethodName,  [interfaces[i]] );
          rescue NoSuchMethodException => exception
            # No-op
          end
        end

        if (method != nil)
          break;
        end
      end
    end

    if (method == nil)
      method = getStaticGetterMethod(sourceType, key, targetType.superclass());
    end
  end

  return method;
end

.getStaticSetterMethod(sourceType, key, valueType, targetType, rubify = false) ⇒ Object



685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# File 'lib/fxmlloader/rrba.rb', line 685

def self.getStaticSetterMethod( sourceType,  key,
    valueType,  targetType, rubify=false)
  if (sourceType == nil)
    raise "NULL PTR"
  end

  if (key == nil)
    raise "NULL PTR"
  end

  if (valueType == nil)
    dputs caller
    dp sourceType, key, valueType, targetType, rubify
    raise "NULL PTR"
  end

  method = nil;

  if (targetType != nil)
    key = key[0].upcase + key[1..-1];

    setMethodName = SET_PREFIX + key;
    begin
      unless rubify
        method = MethodUtil.getMethod(sourceType, setMethodName,[ targetType, valueType ]);
      else
        method = sourceType.ruby_class.method(setMethodName)
      end
    rescue NoSuchMethodException => exception
      # No-op
    end

    # Check for interfaces
    if (method == nil)
      interfaces = targetType.interfaces();
      interfaces.length.times do |i|
        begin
          method = MethodUtil.getMethod(sourceType, setMethodName, [ interfaces[i], valueType ]);
        rescue NoSuchMethodException => exception
          # No-op
        end

        if (method != nil)
          break;
        end
      end
    end

    if (method == nil)
      method = getStaticSetterMethod(sourceType, key, valueType, targetType.superclass());
    end
  end

  return method;
end

.getType(sourceType, key, targetType) ⇒ Object

/**

* Returns the type of a static property.
*
* @param sourceType
* The class that defines the property.
*
* @param key
* The property name.
*
* @param targetType
* The type of the object to which the property applies.
*/


432
433
434
435
# File 'lib/fxmlloader/rrba.rb', line 432

def self.getType(sourceType,  key, targetType)
  getterMethod = getStaticGetterMethod(sourceType, key, targetType);
  return (getterMethod == nil) ? nil : getterMethod.return_type();
end

.isDefined(sourceType, key, targetType) ⇒ Object

/**

* Tests the existence of a static property.
*
* @param sourceType
* The class that defines the property.
*
* @param key
* The property name.
*
* @param targetType
* The type of the object to which the property applies.
*
* @return
* <tt>true</tt> if the property exists; <tt>false</tt>, otherwise.
*/


416
417
418
# File 'lib/fxmlloader/rrba.rb', line 416

def self.isDefined( sourceType,  key,  targetType)
  return (getStaticGetterMethod(sourceType, key, targetType) != nil);
end

.jit_export(co, value, ty, setter, ignore = nil) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/fxmlloader/rrba.rb', line 194

def self.jit_export(co, value, ty, setter, ignore=nil)
  coi = co.inspect
  if co.is_a? Java::JavaLang::Enum
    coi = "Java::#{co.java_class.name.gsub(/[\$\.]/, "::")}::#{co.to_s}"
  elsif co.is_a? EventHandlerWrapper
    coi = "EventHandlerWrapper.new(__local_fxml_controller, #{co.funcName.inspect})"
  elsif co.is_a? ScriptEventHandler
    coi = "ScriptEventHandler.new(#{co.script.inspect}, __local_sem_lang_inst_#{rget_sem(co.scriptEngine)})"
  elsif tmp = rget(value)
    coi = tmp
  elsif co.is_a? Java::javafx.scene.paint.Paint
    coi = "RubyWrapperBeanAdapter.coerce(#{value.inspect}, #{ty.ruby_class}.java_class)"
  elsif setter.respond_to? :varargs? and setter.varargs?
    coi = "*#{coi}"
  elsif coi.start_with? "#<"
    #      puts "ignoring #{setting}(#{coi})
    #        How about #{setting}(RubyWrapperBeanAdapter.coerce(#{value.inspect}, #{ty})) ?#

    #      "
    coi = "RubyWrapperBeanAdapter.coerce(#{value.inspect}, #{ty.ruby_class}.java_class)"
  end
  return coi
end

.mapperObject



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/fxmlloader/rrba.rb', line 219

def self.mapper
  unless @@mapper
    dir = ->(x){x}
    to_x = ->(x){->(o){o.send(x)}}
    to_dbl = ->(x){java.lang.Double.valueOf(x.to_s)}
    to_bool = ->(x){java.lang.Boolean.valueOf(x.to_s)}
    value_of = ->(x, type){type.ruby_class.valueOf(x.to_s)}
    # TODO: Java::double[].java_class.component_type
    @@mapper = {
      [String, java.lang.String.java_class] => dir,
      [Fixnum, java.lang.Integer.java_class] => dir,
      [Float, java.lang.Double.java_class] => dir,
      [Float, Java::double.java_class] => dir,
      [FalseClass, Java::boolean.java_class] => dir,
      [TrueClass, Java::boolean.java_class] => dir,
      [String, Java::double.java_class] => to_dbl,
      [String, java.lang.Double.java_class] => to_dbl,
      [String, Java::int.java_class] => to_x.call(:to_i),
      [String,java.lang.Integer.java_class] => to_x.call(:to_i),
      [String, Java::boolean.java_class] => to_bool,
      [String, Java::javafx.scene.paint.Paint.java_class] => value_of,
      [String, Java::javafx.scene.paint.Color.java_class] => value_of,
      [String, Java::java.lang.Object.java_class] => dir,
      [String, Java::double[].java_class] => ->(x){x.split(/[, ]+/).map(&:to_f)}
    }
  end
  @@mapper
end

.put3(target, sourceType, key, value) ⇒ Object

/**

* Invokes a static setter method for the given property. If the value is
* <tt>nil</tt> or there is no explicit setter for a given type, the
* {@link #coerce(Object, Class)end method is used to attempt to convert the
* value to the actual property type (defined by the return value of the
* getter method).
*
* @param target
* The object to which the property is or will be attached.
*
* @param sourceType
* The class that defines the property.
*
* @param key
* The property name.
*
* @param value
* The property.new value.
*
* @throws PropertyNotFoundException
* If the given static property does not exist or is read-only.
*/


352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/fxmlloader/rrba.rb', line 352

def self.put3(target,  sourceType, key, value)
  targetType = nil
  if target.respond_to? :java_class
    targetType = target.java_class();
  elsif target.is_a? String
    targetType = java.lang.String.java_class
  else
    raise "Shoots!"
  end

  setterMethod = nil;
  if (value != nil)
    valueClass = nil

    if value.respond_to? :java_class
      valueClass = value.java_class();
    elsif value.is_a? String
      valueClass = java.lang.String.java_class
    else
      raise "Shoots TWICE!"
    end
    setterMethod = getStaticSetterMethod(sourceType, key, valueClass, targetType);
  end

  if (setterMethod == nil)
    # Get the property type and attempt to coerce the value to it
    propertyType = getType(sourceType, key, targetType);

    if (propertyType != nil)
      setterMethod = getStaticSetterMethod(sourceType, key, propertyType, targetType);
      value = coerce(value, propertyType);
    end
  end

  if (setterMethod == nil)
    raise PropertyNotFoundException.new("Static property \"" + key + "\" does not exist"                + " or is read-only.");
  end

  # Invoke the setter
  begin
    rputs target, "#{sourceType.ruby_class.inspect}.set#{key[0].upcase}#{key[1..-1]}(self, #{jit_export(value, value, targetType, key, "#{sourceType.ruby_class.inspect}.#{key}=")})"
    getStaticSetterMethod(sourceType, key, valueClass, targetType, true).call(target.java_object, value);
  rescue InvocationTargetException => exception
    raise "RuntimeException.new(exception);"
  rescue IllegalAccessException => exception
    raise " RuntimeException.new(exception);"
  end
end

.toAllCaps(value) ⇒ Object



741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# File 'lib/fxmlloader/rrba.rb', line 741

def  self.toAllCaps(value)
  if (value == nil)

    raise "NULL PTR"
  end

  allCapsBuilder = Java.java.lang.StringBuilder.new();

  value.length.times do |i|
    c = value[(i)];

    if (c.upcase == c)
      allCapsBuilder.append('_');
    end

    allCapsBuilder.append(c.upcase);
  end

  return allCapsBuilder.toString();
end

Instance Method Details

#[](key) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/fxmlloader/rrba.rb', line 123

def [](key)
  key = key.to_s
  begin
    unless key.end_with?(PROPERTY_SUFFIX)
      camel = camelize(key)
      unless !@bean.respond_to?(GET_PREFIX + camel) and @bean.respond_to?(IS_PREFIX + camel)
        @bean.send(GET_PREFIX + camel)
      else
        @bean.send(IS_PREFIX + camel)
      end
    else
      @bean.send key
    end
  rescue NoMethodError => nme
    raise unless nme.name.to_s.end_with?(key)
    puts "failing on #{key}"
#      p @bean
#      p @bean.class
#      puts caller
    nil
  end
end

#[]=(key, value) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fxmlloader/rrba.rb', line 146

def []=(key, value)
  raise "NULL PTR" unless key

  setter = method_name(SET_PREFIX, key)

  raise "Property \"#{key}\" does not exist or is read-only." unless @bean.respond_to? setter
  ty = getType(key)
  co = coerce(value, ty)
  coi = RubyWrapperBeanAdapter.jit_export(co, value, ty, setter(key))
  rputs @bean, "#{setter}(#{coi})"
  if coi.start_with?("*[") # cheap way to not compute it twice :D
    @bean.send(setter, *co)
  else
    @bean.send(setter, co)
  end
  co
end

#build_cache_for(type) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fxmlloader/rrba.rb', line 70

def build_cache_for(type)
  class_methods = {}

  ReflectUtil.checkPackageAccess(type) # TODO: do I want this ?

  java_methods = type.declared_instance_methods.each do |method|
    modifiers = method.modifiers
    if Modifier.public?(modifiers) && !Modifier.static?(modifiers)
      name = method.name
      unless class_methods.has_key? name
        class_methods[name] = []
      else
        class_methods[name]
      end << method
    end
  end

  @@method_cache[type] = class_methods
  return java_methods
end

#camelize(key) ⇒ Object



119
120
121
# File 'lib/fxmlloader/rrba.rb', line 119

def camelize(key)
  key[0].upcase + key[1..-1]
end

#coerce(value, type) ⇒ Object



190
191
192
# File 'lib/fxmlloader/rrba.rb', line 190

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

#getGenericTypeObject

Raises:

  • (ArgumentError)


188
189
190
191
192
193
194
195
196
# File 'lib/fxmlloader/rrba.rb', line 188

def getType(key)
  raise ArgumentError.new unless key
  if @bean.respond_to? "#{key}GetType" # ruby type support ;-D
    @bean.send("#{key}GetType")
  else
    getter = getter(key)
    getter && getter.return_type
  end
end

#getMethod(name, *parameter_types) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fxmlloader/rrba.rb', line 91

def getMethod(name, *parameter_types)
  type = @bean.java_class
  while type != java.lang.Object.java_class
    if methods = (@@method_cache[type] || {})[name]
      methods.each do |method|
        return method if method.name == name && method.parameter_types == parameter_types
      end
    end
    type = type.superclass
  end
  return nil
end

#getPropertyModel(key) ⇒ Object

Raises:

  • (ArgumentError)


173
174
175
176
# File 'lib/fxmlloader/rrba.rb', line 173

def getPropertyModel(key)
  raise ArgumentError.new unless key
  self[key + PROPERTY_SUFFIX]
end

#getter(key) ⇒ Object



104
105
106
107
108
# File 'lib/fxmlloader/rrba.rb', line 104

def getter(key)
  capital = camelize(key)
  return getMethod(GET_PREFIX + capital) if @bean.respond_to?(GET_PREFIX + capital)
  return getMethod(IS_PREFIX + capital)
end

#getType(key) ⇒ Object

Raises:

  • (ArgumentError)


178
179
180
181
182
183
184
185
186
# File 'lib/fxmlloader/rrba.rb', line 178

def getType(key)
  raise ArgumentError.new unless key
  if @bean.respond_to? "#{key}GetType" # ruby type support ;-D
    @bean.send("#{key}GetType")
  else
    getter = getter(key)
    getter && getter.return_type
  end
end

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
167
# File 'lib/fxmlloader/rrba.rb', line 164

def has_key?(key)
  raise "NULL PTR" unless key
  getType(key.to_s)
end

#method_name(prefix, key) ⇒ Object



115
116
117
# File 'lib/fxmlloader/rrba.rb', line 115

def method_name(prefix, key)
  return prefix + camelize(key)
end

#read_only?(key) ⇒ Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/fxmlloader/rrba.rb', line 169

def read_only?(key)
  setter(key) == nil
end

#setter(key) ⇒ Object

Raises:

  • (java.lang.UnsupportedOperationException)


110
111
112
113
# File 'lib/fxmlloader/rrba.rb', line 110

def setter(key)
  raise java.lang.UnsupportedOperationException.new("Cannot determine type for property #{key}.") unless type = getType(key)
  return getMethod(method_name(SET_PREFIX, key), type)
end