// created: 23.11.00
// modified: 28.12.00
 
/*************************************/
/* class MultiAttributeValueFunction */
/*************************************/

class MultiAttributeValueFunction
 {

 ValueFunction [] functions = null;
 int [] functionWeights = null; 

 /***************/
 /* constructor */
 /***************/ 

 //MultiAttributeValueFunction()
  //{
  //functions = new ValueFunction [3];
  //functionWeights = new float [3];
  //functions[0] = new CountValueFunction();
  //functions[1] = new CountValueFunction();
  //functions[2] = new ExistValueFunction();
  //for (int i=0; i<functionWeights.length; i++)
  // {
  // functionWeights[i] = 0.0f;
  // }  
  //}

 MultiAttributeValueFunction(ValueFunction [] funcs)
  {
  functions = funcs;
  functionWeights = new int [funcs.length];
  for (int i=0; i<functionWeights.length; i++)
   {
   functionWeights[i] = 0;
   }  
  }

 /*******************/
 /* method evaluate */ 
 /*************************************************************************/
 /* this takes a WebPage object and works out the value of the page given */
 /* the weights corresponding to the URLs attributes                      */
 /*************************************************************************/

 float evaluate(Object [] theAttributes)//WebPage page)//, MaxAttribute maxAtts)
  {
  float result = 0.0f;
  for (int n=0; n<functions.length; n++)
   {
   if (n < theAttributes.length)
     {
     float val = (new Integer(functionWeights[n])).floatValue() * functions[n].evaluate(theAttributes[n]);
     /****/
     System.out.println("-value of function = "+String.valueOf(val));
     /****/
     result += val;
     }
   }
  return result;
  }

 /***************/
 /* set methods */
 /***************/

 void setValueFunction(int num, ValueFunction func)
  {
  if (num-1 < functions.length)
   functions[num-1] = func;
  }

 void setFunctionWeight(int num, int weight)
  {
  if (num-1 < functionWeights.length)
   functionWeights[num-1] = weight;
  }

 /***************/
 /* get methods */
 /***************/

 ValueFunction getValueFunction(int num)
  {
  if (num-1 < functions.length)
   return functions[num-1];
  else
   return null;
  }  

 }