







































Module('ca.carleton.gcrc.formula.math','$Revision: 3656 $',function(mod){






















mod.LiteralFactory=Class(function(publ,priv){




publ.__init__=function(
literalValue_
){


this.value=[literalValue_];
}







publ.Create=function(context_){
return this;
}




publ.Parent=function(){

}





publ.Values=function(){
return this.value;
}




publ.Terminate=function(){
}
});







mod.MathOperationFactory=Class(function(publ,priv){






publ.__init__=function(
operator_
,leftNodeFactory_
,rightNodeFactory_
){


this.operator=operator_;


this.leftNodeFactory=leftNodeFactory_;


this.rightNodeFactory=rightNodeFactory_;
}






publ.Create=function(context_){
var leftNode=this.leftNodeFactory.Create(context_);
var rightNode=this.rightNodeFactory.Create(context_);

var math=new mod.MathOperation(this.operator,leftNode,rightNode);

return math;
}
});







mod.MathOperation=Class(function(publ,priv){






publ.__init__=function(
operator_
,leftNode_
,rightNode_
){


this.operator=operator_;


this.leftNode=leftNode_;
this.leftNode.Parent(this);


this.rightNode=rightNode_;
this.rightNode.Parent(this);


this.parent=null;


this.value=[0];


this.Update();
}





publ.Parent=function(parent_){
this.parent=parent_;
}




publ.Values=function(){
return this.value;
}




publ.Update=function(){
var previousValue=this.value[0];


var leftValue=1*this.leftNode.Values()[0];
var rightValue=1*this.rightNode.Values()[0];


var newValue=0;
if('plus'==this.operator){
newValue=leftValue+rightValue;
}else if('minus'==this.operator){
newValue=leftValue-rightValue;
}else if('times'==this.operator){
newValue=leftValue*rightValue;
}else if('div'==this.operator){
if(0!=rightValue){
newValue=leftValue/rightValue;
}
}else if('mod'==this.operator){
if(0!=rightValue){
newValue=leftValue%rightValue;
}
}


if(previousValue!=newValue){
this.value[0]=newValue;
if(null!=this.parent){
this.parent.Update();
}
}
}




publ.Terminate=function(){
this.leftNode.Terminate();
this.rightNode.Terminate();
}
});







mod.RangingFactory=Class(function(publ,priv){





publ.__init__=function(
sourceNodeFactory_
,defaultValueFactory_
){


this.sourceNodeFactory=sourceNodeFactory_;


this.defaultNodeFactory=defaultValueFactory_;


this.ranges=new Array();
}




publ.AddRange=function(lowFactory_,highFactory_,valueFactory_){
this.ranges.push([lowFactory_,highFactory_,valueFactory_]);
}






publ.Create=function(context_){
var sourceNode=this.sourceNodeFactory.Create(context_);
var defaultNode=this.defaultNodeFactory.Create(context_);

var ranging=new mod.Ranging(sourceNode,defaultNode);

var ranges=this.ranges;
var loop;
for(loop=0;loop<ranges.length;++loop){
var lowNode=ranges[loop][0].Create(context_);
var highNode=ranges[loop][1].Create(context_);
var valueNode=ranges[loop][2].Create(context_);

ranging.AddRange(lowNode,highNode,valueNode);
}

ranging.Update();

return ranging;
}
});







mod.Ranging=Class(function(publ,priv){





publ.__init__=function(
sourceNode_
,defaultValue_
){


this.sourceNode=sourceNode_;


this.defaultNode=defaultValue_;


this.ranges=new Array();


this.parent=null;


this.value=[0];


this.sourceNode.Parent(this);
this.defaultNode.Parent(this);
}




publ.AddRange=function(low_,high_,value_){
this.ranges.push([low_,high_,value_]);
low_.Parent(this);
high_.Parent(this);
value_.Parent(this);
}





publ.Parent=function(parent_){
this.parent=parent_;
}




publ.Values=function(){
return this.value;
}




publ.Update=function(){

this._RecomputeValue();


if(null!=this.parent){
this.parent.Update();
}
}




publ.Terminate=function(){
var loop;
for(loop=0;loop<this.ranges.length;++loop){
this.ranges[loop][0].Terminate();
this.ranges[loop][1].Terminate();
this.ranges[loop][2].Terminate();
}
}




publ._RecomputeValue=function(){

var sourceValue=this.sourceNode.Values()[0];


var ranges=this.ranges;
var loop;
for(loop=0;loop<ranges.length;++loop){
var low=ranges[loop][0].Values()[0];
var high=ranges[loop][1].Values()[0];

if(sourceValue>=low&&sourceValue<=high){
this.value=ranges[loop][2].Values();
return;
}
}


this.value=this.defaultNode.Values();
}
});







mod.RowSelectorFactory=Class(function(publ,priv){




publ.__init__=function(
valueAttribute_
){

this.valueAttribute=valueAttribute_;

this.conditionFactories=new Array();
}





publ.AddRowCondition=function(rowConditionFactory_){
this.conditionFactories.push(rowConditionFactory_);
}






publ.Create=function(context_){
var selector=new mod.RowSelector(context_,this.valueAttribute);

var loop;
for(loop=0;loop<this.conditionFactories.length;++loop){
var condition=this.conditionFactories[loop].Create(context_);
selector.AddRowCondition(condition);
}

return selector;
}
});






mod.RowSelector=Class(function(publ,priv){





publ.__init__=function(
feature_
,valueAttribute_
){

this.feature=feature_;
this.valueAttribute=valueAttribute_;


this.conditions=new Array();


this.observingToken=feature_.AddObserver('add_atom',this,this.AddAtomCallback,null);


this.usefulAtoms=new Array();
var atoms=this.feature.Atoms();
var atomLoop;
for(atomLoop=0;atomLoop<atoms.length;++atomLoop){
this.AddAtom(atoms[atomLoop]);
}


this.value=[];
this.Update();
}





publ.Parent=function(parent_){
this.parent=parent_;
}




publ.Values=function(){
return this.value;
}




publ.Update=function(){

this._RecomputeValue();


if(null!=this.parent){
this.parent.Update();
}
}





publ._RecomputeValue=function(){

this.value=[];
var rowLoop;
for(rowLoop=0;rowLoop<this.usefulAtoms.length;++rowLoop){
var isEligible=true;


var condLoop;
for(condLoop=0;condLoop<this.conditions.length&&isEligible;++condLoop){
if(false==this.conditions[condLoop].IsRowEligible(this.usefulAtoms[rowLoop])){
isEligible=false;
}
}


if(true==isEligible){
this.value[this.value.length]=this.usefulAtoms[rowLoop].PropertyValueFromName(this.valueAttribute);
}
}


if(0==this.value.length){
this.value=[];
}
}





publ.AddAtomCallback=function(mvcEvent_){
var newAtom=mvcEvent_.data;

var isUseful=this.AddAtom(newAtom);


if(true==isUseful){
this.Update();
}
}






publ.AddAtom=function(atom_){

if(true==atom_.HasPropertyWithName(this.valueAttribute)){
this.usefulAtoms.push(atom_);
return true;
}

return false;
}






publ.AddRowCondition=function(condition_){
condition_.Parent(this);
this.conditions.push(condition_);
}




publ.Terminate=function(){
this.observingToken.RemoveObserver();
var loop;
for(loop=0;loop<this.conditions.length;++loop){
this.conditions[loop].Terminate();
}
}
});





mod.RowConditionFactory=Class(function(publ,priv){






publ.__init__=function(
condition_
,attribute_
,valueFactory_
){

this.condition=condition_;
this.attribute=attribute_;
this.valueFactory=valueFactory_;
}






publ.Create=function(context_){
var value=this.valueFactory.Create(context_);

var condition=new mod.RowCondition(this.condition,this.attribute,value);

return condition;
}
});






mod.RowCondition=Class(function(publ,priv){






publ.__init__=function(
condition_
,attribute_
,value_
){

this.condition=condition_;
this.attribute=attribute_;
this.valueNode=value_;


this.value=this.valueNode.Values();


this.valueNode.Parent(this);
}





publ.Parent=function(parent_){
this.parent=parent_;
}




publ.Update=function(){
this.value=this.valueNode.Values();


if(null!=this.parent){
this.parent.Update();
}
}







publ.IsRowEligible=function(row_){

if(false==row_.HasPropertyWithName(this.attribute)){
return false;
}


var comparedValue=row_.PropertyValueFromName(this.attribute);


if('equalTo'==this.condition){
return(comparedValue==this.value[0]);
}else if('lessThan'==this.condition){
return(comparedValue<this.value[0]);
}else if('greaterThan'==this.condition){
return(comparedValue>this.value[0]);
}
return false;
}




publ.Terminate=function(){
this.valueNode.Terminate();
}
});








mod.PercentFactory=Class(function(publ,priv){







publ.__init__=function(
model_
,sourceAttribute_
,dropCount_
,decimals_
){


this.model=model_;


this.sourceAttribute=sourceAttribute_;


this.percentNodes=new Array();


this.dropTopCount=dropCount_;


this.p100Value=1;


this.decimalCoeff=1;
var loop;
for(loop=0;loop<decimals_;++loop){
this.decimalCoeff=this.decimalCoeff*10;
}


this.changesObserved=false;
}






publ.Create=function(context_){
var percent=new mod.Percent(this.sourceAttribute,context_,this);
this.percentNodes.push(percent);
this.ChangesWereObserved();

return percent;
}





publ.ChangesWereObserved=function(){
this.changesObserved=true;
this.Recompute();
}






publ.Recompute=function(){
if(true==this.changesObserved){
if(this.model.busy){
var receiver=this;
this.model.RegisterForEndProcessing(function(){
receiver.Recompute();
});
}else{
this.changesObserved=false;

this.RecomputeAllDependents();
}
}
}





publ.RecomputeAllDependents=function(){

this.percentNodes.sort(function(a,b){
var aValue=1*a.rawValue;
var bValue=1*b.rawValue;
if(aValue>bValue)
return-1
if(aValue<bValue)
return 1
return 0
});


var p100=0;
var loop;
for(loop=0;loop<this.percentNodes.length;++loop){
if(loop>=this.dropTopCount){
var value=(1*this.percentNodes[loop].rawValue);
if(isNaN(value)){value=0;}
p100=p100+(value*1);
}
}


if(0==p100){
p100=1;
}


if(p100!=this.p100Value){
this.p100Value=p100;


this.model.StartProcessing();


var loop;
for(loop=0;loop<this.percentNodes.length;++loop){
if(loop>=this.dropTopCount){
var value=(1*this.percentNodes[loop].rawValue);
if(isNaN(value)){value=0;}
var percentValue=Math.floor((value*100*this.decimalCoeff)/p100)/this.decimalCoeff;
this.percentNodes[loop].UpdatedPercentValue(percentValue);
}else{
this.percentNodes[loop].UpdatedPercentValue(0);
}
}


this.model.EndProcessing();
}
}
});






mod.Percent=Class(function(publ,priv){






publ.__init__=function(
attribute_
,context_
,factory_
){


this.factory=factory_;


this.parent=null;


this.value=[0];


this.rawValue=context_.GetVariableValue(attribute_);


this.observingToken=context_.AddObserver(attribute_,this,this.Update,null);
}





publ.Parent=function(parent_){

this.parent=parent_;
}




publ.Values=function(){
return this.value;
}





publ.Update=function(mvcEvent_){
var feature=mvcEvent_.originator;
var attribute=mvcEvent_.type;
var rawValue=feature.GetVariableValue(attribute);
this.UpdatedRawValue(rawValue);
}





publ.UpdatedRawValue=function(rawValue_){
if(this.rawValue!=rawValue_){
this.rawValue=rawValue_;


this.factory.ChangesWereObserved();
}
}





publ.UpdatedPercentValue=function(percentValue_)
{
if(percentValue_!=this.value[0]){
this.value[0]=percentValue_;


if(null!=this.parent){
this.parent.Update();
}
}
}




publ.Terminate=function(){
this.observingToken.RemoveObserver();
}
});









mod.ClassifyFactory=Class(function(publ,priv){





publ.__init__=function(
type_
,attribute_
){


this.type=type_;


this.attribute=attribute_;


this.intervals=new Array();


this.classifyObjects=new Array();


this.maxRawValue=1;


this.minRawValue=0;
}






publ.Create=function(context_){
var classify=new mod.Classify(this,context_);

return classify;
}





publ.AddInterval=function(value_){
this.intervals.push(value_);
}








publ.ValueFromRawData=function(rawValue_){
if('equal-intervals'==this.type){

var objectCount=this.classifyObjects.length;
this.classifyObjects.sort(function(a,b){
var aValue=1*a.rawValue;
var bValue=1*b.rawValue;
if(aValue>bValue){
return-1;
}else if(aValue<bValue){
return 1;
}
return 0;
});
if(this.classifyObjects[0].rawValue!=this.maxRawValue
||this.classifyObjects[objectCount-1].rawValue!=this.minRawValue){

this.maxRawValue=this.classifyObjects[0].rawValue;
this.minRawValue=this.classifyObjects[objectCount-1].rawValue;


var intervalCount=this.intervals.length;
var loop;
for(loop=0;loop<this.classifyObjects.length;++loop){
var raw=this.classifyObjects[loop].rawValue;
var value=this.EqualIntervalValue(raw);
this.classifyObjects[loop].UpdatedValue(value);
}
}


return this.EqualIntervalValue(rawValue_);
}else{

return 0;
}
}







publ.EqualIntervalValue=function(rawValue_){
var intervalCount=this.intervals.length;

var index=0;
if(0!=(this.maxRawValue-this.minRawValue)){
index=Math.floor(((rawValue_-this.minRawValue)*intervalCount)/(this.maxRawValue-this.minRawValue));
}

if(index>=intervalCount){
index=intervalCount-1;
}
return this.intervals[index];
}
});






mod.Classify=Class(function(publ,priv){





publ.__init__=function(
factory_
,context_
){


this.factory=factory_;


this.parent=null;


this.value=[0];


this.rawValue='nogood';


this.observingToken=context_.AddObserver(this.factory.attribute,this,this.Update,null);


this.factory.classifyObjects.push(this);


this.UpdatedRawValue(context_.GetVariableValue(this.factory.attribute));
}





publ.Parent=function(parent_){

this.parent=parent_;
}




publ.Values=function(){
return this.value;
}





publ.Update=function(mvcEvent_){
var feature=mvcEvent_.originator;
var type=mvcEvent_.type;
var rawValue=feature.GetVariableValue(type);
this.UpdatedRawValue(rawValue);
}





publ.UpdatedRawValue=function(rawValue_){
if(this.rawValue!=rawValue_){
this.rawValue=rawValue_;


var value=this.factory.ValueFromRawData(rawValue_);

this.UpdatedValue(value);
}
}






publ.UpdatedValue=function(value_){

if(value_!=this.value[0]){
this.value[0]=value_;


if(null!=this.parent){
this.parent.Update();
}
}
}




publ.Terminate=function(){
this.observingToken.RemoveObserver();
}
});








mod.ValueOfFactory=Class(function(publ,priv){








publ.__init__=function(
layerNameFactory_
,featureNameFactory_
,variableNameFactory_
){


this.layerNameFactory=layerNameFactory_;


this.featureNameFactory=featureNameFactory_;


this.variableNameFactory=variableNameFactory_;
}






publ.Create=function(context_){

var layerNameNode=null;
if(null!=this.layerNameFactory){
layerNameNode=this.layerNameFactory.Create(context_);
}


var featureNameNode=null;
if(null!=this.featureNameFactory){
featureNameNode=this.featureNameFactory.Create(context_);
}


var attributeNameNode=this.variableNameFactory.Create(context_);


var copy=new mod.ValueOf(context_,layerNameNode,featureNameNode,attributeNameNode);

return copy;
}
});








mod.ValueOf=Class(function(publ,priv){






publ.__init__=function(
context_
,layerNameNode_
,featureNameNode_
,attributeNameNode_
){


this.context=context_;


this.currentLayerName=null;


this.layerNameNode=layerNameNode_;
if(null!=this.layerNameNode){

this.layerNameNode.Parent(this);
}


this.currentFeatureName=null;


this.featureNameNode=featureNameNode_;
if(null!=this.featureNameNode){

this.featureNameNode.Parent(this);
}


this.currentAttributeName=null;


this.attributeNameNode=attributeNameNode_;
if(null!=this.attributeNameNode){

this.attributeNameNode.Parent(this);
}


this.currentObservation=null;


this.currentFeature=null;


this.value=[];


this.Update();
}





publ.Parent=function(parent_){

this.parent=parent_;
}




publ.Values=function(){
return this.value;
}






publ.Update=function(){

var isNewObservationRequired=false;
var effectiveLayerName;
if(null!=this.layerNameNode){
effectiveLayerName=this.layerNameNode.Values()[0];
}else{
effectiveLayerName=this.context.layerModel.name;
}

var effectiveFeatureName;
if(null!=this.featureNameNode){
effectiveFeatureName=this.featureNameNode.Values()[0];
}else{
effectiveFeatureName=this.context.id;
}

var effectiveAttributeName=this.attributeNameNode.Values()[0];
if(effectiveLayerName!=this.currentLayerName){
isNewObservationRequired=true;
}else if(effectiveFeatureName!=this.currentFeatureName){
isNewObservationRequired=true;
}else if(effectiveAttributeName!=this.currentAttributeName){
isNewObservationRequired=true;
}


if(isNewObservationRequired){

if(null!=this.currentObservation){
this.currentObservation.RemoveObserver();
this.currentObservation=null;
}


this.currentLayerName=effectiveLayerName;
this.currentFeatureName=effectiveFeatureName;
this.currentAttributeName=effectiveAttributeName;

if(null!=effectiveLayerName&&null!=effectiveFeatureName){

var model=this.context.layerModel.mapModel;
var layer=model.LayerFromName(effectiveLayerName);
var feature=layer.FeatureFromId(effectiveFeatureName);


this.currentObservation=feature.AddObserver(effectiveAttributeName,this,this.UpdatedVariable,null);

this.currentFeature=feature;
}else{
this.currentFeature=null;
}
}


var previousValue=this.value.slice();
if(null!=this.currentFeature){
this.value=this.currentFeature.GetVariableArray(effectiveAttributeName);
}else{
this.value=[];
}


if(!previousValue.isEqual(this.value)){
if(null!=this.parent){
this.parent.Update();
}
}
}







publ.UpdatedVariable=function(mvcEvent_){
var previousValue=this.value.slice();

this.value=mvcEvent_.originator.GetVariableArray(mvcEvent_.type);


if(!previousValue.isEqual(this.value)){
if(null!=this.parent){
this.parent.Update();
}
}
}




publ.Terminate=function(){
if(null!=this.currentObservation){
this.currentObservation.RemoveObserver();
}
if(null!=this.layerNameNode){
this.layerNameNode.Terminate();
}
if(null!=this.featureNameNode){
this.featureNameNode.Terminate();
}
if(null!=this.attributeNameNode){
this.attributeNameNode.Terminate();
}
}
});









mod.ConditionalSelectionFactory=Class(function(publ,priv){




publ.__init__=function(
otherwiseValueFactory_
){


this.otherwiseValueFactory=otherwiseValueFactory_;


this.conditions=new Array();
}




publ.AddCondition=function(conditionFactory_,valueFactory_){
this.conditions.push([conditionFactory_,valueFactory_]);
}






publ.Create=function(context_){
var otherwiseValueNode=this.otherwiseValueFactory.Create(context_);

var conditionalSelection=new mod.ConditionalSelection(otherwiseValueNode);

var conditions=this.conditions;
var loop;
for(loop=0;loop<conditions.length;++loop){
var conditionNode=conditions[loop][0].Create(context_);
var valueNode=conditions[loop][1].Create(context_);

conditionalSelection.AddCondition(conditionNode,valueNode);
}

conditionalSelection.Update();

return conditionalSelection;
}
});








mod.ConditionalSelection=Class(function(publ,priv){




publ.__init__=function(
otherwiseValueNode_
){


this.otherwiseValueNode=otherwiseValueNode_;


this.conditions=new Array();


this.parent=null;


this.value=[0];


this.otherwiseValueNode.Parent(this);
}




publ.AddCondition=function(conditionNode_,valueNode_){
this.conditions.push([conditionNode_,valueNode_]);
conditionNode_.Parent(this);
valueNode_.Parent(this);
}





publ.Parent=function(parent_){
this.parent=parent_;
}




publ.Values=function(){
return this.value;
}




publ.Update=function(){
var previousValue=this.value[0];


this._RecomputeValue();


if(null!=this.parent&&previousValue!=this.value[0]){
this.parent.Update();
}
}




publ._RecomputeValue=function(){

for(var loop=0;loop<this.conditions.length;++loop){
if(this.conditions[loop][0].LogicalValue()){
this.value[0]=this.conditions[loop][1].Values()[0];
return;
}
}


this.value[0]=this.otherwiseValueNode.Values()[0];
}




publ.Terminate=function(){
for(var loop=0;loop<this.conditions.length;++loop){
this.conditions[loop][0].Terminate();
this.conditions[loop][1].Terminate();
}

this.otherwiseValueNode.Terminate();
}
});







mod.AttributeOnFeatureSelectFactory=Class(function(publ,priv){




publ.__init__=function(
layerName_
,featureName_
,attributeName_
,defaultValue_
){


this.layerName=layerName_;


this.featureName=featureName_;


this.attributeName=attributeName_;


this.defaultValue=defaultValue_;


this.instance=null;
}






publ.Create=function(context_){
if(null==this.instance){
this.instance=new mod.AttributeOnFeatureSelect(
context_,
this.layerName,
this.featureName,
this.attributeName,
this.defaultValue);
}
return this.instance;
}
});







mod.AttributeOnFeatureSelect=Class(function(publ,priv){








publ.__init__=function(
context_
,layerName_
,featureName_
,attributeName_
,defaultValue_
){


this.attributeName=attributeName_;


this.defaultValue=defaultValue_;


this.layer=context_.layerModel.mapModel.LayerFromName(layerName_);


this.feature=null;
if(null!=featureName_){
this.feature=this.layer.FeatureFromId(featureName_);


this.selectedToken=this.feature.AddObserver('selected',this,this.SelectedFeatureCallback,null);


if(null!=this.defaultValue){
this.displayToken=this.feature.AddObserver('display_state',this,this.DisplayStateFeatureCallback,null);
}
}else{
this.selectedToken=this.layer.AddObserver('selected',this,this.SelectedFeatureCallback,null);


if(null!=this.defaultValue){
this.displayToken=this.layer.AddObserver('display_state',this,this.DisplayStateFeatureCallback,null);
}
}


this.parents=new Array();


this.lastSelectedFeature=null;


if(null==this.defaultValue){
this.values=[];
}else{
this.values=[this.defaultValue];
}
}





publ.Parent=function(parent_){

this.parents.push(parent_);
}




publ.Values=function(){
return this.values;
}





publ.SelectedFeatureCallback=function(event_){
var feature=event_.originator;


this.lastSelectedFeature=feature;


var value=feature.GetVariableValue(this.attributeName);
this.SetValue(value);
}





publ.DisplayStateFeatureCallback=function(event_){
var feature=event_.originator;



if(null!=this.lastSelectedFeature){
if(this.lastSelectedFeature==feature){
if(false==feature.IsSelected()){
this.lastSelectedFeature=null;

this.SetValue(this.defaultValue);
}
}
}
}





publ.SetValue=function(value_){
if(1==this.values.length&&this.values[0]==value_){

}
if(0==this.values.length&&null==value_){

}

if(null==value_){
this.values=[];
}else{
this.values=[value_];
}


var loop;
for(loop=0;loop<this.parents.length;++loop){
var parent=this.parents[loop];
parent.Update();
}
}




publ.Terminate=function(){
if(null!=this.displayToken){
this.displayToken.RemoveObserver();
}
if(null!=this.selectedToken){
this.selectedToken .RemoveObserver();
}
}
});







mod.AttributeOnFeatureFocusFactory=Class(function(publ,priv){






publ.__init__=function(
layerName_
,featureName_
,attributeName_
){


this.layerName=layerName_;


this.featureName=featureName_;


this.attributeName=attributeName_;


this.instance=null;
}






publ.Create=function(context_){
if(null==this.instance){
this.instance=new mod.AttributeOnFeatureFocus(
context_,
this.layerName,
this.featureName,
this.attributeName);
}
return this.instance;
}
});








mod.AttributeOnFeatureFocus=Class(function(publ,priv){






publ.__init__=function(
context_
,layerName_
,featureName_
,attributeName_
){


this.attributeName=attributeName_;


this.layer=context_.layerModel.mapModel.LayerFromName(layerName_);


this.feature=null;
if(null!=featureName_){
this.feature=this.layer.FeatureFromId(featureName_);


this.displayToken=this.feature.AddObserver('display_state',this,this.DisplayStateChangedOnFeature,null);
}else{
this.displayToken=this.layer.AddObserver('display_state',this,this.DisplayStateChangedOnFeature,null);
}


this.parents=new Array();


this.value=[null];
}





publ.Parent=function(parent_){

this.parents.push(parent_);
}




publ.Values=function(){
return this.value;
}





publ.DisplayStateChangedOnFeature=function(event_){
var feature=event_.originator;


if(feature.IsInFocus()){

this.value=feature.GetVariableArray(this.attributeName);


var loop;
for(loop=0;loop<this.parents.length;++loop){
var parent=this.parents[loop];
parent.Update();
}
}
}




publ.Terminate=function(){
if(null!=this.displayToken){
this.displayToken.RemoveObserver();
}
}
});





mod.ConcatenateFactory=Class(function(publ,priv){



publ.__init__=function(
){


this.childFactories=new Array();
}





publ.Add=function(childFactory_){
this.childFactories.push(childFactory_);
}






publ.Create=function(context_){

var children=new Array();
var loop;
for(loop=0;loop<this.childFactories.length;++loop){
var child=this.childFactories[loop].Create(context_);
children.push(child);
}

return new mod.Concatenate(children);
}
});
















mod.Concatenate=Class(function(publ,priv){




publ.__init__=function(
children_
){


this.children=children_;


this.parent=null;


this.value=[''];


var loop;
for(loop=0;loop<this.children.length;++loop){
this.children[loop].Parent(this);
}


this.Update();
}





publ.Parent=function(parent_){

this.parent=parent_;
}




publ.Values=function(){
return this.value;
}




publ.Update=function(){

var previousValue=this.value[0];


this.value[0]='';
var loop;
for(loop=0;loop<this.children.length;++loop){
this.value[0]+=this.children[loop].Values()[0];
}


if(previousValue!=this.value[0]){
if(null!=this.parent){
this.parent.Update();
}
}
}




publ.Terminate=function(){
var loop;
for(loop=0;loop<this.children.length;++loop){
this.children[loop].Terminate();
}
}
});


var serverFileUrl=null;
mod.SetServerFileUrl=function(url_){
serverFileUrl=url_;
}





mod.ServerFileFactory=Class(function(publ,priv){



publ.__init__=function(
){

this.childFactory=null;
}





publ.Add=function(childFactory_){
this.childFactory=childFactory_;
}






publ.Create=function(context_){

var childNode=null;
if(null!=this.childFactory){
childNode=this.childFactory.Create(context_);
}

return new mod.ServerFile(serverFileUrl,childNode);
}
});







mod.ServerFile=Class(function(publ,priv){





publ.__init__=function(
proxyUrl_
,child_
){

this.proxyUrl=proxyUrl_;


this.child=child_;


this.parent=null;


this.value=[];


this.child.Parent(this);


this.Update();
}





publ.Parent=function(parent_){
this.parent=parent_;
}




publ.Values=function(){
return this.value;
}




publ.Update=function(){

var previousValue=this.value.slice();


this.value=new Array();
var childArray=this.child.Values();
for(var loop=0;loop<childArray.length;++loop){
this.value.push(this.proxyUrl+childArray[loop]);
}


if(false==previousValue.isEqual(this.value)){
if(null!=this.parent){
this.parent.Update();
}
}
}




publ.Terminate=function(){
this.child.Terminate();
}
});
});

