package gw.rating.worksheet.domain uses java.lang.StringBuilder uses gw.xml.parser2.PLXMLNode uses gw.api.upgrade.Coercions /** * Represents the execution of an expression with an assignment to a new or existing variable * */ class WorksheetCalculation extends WorksheetEntryWithResult{ var _storeLocation : String as StoreLocation var _storeObjectType : String as StoreObjectType var _storeObjectName : String as StoreObjectName var _storePropertyName : String as StorePropertyName var _declaration : boolean as VariableDeclaration override function pseudoCode(buffer : StringBuilder, includeValues : boolean) { if (_declaration) { buffer.append("var ") } if (_storeObjectName.HasContent) { buffer.append("${_storeObjectName}.${_storePropertyName}") } else { buffer.append("${_storeLocation}") } if (includeValues) { buffer.append("<${Result}>") } if (VariableDeclaration) { buffer.append(" : ${Result.Class.SimpleName}") } buffer.append(" = ") WorksheetOperands.each(\ o -> o.pseudoCode(buffer, includeValues) ) } override function toXml() : PLXMLNode { var node = new PLXMLNode(_storeObjectName.HasContent ? "PropertySet" : "Store") if (_declaration) { node.setAttributeValue("Declaration", _declaration as String) } if(_storeLocation.HasContent){ node.setAttributeValue("Variable", _storeLocation) } if(_storeObjectName.HasContent){ node.setAttributeValue("ObjectName", _storeObjectName) } if (_storeObjectType.HasContent) { node.setAttributeValue("ObjectType", _storeObjectType) } if(_storePropertyName.HasContent){ node.setAttributeValue("PropertyName", _storePropertyName) } writeXml(node) return node } override function fromXml(node: PLXMLNode) { _storeLocation = node.getAttributeValue("Variable") _declaration = Coercions.makeBooleanFrom(node.getAttributeValue("Declaration") ?: false) _storeObjectType = node.getAttributeValue("ObjectType") _storeObjectName = node.getAttributeValue("ObjectName") _storePropertyName = node.getAttributeValue("PropertyName") readXml(node) } override property get WorksheetClass(): String { return "Calculation" } }