Package ognl.helperfunction

Source Code of ognl.helperfunction.WOHelperFunctionAssociation

package ognl.helperfunction;

import com.webobjects.appserver.WOAssociation;
import com.webobjects.appserver._private.WOReadOnlyKeyValueAssociation;

/**
* Factory methods for creating WOAssociations (ripped from WOAssociation)
*
* @author mschrag
*/
public class WOHelperFunctionAssociation {
  private static boolean _keyPathIsReadOnly(String keyPath) {
    return keyPath.startsWith("@") || keyPath.indexOf(".@") > 0;
  }

  /**
   * Returns a WOAssociation with a value.
   *
   * @param obj the value
   * @return a corresponding WOAssociation
   */
  public static WOAssociation associationWithValue(Object obj) {
    return new WOHelperFunctionConstantValueAssociation(obj);
  }

  /**
   * Creates a WOAssociation with a keyPath.
   *
   * @param keyPath the keypath
   * @return a corresponding WOAssociation
   */
  public static WOAssociation associationWithKeyPath(String keyPath) {
    WOAssociation association;
    if (keyPath.charAt(0) == '^') {
      association = new WOHelperFunctionBindingNameAssociation(keyPath);
    }
    else if (_keyPathIsReadOnly(keyPath)) {
      association = new WOReadOnlyKeyValueAssociation(keyPath);
    }
    else {
      association = new WOHelperFunctionKeyValueAssociation(keyPath);
    }
    return association;
  }
}
TOP

Related Classes of ognl.helperfunction.WOHelperFunctionAssociation

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.