Package railo.runtime.type.Collection

Examples of railo.runtime.type.Collection.Key


  private static Struct cfmlBasedFunction(PageContext pc, FunctionLibFunction function) throws PageException {
    Struct sct=new StructImpl();
    ArrayList<FunctionLibFunctionArg> args = function.getArg();
   
    String filename = Caster.toString(args.get(0).getDefaultValue());
    Key name = KeyImpl.toKey(args.get(1).getDefaultValue());
    boolean isWeb = Caster.toBooleanValue(args.get(2).getDefaultValue());
    UDF udf = CFFunction.loadUDF(pc, filename, name, isWeb);
   
    sct.set(KeyConstants._name,function.getName());
        sct.set(ARGUMENT_TYPE,"fixed");
View Full Code Here


    this.access=access;
  }

  @Override
  public Object next() {
    Key key = keys[pos++];
    if(key==null) return null;
    return cfc.get(access,key,null);
  }
View Full Code Here

    this.access=access;
  }

  @Override
  public Entry<Key, Object> next() {
    Key key = keys[pos++];
    if(key==null) return null;
    return new CAEntryImpl(cfc,key,access);
  }
View Full Code Here

      value=Caster.unwrap(value,value);
     
      if(value instanceof Argument) {
        Argument argColl=(Argument) value;
        Iterator<Key> it = argColl.keyIterator();
        Key k;
        int i=-1;
          while(it.hasNext()) {
            i++;
            k = it.next();
            if(funcArgs.length>i && k instanceof ArgumentIntKey) {
                  if(!values.containsKey(funcArgs[i].getName()))
                    values.setEL(funcArgs[i].getName(),argColl.get(k,Argument.NULL));
                  else
                    values.setEL(k,argColl.get(k,Argument.NULL));
            }
                else if(!values.containsKey(k)){
                  values.setEL(k,argColl.get(k,Argument.NULL));
                }
              }
        }
      else if(value instanceof Collection) {
            Collection argColl=(Collection) value;
          //Collection.Key[] keys = argColl.keys();
        Iterator<Key> it = argColl.keyIterator();
        Key k;
        while(it.hasNext()) {
            k = it.next();
            if(!values.containsKey(k)){
                  values.setEL(k,argColl.get(k,Argument.NULL));
                }
              }
        }
      else if(value instanceof Map) {
        Map map=(Map) value;
          Iterator it = map.entrySet().iterator();
          Map.Entry entry;
          Key key;
          while(it.hasNext()) {
            entry=(Entry) it.next();
            key = Caster.toKey(entry.getKey(),null);
            if(!values.containsKey(key)){
                  values.setEL(key,entry.getValue());
                }
              }
        }
      else if(value instanceof java.util.List) {
        java.util.List list=(java.util.List) value;
          Iterator it = list.iterator();
          Object v;
          int index=0;
          Key k;
          while(it.hasNext()) {
            v= it.next();
            k=ArgumentIntKey.init(++index);
            if(!values.containsKey(k)){
                  values.setEL(k,v);
View Full Code Here

  private static final long serialVersionUID = -3345605395096765821L;

  public static String call(PageContext pc) {
    PageContextImpl pci=(PageContextImpl) pc;
    Key name = pci.getActiveUDFCalledName();
    if(name!=null) return name.getString();
   
    UDF[] udfs = ((PageContextImpl)pc).getUDFs();
    if(udfs.length==0) return "";
    return udfs[udfs.length-1].getFunctionName();
  }
View Full Code Here

     * @throws PageException
     */
    private static boolean getValues(PageContext pc,Array array,Collection coll, String value, boolean all, String path) throws PageException {
        //Key[] keys = coll.keys();
        boolean abort=false;
        Key key;
        Iterator<Entry<Key, Object>> it = coll.entryIterator();
        Entry<Key, Object> e;
        loop:while(it.hasNext()) {
          e = it.next();
            if(abort)break loop;
            key=e.getKey();
            Object o=e.getValue();
           
            // Collection (this function search first for sub)
            if(o instanceof Collection) {
                abort=getValues(pc,array,((Collection)o), value, all, StructFindKey.createKey(coll, path, key));
               
            }
            // matching value
            if(!abort && !StructFindKey.isArray(coll)){
            String target=Caster.toString(o,null);
            if((target!=null && target.equalsIgnoreCase(value)) /*|| (o instanceof Array && checkSub(array,((Array)o),value,all,path,abort))*/) {
                Struct sct=new StructImpl();
                  sct.setEL(KeyConstants._key,key.getString());
                    sct.setEL(KeyConstants._path,StructFindKey.createKey(coll, path, key));
                    sct.setEL(KeyConstants._owner,coll);
                array.append(sct);
                if(!all)abort=true;
            }
View Full Code Here

    UDFUtil.argumentCollection(values,getFunctionArguments());
   
   
    // struct
    if(this.arguments.length==2) {
      Key keyName = arguments[0].getName();
      Key valueName = arguments[1].getName();
      Object key = values.get(keyName,null);
      Object value = values.get(valueName,null);
      if(key==null)
        throw new ExpressionException("The parameter "+keyName+" to function "+getFunctionName()+" is required but was not passed in.");
      if(value==null)
        throw new ExpressionException("The parameter "+valueName+" to function "+getFunctionName()+" is required but was not passed in.");
     
      return _call(pageContext, key, value);
    }
    // array
    else if(this.arguments.length==1) {
      Key valueName = arguments[0].getName();
      Object value = values.get(valueName,null);
      if(value==null){
        Key[] keys = CollectionUtil.keys(values);
        if(keys.length==1) {
          value=values.get(keys[0]);
View Full Code Here

  }

  @Override
  public Object callWithNamedValues(PageContext pageContext, Struct values,boolean doIncludePath) throws PageException {
    UDFUtil.argumentCollection(values,getFunctionArguments());
    Key key = arguments[0].getName();
    Object value = values.get(key,null);
    if(value==null){
      Key[] keys = CollectionUtil.keys(values);
      if(keys.length>0) {
        value=values.get(keys[0]);
View Full Code Here

 
  @Override
  public Object callWithNamedValues(PageContext pc, Key calledName, Struct values, boolean doIncludePath) throws PageException {
    PageContextImpl pci = ((PageContextImpl)pc);
    Key old =pci.getActiveUDFCalledName();
    pci.setActiveUDFCalledName(calledName);
    try{
      return callWithNamedValues(pci, values, doIncludePath);
    }
    finally{
View Full Code Here

  }

  @Override
  public Object call(PageContext pc, Key calledName, Object[] args, boolean doIncludePath) throws PageException {
    PageContextImpl pci = ((PageContextImpl)pc);
    Key old =pci.getActiveUDFCalledName();
    pci.setActiveUDFCalledName(calledName);
    try{
      return call(pci, args, doIncludePath);
    }
    finally{
View Full Code Here

TOP

Related Classes of railo.runtime.type.Collection.Key

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.