Package jfun.yan

Examples of jfun.yan.Binder


  }
  public Binder eval(){
    if(cases.isEmpty() && def==null){
      throw raise("empty " + getTagName());
    }
    return new Binder(){
      public Creator bind(Object v)
      throws Throwable{
        final int sz = cases.size();
        for(int i=0; i<sz; i++){
          final BinderCase bc = (BinderCase)cases.get(i);
View Full Code Here


  }

  public Component eval(){
    final Component p = getProps();
    final Component cc = getMandatory();
    Component result = p.bind(new Binder(){
      public Creator bind(Object v) throws Throwable {
        if(v==null) return cc;
        if(v instanceof java.util.Map){
          final java.util.Map m = (java.util.Map)v;
          final int sz = m.size();
View Full Code Here

  public Component eval(){
    final Component a = getArgs();
    final Component cc = getMandatory();
   
    Component result = a.bind(new Binder(){
      public Creator bind(Object v) throws Throwable {
        if(v==null) return cc;
        if(v.getClass().isArray()){
          final int sz = Array.getLength(v);
          final Component[] cargs = new Component[sz];
View Full Code Here

* Nov 12, 2005 7:09:29 PM
*/
public class SynchronizedNut extends DelegatingBinderNut {

  public Binder eval() throws Exception {
    final Binder binder = getMandatory();
    return new Binder(){
      public Creator bind(Object v)
      throws Throwable{
       synchronized(v){
         return binder.bind(v);
       }
      }
      public String toString(){
        return binder.toString();
      }
    };
  }
View Full Code Here

* @author Ben Yu
* Nov 12, 2005 11:59:27 PM
*/
public class ForeachNut extends DelegatingBinderNut {
  public Binder eval() throws Exception {
    final Binder binder = getMandatory();
    return new Binder(){
      public Creator bind(Object v)
      throws Throwable{
        if(v==null) return Components.value(null);
        final Creator[] steps = getNextSteps(v, binder);
        return Monad.sequence(steps);
View Full Code Here

      final Object key, final Class type) {
    if(the_map!=null){
      return performLookup(component_type, key, type);
    }
    else{
      return detect_map.bind(new Binder(){
        public Creator bind(Object m){
          if(m instanceof Map){
            the_map = (Map)m;
            return performLookup(component_type, key, type);
          }
View Full Code Here

        return null;
      }
    }, key);
  }
  private Binder getLazyBinder(){
    return new Binder(){
      public Creator bind(Object v) throws Throwable {
        final Object b = get();
        if(b instanceof Binder){
          return ((Binder)b).bind(v);
        }
View Full Code Here

    final Class param_type = param_types[0];
    final Class argtype = valc.getType();
    if(argtype!=null && !ReflectionUtil.isAssignableFrom(param_type, argtype)){
      return c;
    }
    return c.followedBy(new Binder(){
      public Creator bind(final Object obj){
        return valc.mutate(new Mutation(){
          public void mutate(Object arg) throws Exception {
            if(ReflectionUtil.isInstance(param_type, arg)){
              mtd.invoke(obj, new Object[]{arg});
View Full Code Here

TOP

Related Classes of jfun.yan.Binder

Copyright © 2018 www.massapicom. 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.