Class: CopyElement

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

Overview

Element representing a copy

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, #initialize, #isBidirectionalBindingExpression, #isBindingExpression, #isCollection, #isTyped, #populateArrayFromString, #populateListFromString, #processCharacters, #processEndElement, #processEventHandlerAttributes, #processInstancePropertyAttributes, #processPropertyAttribute, #processStartElement, #processValue3, #resolvePrefixedValue, #set, #staticLoad, #updateValue, #warnDeprecatedEscapeSequence

Constructor Details

This class inherits a constructor from Element

Instance Attribute Details

#sourceObject

Returns the value of attribute source


317
318
319
# File 'lib/fxmlloader/real_elts.rb', line 317

def source
  @source
end

Instance Method Details

#constructValueObject


337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/fxmlloader/real_elts.rb', line 337

def constructValue()
  if (source == nil)
    raise LoadException.new(FXL::COPY_SOURCE_ATTRIBUTE + " is required.");
  end

  path = KeyPath.parse(source);
  if (!Expression.isDefined(namespace, path))
    raise LoadException.new("Value \"" + source + "\" does not exist.");
  end

  sourceValue = Expression.get(namespace, path);
  sourceValueType = sourceValue.java_class();

  constructor = nil;
  begin
    constructor = ConstructorUtil.getConstructor(sourceValueType, [sourceValueType]);
  rescue NoSuchMethodException => exception
    # No-op
  end

  value=nil
  if (constructor != nil)
    begin
      #TODO: try to do evil things here
      ReflectUtil.checkPackageAccess(sourceValueType);
      value = constructor.newInstance(sourceValue);
    rescue InstantiationException => exception
      raise LoadException.new(exception);
    rescue IllegalAccessException => exception
      raise LoadException.new(exception);
    rescue InvocationTargetException => exception
      raise LoadException.new(exception);
    end
  else
    raise LoadException.new("Can't copy value " + sourceValue + ".");
  end

  return value;
end

#processAttribute(prefix, localName, value) ⇒ Object


320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/fxmlloader/real_elts.rb', line 320

def processAttribute(prefix,  localName,  value)

  if (prefix == nil)
    if (localName == (FXL::COPY_SOURCE_ATTRIBUTE))
      if (loadListener != nil)
        loadListener.readInternalAttribute(localName, value);
      end

      @source = value;
    else
      super(prefix, localName, value);
    end
  else
    super(prefix, localName, value);
  end
end