Package net.xoetrope.xui.data

Source Code of net.xoetrope.xui.data.XDataBindingFactory

package net.xoetrope.xui.data;

import java.util.Hashtable;
import net.xoetrope.xui.PageSupport;
import net.xoetrope.xui.evaluator.XDefaultAttributeEvaluator;
import net.xoetrope.xui.evaluator.XAttributeEvaluator;
import net.xoetrope.xui.XProject;

/**
* A factory for construction of data bindings
* <p>Copyright (c) Xoetrope Ltd., 1998-2003</p>
* $Revision: 2.3 $
*/
public abstract class XDataBindingFactory
  protected XAttributeEvaluator evaluator; 
  protected XProject currentProject;
 
  protected XDataBindingFactory( XProject project )
  {
    currentProject = project;
    evaluator = (XDefaultAttributeEvaluator)currentProject.getObject( "DefaultAttributeEvaluator" );
    if ( evaluator == null ) {
      evaluator = new XDefaultAttributeEvaluator( currentProject );
      evaluator.setCurrentProject( currentProject );
      currentProject.setObject( "DefaultAttributeEvaluator", evaluator );
    }
  }
 
  /**
   * Returns evaluated attribute
   * @param page the page that owns the binding and supplies the methods
   * referenced in the evaluated attributes
   * @param attributeValue name of the attribute to retrieve and evaluate
   * @return evaluated attribute
   */
  protected String getEvaluatedAttribute( PageSupport page, String attributeValue
  {
    String eval = null;
    if ( attributeValue != null ) {
      if ( evaluator != null )
        eval = evaluator.evaluateAttribute( page, attributeValue ).toString();
      else
        eval = page.evaluateAttribute( attributeValue ).toString();
    }
    return eval;
  }      
 
  /**
   * Try to get a binding factory to construct the binding
   * @param page the page that will own the binding
   * @param model the source data model
   * @param instanceConfig the XML element defining the binding
   * @return the new binding if one could be constructed
   */
  public abstract XDataBinding getBinding( PageSupport page, Object comp, Hashtable instanceConfig );
}
TOP

Related Classes of net.xoetrope.xui.data.XDataBindingFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.