/**
 * Generated by Apache Royale Compiler from org\apache\royale\html\supportClasses\NestedStringItemRenderer.as
 * org.apache.royale.html.supportClasses.NestedStringItemRenderer
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.html.supportClasses.NestedStringItemRenderer');

goog.require('org.apache.royale.html.supportClasses.StringItemRenderer');
goog.require('org.apache.royale.utils.Language');



/**
 * Constructor
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @constructor
 * @extends {org.apache.royale.html.supportClasses.StringItemRenderer}
 */
org.apache.royale.html.supportClasses.NestedStringItemRenderer = function() {
  org.apache.royale.html.supportClasses.NestedStringItemRenderer.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.supportClasses.NestedStringItemRenderer, org.apache.royale.html.supportClasses.StringItemRenderer);


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.html.supportClasses.NestedStringItemRenderer', org.apache.royale.html.supportClasses.NestedStringItemRenderer);


/**
 * Takes a labelField (or dataField) path (eg, "foo.bar.goo") and 
 * returns the value associated with it from the data property by
 * doing data[foo][bar][goo]. Returns null if the value cannot
 * be determined.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @export
 * @param {string} useField
 * @return {Object}
 */
org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.getValueFromField = function(useField) {
  var self = this;
  var /** @type {Function} */ __localFn0__ = function(object, index, array) {
    if (currentValue && currentValue.hasOwnProperty(object)) {
      currentValue = currentValue[object];
    } else {
      currentValue = null;
    }
  }
  if (this.data == null)
    return null;
  var /** @type {Object} */ currentValue = this.data;
  var /** @type {Function} */ fn = __localFn0__;
  var /** @type {Array} */ path = useField.split(".");
  path.forEach(fn, this);
  return currentValue;
};


/**
 * @private
 * @type {Object}
 */
org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.org_apache_royale_html_supportClasses_NestedStringItemRenderer__data;


org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.get__data = function() {
  return this.org_apache_royale_html_supportClasses_NestedStringItemRenderer__data;
};


org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.set__data = function(value) {
  this.org_apache_royale_html_supportClasses_NestedStringItemRenderer__data = value;
  var /** @type {string} */ text;
  if (org.apache.royale.utils.Language.is(value, String))
    text = org.apache.royale.utils.Language.as(value, String);
  else if (this.labelField)
    text = String(this.getValueFromField(this.labelField));
  else if (this.dataField)
    text = String(this.getValueFromField(this.dataField));
  else
    text = String(value);
  this.text = text;
};


Object.defineProperties(org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype, /** @lends {org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype} */ {
/**
  * @export
  * @type {Object} */
data: {
get: org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.get__data,
set: org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.set__data}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'NestedStringItemRenderer', qName: 'org.apache.royale.html.supportClasses.NestedStringItemRenderer', kind: 'class' }] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.supportClasses.NestedStringItemRenderer.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'data': { type: 'Object', access: 'readwrite', declaredBy: 'org.apache.royale.html.supportClasses.NestedStringItemRenderer'}
      };
    },
    methods: function () {
      return {
        'NestedStringItemRenderer': { type: '', declaredBy: 'org.apache.royale.html.supportClasses.NestedStringItemRenderer'},
        'getValueFromField': { type: 'Object', declaredBy: 'org.apache.royale.html.supportClasses.NestedStringItemRenderer', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }}
      };
    }
  };
};