1 package jfun.yan.xml.nuts.optional; 2 3 import java.util.Map ; 4 5 import jfun.util.Misc; 6 import jfun.yan.Component; 7 import jfun.yan.Components; 8 import jfun.yan.xml.nuts.DelegatingNut; 9 16 public class GetKeyNut extends DelegatingNut { 17 private Object key; 18 19 public Object getKey() { 20 return key; 21 } 22 23 public void setKey(Object key) { 24 this.key = key; 25 } 26 27 public Component eval(){ 28 final Component cc = getComponent(); 29 checkMandatory("key", key); 30 checkMandatory("component", cc); 31 final Class type = cc.getType(); 32 if(type!=null && 33 !jfun.yan.util.Utils.isCompatible(Map .class, cc) 34 ){ 35 throw raise("cannot call get against "+ 36 Misc.getTypeName(type)); 37 } 38 return Components.get(cc, key); 39 } 40 41 } 42 | Popular Tags |