📄 fieldaccessor.as
字号:
} // end else if
}
else
{
_global.__dataLogger.logData(this.component, "Error: path \'<path>\' is an XPath. It cannot be applied to non-XML data <t.property>:<t.m_location>", {path: path, t: this});
} // end else if
return (obj);
} // End of the function
function getFieldData()
{
if (xpath != null)
{
for (var _loc4 = parentObj[fieldName].firstChild; _loc4 != null && _loc4.nodeType != 1; _loc4 = _loc4.nextSibling)
{
} // end of for
var _loc10 = mx.xpath.XPathAPI.selectSingleNode(_loc4, xpath);
return (_loc10);
}
else if (this.isXML(parentObj))
{
if (type.path != null)
{
return (this.evaluateSubPath(parentObj, type));
} // end if
if (type.category == "attribute")
{
var _loc5 = parentObj.attributes;
for (var _loc8 in _loc5)
{
if (mx.data.binding.FieldAccessor.toLocalName(_loc8) == fieldName)
{
return (_loc5[_loc8]);
} // end if
} // end of for...in
return;
}
else
{
var _loc3 = parentObj.firstChild;
if (type.category == "array")
{
var _loc6 = new Array();
while (_loc3 != null)
{
if (mx.data.binding.FieldAccessor.toLocalName(_loc3.nodeName) == fieldName)
{
_loc6.push(_loc3);
} // end if
_loc3 = _loc3.nextSibling;
} // end while
return (_loc6);
}
else
{
while (_loc3 != null)
{
if (mx.data.binding.FieldAccessor.toLocalName(_loc3.nodeName) == fieldName)
{
return (_loc3);
} // end if
_loc3 = _loc3.nextSibling;
} // end while
} // end else if
return (null);
} // end else if
}
else if (fieldName == "[n]")
{
var _loc7;
if (index.component != null)
{
var _loc9 = index.component.getField(index.property, index.location);
_loc7 = _loc9.getAnyTypedValue(["Number"]);
_loc7 = _loc7.value;
}
else
{
_loc7 = index.constant;
} // end else if
var _loc11 = Number(_loc7);
if (typeof(_loc7) == "undefined")
{
_global.__dataLogger.logData(component, "Error: index specification \'<index>\' was not supplied, or incorrect, for <t.property>:<t.m_location>", {index: _loc11, t: this});
return (null);
}
else if (_loc11.toString() == "NaN")
{
_global.__dataLogger.logData(component, "Error: index value \'<index>\' for <t.property>:<t.m_location> is not a number", {index: _loc11, t: this});
return (null);
}
else if (!(parentObj instanceof Array))
{
_global.__dataLogger.logData(component, "Error: indexed field <property>:<m_location> is not an array", this);
return (null);
}
else if (_loc11 < 0 || _loc11 >= parentObj.length)
{
_global.__dataLogger.logData(component, "Error: index \'<index>\' for <t.property>:<t.m_location> is out of bounds", {index: _loc11, t: this});
return (null);
}
else
{
_global.__dataLogger.logData(component, "Accessing item [<index>] of <t.property>:<t.m_location>", {index: _loc11, t: this});
return (parentObj[_loc11]);
} // end else if
}
else
{
if (type.path != null)
{
return (this.evaluateSubPath(parentObj, type));
} // end if
return (parentObj[fieldName]);
} // end else if
} // End of the function
static function setXMLData(obj, newValue)
{
while (obj.hasChildNodes())
{
obj.firstChild.removeNode();
} // end while
var _loc2 = mx.data.binding.FieldAccessor.xmlNodeFactory.createTextNode(newValue);
obj.appendChild(_loc2);
} // End of the function
function setupComplexField()
{
var _loc2;
if (this.isXML(parentObj))
{
_loc2 = mx.data.binding.FieldAccessor.xmlNodeFactory.createElement(fieldName);
parentObj.appendChild(_loc2);
}
else if (this.dataIsXML())
{
parentObj[fieldName] = new XML();
}
else
{
parentObj[fieldName] = new Object();
} // end else if
} // End of the function
static function findElementType(type, name)
{
for (var _loc1 = 0; _loc1 < type.elements.length; ++_loc1)
{
if (type.elements[_loc1].name == name)
{
return (type.elements[_loc1].type);
} // end if
} // end of for
return (null);
} // End of the function
function isXML(obj)
{
return (obj instanceof XMLNode);
} // End of the function
function dataIsXML()
{
return (type.name == "XML");
} // End of the function
static function accessField(component, fieldName, desiredTypes)
{
var _loc1;
_loc1 = desiredTypes[fieldName];
if (_loc1 == null)
{
_loc1 = desiredTypes.dflt;
} // end if
if (_loc1 == null)
{
_loc1 = desiredTypes;
} // end if
var _loc4 = component.createField("data", [fieldName]);
var _loc2 = _loc4.getAnyTypedValue([_loc1]);
return (_loc2.value);
} // End of the function
static function ExpandRecord(obj, objectType, desiredTypes)
{
var _loc4 = new Object();
mx.data.binding.ComponentMixins.initComponent(_loc4);
_loc4.data = obj;
_loc4.__schema = {elements: [{name: "data", type: objectType}]};
var _loc2 = new Object();
if (objectType.elements.length > 0)
{
for (var _loc3 = 0; _loc3 < objectType.elements.length; ++_loc3)
{
var _loc10 = objectType.elements[_loc3].name;
_loc2[_loc10] = mx.data.binding.FieldAccessor.accessField(_loc4, _loc10, desiredTypes);
} // end of for
}
else if (obj instanceof XML || obj instanceof XMLNode)
{
if (obj.childNodes.length == 1 && obj.firstChild.nodeType == 3)
{
return (obj.firstChild.nodeValue);
} // end if
for (var _loc5 = obj.lastChild; _loc5 != null; _loc5 = _loc5.previousSibling)
{
_loc10 = mx.data.binding.FieldAccessor.toLocalName(_loc5.nodeName);
if (_loc10 != null && _loc2[_loc10] == null)
{
_loc2[_loc10] = mx.data.binding.FieldAccessor.accessField(_loc4, _loc10, desiredTypes);
} // end if
} // end of for
for (var _loc10 in obj.attributes)
{
if (_loc2[_loc10] != null)
{
_global.__dataLogger.logData(null, "Warning: attribute \'<name>\' has same name as an element, in XML object <obj>", {name: _loc10, obj: obj});
} // end if
_loc2[_loc10] = mx.data.binding.FieldAccessor.accessField(_loc4, _loc10, desiredTypes);
} // end of for...in
}
else
{
if (typeof(obj) != "object")
{
return (obj);
} // end if
for (var _loc10 in obj)
{
_loc2[_loc10] = mx.data.binding.FieldAccessor.accessField(_loc4, _loc10, desiredTypes);
} // end of for...in
} // end else if
return (_loc2);
} // End of the function
static function wrapArray(theArray, itemType, desiredTypes)
{
var _loc4 = {getItemAt: function (index)
{
if (index < 0 || index >= data.length)
{
return;
} // end if
var _loc2 = data[index];
if (_loc2 == undefined)
{
return;
} // end if
var _loc3 = mx.data.binding.FieldAccessor.ExpandRecord(_loc2, type, desiredTypes);
return (_loc3);
}, getItemID: function (index)
{
return (index);
}, data: theArray, type: itemType, length: theArray.length};
return (_loc4);
} // End of the function
static function toLocalName(nodeName)
{
var _loc1 = nodeName.split(":");
var _loc2 = _loc1[_loc1.length - 1];
return (_loc2);
} // End of the function
static var xmlNodeFactory = new XML();
} // End of Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -