Package railo.runtime.type

Examples of railo.runtime.type.Array


       
        // watchExtensions
        obj = sct.get(KeyImpl.init("watchExtensions"),null);
        List<String> extensions=new ArrayList<String>();
        if(obj!=null) {
          Array arr;
          if(Decision.isArray(obj)) {
            try {
              arr = Caster.toArray(obj);
            } catch (PageException e) {
              arr=new ArrayImpl();
            }
          }
          else {
            arr=railo.runtime.type.util.ListUtil.listToArrayRemoveEmpty(Caster.toString(obj,""), ',');
          }
          Iterator<Object> it = arr.valueIterator();
          String ext;
          while(it.hasNext()){
            ext=Caster.toString(it.next(),null);
            if(StringUtil.isEmpty(ext))continue;
            ext=ext.trim();
View Full Code Here


   

    // exceptions
    len = exceptions==null?0:exceptions.size();
   
        Array arrExceptions=new ArrayImpl();
        if(len>0) {
            Iterator<CatchBlock> it = exceptions.iterator();
            row=0;
            while(it.hasNext()) {
              arrExceptions.appendEL(it.next())
            }
     
        }

    // output log
View Full Code Here

    if(args.length==2)return call(pc,Caster.toArray(args[0]),Caster.toDoubleValue(args[1]));
    return call(pc,Caster.toArray(args[0]),Caster.toDoubleValue(args[1]),Caster.toDoubleValue(args[2]));
  }
 
  private static Array get(Array arr, int from, int to) throws PageException {
    Array rtn=new ArrayImpl(arr.getDimension());
    int[] keys=arr.intKeys();
    for(int i=0;i<keys.length;i++) {
      int key=keys[i];
      if(key<from)continue;
      if(to>0 && key>to)break;
      rtn.append(arr.getE(key));
    }
    return rtn;
  }
View Full Code Here

    try {
      Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
     
      List<String> keys = isFilter(filter)?cache.keys(new WildCardFilter(filter,true)):cache.keys();
      Iterator<String> it = keys.iterator();
      Array arr = new ArrayImpl();
      while(it.hasNext()){
        arr.append(it.next());
      }
      return arr;
    } catch (Exception e) {
      throw Caster.toPageException(e);
    }
View Full Code Here

      ) {
      
    if(list.length()==0) return "";
    if(psq)list=StringUtil.replace(list, "'", "''", false);
   
       Array arr=includeEmptyFields?ListUtil.listToArray(list,delimiter):ListUtil.listToArrayRemoveEmpty(list,delimiter);
   
    boolean isQChar=qualifier.length()==1;
    boolean isDChar=delimiter.length()==1;
   
    if(isQChar && isDChar) return doIt(arr,qualifier.charAt(0),delimiter.charAt(0),elements);
View Full Code Here

   
   
    int pos=((int) posNumber);
    //int[] removedInfo=new int[2];
   
    Array arr = ListUtil.listToArray(list,delimiter);
    int len=arr.size();
   
    // invalid index
    if(pos<1)
      throw new FunctionException(pc,"listSetAt",2,"position","invalid string list index ["+(pos)+"]");
    else if(len<pos) {
      throw new FunctionException(pc,"listSetAt",2,"position","invalid string list index ["+(pos)+"], indexes go from 1 to "+(len));
    }
   
    StringBuffer sb=new StringBuffer();//RepeatString.call(new StringBuffer(),delimiter,removedInfo[0]);
    boolean hasStart=false;
    boolean hasSet=false;
    String v;
    int count=0;
    for(int i=1;i<=len;i++) {
      v=(String)arr.get(i,"");
      if(hasStart) {
        sb.append(delimiter);
      }
      else hasStart=true;
     
      if(includeEmptyFields || v.length()>0)count++;
      if(!hasSet && pos==count) {
        sb.append(value);
        hasSet=true;
      }
      else sb.append(arr.get(i,""));
    }
    if(!hasSet){
      throw new FunctionException(pc,"listSetAt",2,"position","invalid string list index ["+(pos)+"]");
    }
   
View Full Code Here

  public static Array call(PageContext pc) throws PageException {
    return call(pc, null);
  }
 
  public static Array call(PageContext pc, String cacheName) throws PageException {
    Array arr = new ArrayImpl();
    try {
      if(StringUtil.isEmpty(cacheName)){
        addDefault(pc,ConfigImpl.CACHE_DEFAULT_OBJECT,arr);
        addDefault(pc,ConfigImpl.CACHE_DEFAULT_TEMPLATE,arr);
        addDefault(pc,ConfigImpl.CACHE_DEFAULT_QUERY,arr);
        addDefault(pc,ConfigImpl.CACHE_DEFAULT_RESOURCE,arr);
        addDefault(pc,ConfigImpl.CACHE_DEFAULT_FUNCTION,arr);
        //arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_TEMPLATE).getCustomInfo());
        //arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_QUERY).getCustomInfo());
        //arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_RESOURCE).getCustomInfo());
        // MUST welcher muss zuers sein
      }
      else{
        String name;
        String[] names=ListUtil.listToStringArray(cacheName, ',');
        for(int i=0;i<names.length;i++){
          name=names[i].trim();
          if(name.equalsIgnoreCase("template"))
            arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_TEMPLATE).getCustomInfo());
          else if(name.equalsIgnoreCase("object"))
            arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_OBJECT).getCustomInfo());
          else if(name.equalsIgnoreCase("query"))
            arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_QUERY).getCustomInfo());
          else if(name.equalsIgnoreCase("resource"))
            arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_RESOURCE).getCustomInfo());
          else if(name.equalsIgnoreCase("function"))
            arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_FUNCTION).getCustomInfo());
          else
            arr.appendEL(Util.getCache(pc.getConfig(),name).getCustomInfo());
        }
      }
     
     
      return arr;
View Full Code Here

    return call(pc,list,delimiter,false);
  }
 
  public static String call(PageContext pc , String list, String delimiter,boolean includeEmptyFields) throws PageException {
    if(list.length()==0) return "";
    Array arr = includeEmptyFields?ListUtil.listToArray(list,delimiter):ListUtil.listToArrayRemoveEmpty(list,delimiter);
    return ListUtil.arrayToList(ListUtil.trimItems(arr),delimiter)
  }
View Full Code Here

  public static double call(PageContext pc , String list, String value, String delimiter) throws PageException {
    return call(pc,list,value,delimiter,false);
  }
  public static double call(PageContext pc , String list, String value, String delimiter,boolean includeEmptyFields) throws PageException {
    int count=0;
    Array arr= includeEmptyFields?ListUtil.listToArray(list,delimiter):ListUtil.listToArrayRemoveEmpty(list,delimiter);
    int len=arr.size();
   
    for(int i=1;i<=len;i++) {
      if(arr.getE(i).equals(value))count++;
    }
    return count;
  }
View Full Code Here

    return call(pc,Caster.toArray(args[0]),args[1]);
  }
 

    public static Array find(PageContext pc , Array array, UDF udf) throws PageException {
        Array rtn=new ArrayImpl();
      int len=array.size();
     
      Object[] arr=new Object[1];
        Object res;
        Boolean b;
        for(int i=1;i<=len;i++) {
            arr[0]=array.get(i,null);
            if(arr[0]!=null) {
              res=udf.call(pc, arr, false);
              b=Caster.toBoolean(res,null);
              if(b==null) throw new FunctionException(pc,"ArrayFindAll",2,"function","return value of the "+(udf instanceof Closure?"closure":"function ["+udf.getFunctionName()+"]")+" cannot be casted to a boolean value.",CasterException.createMessage(res, "boolean"));
              if(b.booleanValue()) {
                rtn.appendEL(Caster.toDouble(i));
              }
            }
        }
        return rtn;
    }
View Full Code Here

TOP

Related Classes of railo.runtime.type.Array

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.