Class: InstanceDeclarationElement

Inherits:
ValueElement show all
Defined in:
lib/fxmlloader/real_elts.rb

Instance Attribute Summary collapse

Attributes inherited from ValueElement

#fx_id

Attributes inherited from Element

#current, #eventHandlerAttributes, #instancePropertyAttributes, #lineNumber, #loadListener, #parent, #parentLoader, #staticPropertyAttributes, #staticPropertyElements, #value, #valueAdapter, #xmlStreamReader

Instance Method Summary collapse

Methods inherited from ValueElement

#getListValue, #processCharacters, #processEndElement, #processStartElement, #processValue

Methods inherited from Element

#add, #addEventHandler, #applyProperty, #callz, #getProperties, #getValueAdapter, #isBidirectionalBindingExpression, #isBindingExpression, #isCollection, #isTyped, #populateArrayFromString, #populateListFromString, #processCharacters, #processEndElement, #processEventHandlerAttributes, #processInstancePropertyAttributes, #processPropertyAttribute, #processStartElement, #processValue3, #resolvePrefixedValue, #set, #staticLoad, #updateValue, #warnDeprecatedEscapeSequence

Constructor Details

#initialize(current, xmlStreamReader, loadListener, parentLoader, type) ⇒ InstanceDeclarationElement

Returns a new instance of InstanceDeclarationElement.


57
58
59
60
61
62
# File 'lib/fxmlloader/real_elts.rb', line 57

def initialize(current, xmlStreamReader, loadListener, parentLoader, type)
  super(current, xmlStreamReader, loadListener, parentLoader)
  @type = type;
  @constant = nil;
  @factory = nil;
end

Instance Attribute Details

#constantObject

Returns the value of attribute constant


55
56
57
# File 'lib/fxmlloader/real_elts.rb', line 55

def constant
  @constant
end

#factoryObject

Returns the value of attribute factory


55
56
57
# File 'lib/fxmlloader/real_elts.rb', line 55

def factory
  @factory
end

#typeObject

Returns the value of attribute type


55
56
57
# File 'lib/fxmlloader/real_elts.rb', line 55

def type
  @type
end

Instance Method Details

#constructValueObject


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/fxmlloader/real_elts.rb', line 80

def constructValue()
  value = nil
  if (@value != nil)
    value = RubyWrapperBeanAdapter.coerce(@value, type);
  elsif (constant != nil)
    value = RubyWrapperBeanAdapter.getConstantValue(type, constant);
  elsif (factory != nil)
    factoryMethod = nil
    begin
      factoryMethod = MethodUtil.getMethod(type, factory, []);
    rescue NoSuchMethodException => exception
      raise LoadException.new(exception);
    end

    begin
      value = MethodUtil.invoke(factoryMethod, nil, []);
    rescue IllegalAccessException => exception
      raise LoadException.new(exception);
    rescue InvocationTargetException => exception
      raise LoadException.new(exception);
    end
  else
    value = (parentLoader.builderFactory == nil) ? nil : parentLoader.builderFactory.getBuilder(type);
    if (value.is_a? Builder or (value.respond_to?(:java_object) && value.java_object.is_a?(Builder)))
      begin
        value.size
      rescue java.lang.UnsupportedOperationException => ex
        dputs "########################## WARNING #############################3"
        value = OBJFXBuilderWrapper.new(value, type)
        value.on_put {|k, v| rctor value, k, v }
      end
    end
    if (value == nil)
      begin
        #TODO: does this work?
        value = type.ruby_class.new
      rescue InstantiationException => exception
        raise LoadException.new(exception);
      rescue IllegalAccessException => exception
        raise LoadException.new(exception);
      end
    else
   end
  end
  if factory
    rputs value, "build(FactoryBuilderBuilder, #{type.ruby_class}, #{factory.inspect}) do"
  elsif @value
    rno_show(value)
    rputs value, value.inspect
  else
    rputs value, "build(#{type.ruby_class}) do"
  end
  rnest 1
  return value;
end

#processAttribute(prefix, localName, value) ⇒ Object


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fxmlloader/real_elts.rb', line 64

def processAttribute( prefix,  localName,  value)
  if (prefix != nil				&& prefix == (FXL::FX_NAMESPACE_PREFIX))
    if (localName == (FXL::FX_VALUE_ATTRIBUTE))
      @value = value;
    elsif (localName == (FXL::FX_CONSTANT_ATTRIBUTE))
      @constant = value;
    elsif (localName == (FXL::FX_FACTORY_ATTRIBUTE))
      @factory = value;
    else
      super(prefix, localName, value);
    end
  else
    super(prefix, localName, value);
  end
end