Esempio n. 1
1
  /** @return returns a string list of all pathes */
  public static Resource[] getClassPathes() {

    if (classPathes != null) return classPathes;

    ArrayList pathes = new ArrayList();
    String pathSeperator = System.getProperty("path.separator");
    if (pathSeperator == null) pathSeperator = ";";

    // java.ext.dirs
    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();

    // pathes from system properties
    String strPathes = System.getProperty("java.class.path");
    if (strPathes != null) {
      Array arr = ListUtil.listToArrayRemoveEmpty(strPathes, pathSeperator);
      int len = arr.size();
      for (int i = 1; i <= len; i++) {
        Resource file = frp.getResource(Caster.toString(arr.get(i, ""), "").trim());
        if (file.exists()) pathes.add(ResourceUtil.getCanonicalResourceEL(file));
      }
    }

    // pathes from url class Loader (dynamic loaded classes)
    ClassLoader cl = new Info().getClass().getClassLoader();
    if (cl instanceof URLClassLoader) getClassPathesFromClassLoader((URLClassLoader) cl, pathes);

    return classPathes = (Resource[]) pathes.toArray(new Resource[pathes.size()]);
  }
Esempio n. 2
0
  private static boolean invoke(
      PageContext pc,
      StringListData sld,
      UDF udf,
      ExecutorService es,
      List<Future<Data<Object>>> futures)
      throws CasterException, PageException {
    Array arr =
        ListUtil.listToArray(
            sld.list, sld.delimiter, sld.includeEmptyFieldsx, sld.multiCharacterDelimiter);

    Iterator<Entry<Key, Object>> it = arr.entryIterator();
    Entry<Key, Object> e;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
      e = it.next();
      res =
          _inv(
              pc,
              udf,
              new Object[] {
                e.getValue(), Caster.toDoubleValue(e.getKey().getString()), sld.list, sld.delimiter
              },
              e.getKey(),
              e.getValue(),
              es,
              futures);
      if (!async && !Caster.toBooleanValue(res)) {
        return false;
      }
    }
    return true;
  }
Esempio n. 3
0
 private static boolean invoke(
     PageContext pc, List list, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures)
     throws CasterException, PageException {
   ListIterator it = list.listIterator();
   boolean async = es != null;
   Object res, v;
   int index;
   ArgumentIntKey k;
   while (it.hasNext()) {
     index = it.nextIndex();
     k = ArgumentIntKey.init(index);
     v = it.next();
     res =
         _inv(
             pc,
             udf,
             new Object[] {v, Caster.toDoubleValue(k.getString()), list},
             k,
             v,
             es,
             futures);
     if (!async && !Caster.toBooleanValue(res)) return false;
   }
   return true;
 }
Esempio n. 4
0
  public static Struct getMemoryUsageAsStruct(int type) {
    java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
    Iterator<MemoryPoolMXBean> it = manager.iterator();

    MemoryPoolMXBean bean;
    MemoryUsage usage;
    MemoryType _type;
    long used = 0, max = 0, init = 0;
    while (it.hasNext()) {
      bean = it.next();
      usage = bean.getUsage();
      _type = bean.getType();
      if ((type == MEMORY_TYPE_HEAP && _type == MemoryType.HEAP)
          || (type == MEMORY_TYPE_NON_HEAP && _type == MemoryType.NON_HEAP)) {
        used += usage.getUsed();
        max += usage.getMax();
        init += usage.getInit();
      }
    }
    Struct sct = new StructImpl();
    sct.setEL(KeyConstants._used, Caster.toDouble(used));
    sct.setEL(KeyConstants._max, Caster.toDouble(max));
    sct.setEL(KeyConstants._init, Caster.toDouble(init));
    sct.setEL(KeyImpl.init("available"), Caster.toDouble(max - used));
    return sct;
  }
Esempio n. 5
0
 public static double call(
     PageContext pc, Query query, String string, Object datatype, Object array)
     throws PageException {
   if (datatype == null) return call(pc, query, string, array);
   query.addColumn(
       KeyImpl.init(string),
       Caster.toArray(array),
       SQLCaster.toSQLType(Caster.toString(datatype)));
   return query.size();
 }
Esempio n. 6
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    int width = Caster.toIntValue(parameters.get(KeyImpl.init("Width")));
    int height = Caster.toIntValue(parameters.get(KeyImpl.init("Height")));
    setHeight(height);
    setWidth(width);

    dst = ImageUtil.createBufferedImage(dst, width, height);

    return filter(src, dst);
  }
Esempio n. 7
0
 public boolean isCloseOnCompletion() throws SQLException {
   // used reflection to make sure this work with Java 5 and 6
   try {
     return Caster.toBooleanValue(
         stat.getClass()
             .getMethod("isCloseOnCompletion", new Class[0])
             .invoke(stat, new Object[0]));
   } catch (Throwable t) {
     if (t instanceof InvocationTargetException
         && ((InvocationTargetException) t).getTargetException() instanceof SQLException)
       throw (SQLException) ((InvocationTargetException) t).getTargetException();
     throw new PageRuntimeException(Caster.toPageException(t));
   }
 }
Esempio n. 8
0
  public static lucee.runtime.type.Query toQuery(
      FTPFile[] files, String prefix, String directory, String hostName) throws PageException {

    String[] cols =
        new String[] {
          "name",
          "isdirectory",
          "lastmodified",
          "length",
          "mode",
          "path",
          "url",
          "type",
          "raw",
          "attributes"
        };
    String[] types =
        new String[] {
          "VARCHAR", "BOOLEAN", "DATE", "DOUBLE", "VARCHAR", "VARCHAR", "VARCHAR", "VARCHAR",
          "VARCHAR", "VARCHAR"
        };

    lucee.runtime.type.Query query = new QueryImpl(cols, types, 0, "query");

    // translate directory path for display
    if (directory.length() == 0) directory = "/";
    else if (directory.startsWith("./")) directory = directory.substring(1);
    else if (directory.charAt(0) != '/') directory = '/' + directory;
    if (directory.charAt(directory.length() - 1) != '/') directory = directory + '/';

    int row;
    for (int i = 0; i < files.length; i++) {
      FTPFile file = files[i];
      if (file.getName().equals(".") || file.getName().equals("..")) continue;
      row = query.addRow();
      query.setAt("attributes", row, "");
      query.setAt("isdirectory", row, Caster.toBoolean(file.isDirectory()));
      query.setAt("lastmodified", row, new DateTimeImpl(file.getTimestamp()));
      query.setAt("length", row, Caster.toDouble(file.getSize()));
      query.setAt("mode", row, FTPConstant.getPermissionASInteger(file));
      query.setAt("type", row, FTPConstant.getTypeAsString(file.getType()));
      // query.setAt("permission",row,FTPConstant.getPermissionASInteger(file));
      query.setAt("raw", row, file.getRawListing());
      query.setAt("name", row, file.getName());
      query.setAt("path", row, directory + file.getName());
      query.setAt("url", row, prefix + "://" + hostName + "" + directory + file.getName());
    }
    return query;
  }
Esempio n. 9
0
 Resource[] callResourceArrayRTE(PageContext pc, Component cfc, String methodName, Object[] args) {
   pc = ThreadLocalPageContext.get(pc);
   try {
     Array arr = Caster.toArray(call(pc, getCFC(pc, cfc), methodName, args));
     Iterator<Object> it = arr.valueIterator();
     CFMLResource[] resources = new CFMLResource[arr.size()];
     int index = 0;
     while (it.hasNext()) {
       resources[index++] = new CFMLResource(this, Caster.toComponent(it.next()));
     }
     return resources;
   } catch (PageException pe) {
     throw new PageRuntimeException(pe);
   }
 }
Esempio n. 10
0
  /**
   * Constructor of the class
   *
   * @param name
   * @param coll
   */
  public FDUDF(IFDStackFrame frame, String name, UDF udf) {
    this.name = name;
    this.udf = udf;

    // meta
    List<FDSimpleVariable> list = new ArrayList<FDSimpleVariable>();
    children.add(new FDSimpleVariable(frame, "Meta Data", "", list));
    list.add(new FDSimpleVariable(frame, "Function Name", udf.getFunctionName(), null));
    if (!StringUtil.isEmpty(udf.getDisplayName()))
      list.add(new FDSimpleVariable(frame, "Display Name", udf.getDisplayName(), null));
    if (!StringUtil.isEmpty(udf.getDescription()))
      list.add(new FDSimpleVariable(frame, "Description", udf.getDescription(), null));
    if (!StringUtil.isEmpty(udf.getHint()))
      list.add(new FDSimpleVariable(frame, "Hint", udf.getHint(), null));
    list.add(new FDSimpleVariable(frame, "Return Type", udf.getReturnTypeAsString(), null));
    list.add(
        new FDSimpleVariable(
            frame, "Return Format", UDFUtil.toReturnFormat(udf.getReturnFormat(), "plain"), null));
    list.add(
        new FDSimpleVariable(
            frame, "Source", Caster.toString(udf.getPageSource().getDisplayPath()), null));
    list.add(
        new FDSimpleVariable(frame, "Secure Json", Caster.toString(udf.getSecureJson(), ""), null));
    list.add(
        new FDSimpleVariable(
            frame, "Verify Client", Caster.toString(udf.getVerifyClient(), ""), null));

    // arguments
    list = new ArrayList();
    List el;
    children.add(new FDSimpleVariable(frame, "Arguments", "", list));
    FunctionArgument[] args = udf.getFunctionArguments();
    for (int i = 0; i < args.length; i++) {
      el = new ArrayList();
      list.add(new FDSimpleVariable(frame, "[" + (i + 1) + "]", "", el));
      el.add(new FDSimpleVariable(frame, "Name", args[i].getName().getString(), null));
      el.add(new FDSimpleVariable(frame, "Type", args[i].getTypeAsString(), null));
      el.add(new FDSimpleVariable(frame, "Required", Caster.toString(args[i].isRequired()), null));

      if (!StringUtil.isEmpty(args[i].getDisplayName()))
        el.add(new FDSimpleVariable(frame, "Display Name", args[i].getDisplayName(), null));
      if (!StringUtil.isEmpty(args[i].getHint()))
        el.add(new FDSimpleVariable(frame, "Hint", args[i].getHint(), null));
    }

    // return
    children.add(new FDSimpleVariable(frame, "return", udf.getReturnTypeAsString(), null));
  }
Esempio n. 11
0
 String callStringRTE(PageContext pc, Component cfc, String methodName, Object[] args) {
   try {
     return Caster.toString(call(pc, cfc, methodName, args));
   } catch (PageException pe) {
     throw new PageRuntimeException(pe);
   }
 }
Esempio n. 12
0
 /** @throws PageException */
 private void doRun() throws PageException {
   try {
     scheduler.runScheduleTask(task, true);
   } catch (Exception e) {
     throw Caster.toPageException(e);
   }
 }
Esempio n. 13
0
 /** @throws PageException */
 private void doDelete() throws PageException {
   try {
     scheduler.removeScheduleTask(task, false);
   } catch (Exception e) {
     throw Caster.toPageException(e);
   }
 }
Esempio n. 14
0
 private void doPause(boolean pause) throws PageException {
   try {
     ((SchedulerImpl) scheduler).pauseScheduleTask(task, pause, true);
   } catch (Exception e) {
     throw Caster.toPageException(e);
   }
 }
Esempio n. 15
0
  private static boolean invoke(
      PageContext pc,
      Iteratorable i,
      UDF udf,
      ExecutorService es,
      List<Future<Data<Object>>> futures)
      throws PageException {
    Iterator<Entry<Key, Object>> it = i.entryIterator();

    Entry<Key, Object> e;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
      e = it.next();
      res =
          _inv(
              pc,
              udf,
              new Object[] {e.getKey().getString(), e.getValue()},
              e.getKey(),
              e.getValue(),
              es,
              futures);
      if (!async && !Caster.toBooleanValue(res)) return false;
    }
    return true;
  }
Esempio n. 16
0
 private static boolean invoke(
     PageContext pc,
     java.util.Map map,
     UDF udf,
     ExecutorService es,
     List<Future<Data<Object>>> futures)
     throws PageException {
   Iterator<Entry> it = map.entrySet().iterator();
   Entry e;
   boolean async = es != null;
   Object res;
   while (it.hasNext()) {
     e = it.next();
     res =
         _inv(
             pc,
             udf,
             new Object[] {e.getKey(), e.getValue(), map},
             e.getKey(),
             e.getValue(),
             es,
             futures);
     if (!async && !Caster.toBooleanValue(res)) return false;
   }
   return true;
 }
Esempio n. 17
0
  public static boolean call(PageContext pc, Object obj, boolean addNewLine, boolean doErrorStream)
      throws PageException {
    String string;
    if (Decision.isSimpleValue(obj)) string = Caster.toString(obj);
    else {
      try {
        string = Serialize.call(pc, obj);
      } catch (Throwable t) {
        string = obj.toString();
      }
    }
    PrintStream stream = System.out;
    // string+=":"+Thread.currentThread().getId();
    if (doErrorStream) stream = System.err;
    if (string != null) {
      if (StringUtil.indexOfIgnoreCase(string, "<print-stack-trace>") != -1) {
        String st = ExceptionUtil.getStacktrace(new Exception("Stack trace"), false);
        string = StringUtil.replace(string, "<print-stack-trace>", "\n" + st + "\n", true).trim();
      }
      if (StringUtil.indexOfIgnoreCase(string, "<hash-code>") != -1) {
        String st = obj.hashCode() + "";
        string = StringUtil.replace(string, "<hash-code>", st, true).trim();
      }
    }
    if (addNewLine) stream.println(string);
    else stream.print(string);

    return true;
  }
Esempio n. 18
0
 public static void _onDebug(PageContext pc) throws PageException {
   try {
     if (pc.getConfig().debug()) pc.getDebugger().writeOut(pc);
   } catch (IOException e) {
     throw Caster.toPageException(e);
   }
 }
Esempio n. 19
0
    public boolean accept(Resource res) {

      if (res.isDirectory()) return allowDir;

      // load content
      String str = null;
      try {
        str = IOUtil.toString(res, "UTF-8");
      } catch (IOException e) {
        return false;
      }

      int index = str.indexOf(':');
      if (index != -1) {
        long expires = Caster.toLongValue(str.substring(0, index), -1L);
        // check is for backward compatibility, old files have no expires date inside. they do ot
        // expire
        if (expires != -1) {
          if (expires < System.currentTimeMillis()) {
            return true;
          }
          str = str.substring(index + 1);
          return false;
        }
      }
      // old files not having a timestamp inside
      else if (res.lastModified() <= time) {
        return true;
      }
      return false;
    }
Esempio n. 20
0
  @Override
  public Object get(Collection.Key key) throws ExpressionException {
    /*if(NullSupportHelper.full()) {
    	Object o=super.get(key,NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;

    	o=get(Caster.toIntValue(key.getString(),-1),NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;
    	throw new ExpressionException("key ["+key.getString()+"] doesn't exist in argument scope. existing keys are ["+
    			lucee.runtime.type.List.arrayToList(CollectionUtil.keys(this),", ")
    			+"]");
    }*/

    // null is supported as returned value with argument scope
    Object o = super.g(key, Null.NULL);
    if (o != Null.NULL) return o;

    o = get(Caster.toIntValue(key.getString(), -1), Null.NULL);
    if (o != Null.NULL) return o;

    throw new ExpressionException(
        "key ["
            + key.getString()
            + "] doesn't exist in argument scope. existing keys are ["
            + lucee.runtime.type.util.ListUtil.arrayToList(CollectionUtil.keys(this), ", ")
            + "]");
  }
Esempio n. 21
0
  /** @throws PageException */
  private void doUpdate() throws PageException {
    String message = "missing attribute for tag schedule with action update";
    String detail = "required attributes are [startDate, startTime, URL, interval, operation]";

    Resource file = null;
    // if(publish) {
    if (!StringUtil.isEmpty(strFile) && !StringUtil.isEmpty(strPath)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strPath);
      file = file.getRealResource(strFile);
    } else if (!StringUtil.isEmpty(strFile)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strFile);
    } else if (!StringUtil.isEmpty(strPath)) {
      file = ResourceUtil.toResourceNotExisting(pageContext, strPath);
    }
    if (file != null)
      pageContext
          .getConfig()
          .getSecurityManager()
          .checkFileLocation(pageContext.getConfig(), file, serverPassword);

    // missing attributes
    if (startdate == null || starttime == null || url == null || interval == null)
      throw new ApplicationException(message, detail);

    // timeout
    if (requesttimeout < 0) requesttimeout = pageContext.getRequestTimeout();

    // username/password
    Credentials cr = null;
    if (username != null) cr = CredentialsImpl.toCredentials(username, password);

    try {

      ScheduleTask st =
          new ScheduleTaskImpl(
              task,
              file,
              startdate,
              starttime,
              enddate,
              endtime,
              url,
              port,
              interval,
              requesttimeout,
              cr,
              ProxyDataImpl.getInstance(proxyserver, proxyport, proxyuser, proxypassword),
              resolveurl,
              publish,
              hidden,
              readonly,
              paused,
              autoDelete);
      scheduler.addScheduleTask(st, true);
    } catch (Exception e) {
      throw Caster.toPageException(e);
    }

    //
  }
Esempio n. 22
0
  @Override
  public SearchEngine getSearchEngine(PageContext pc) throws PageException {
    if (searchEngine == null) {
      try {
        Object o = ClassUtil.loadInstance(getSearchEngineClassDefinition().getClazz());
        if (o instanceof SearchEngine) searchEngine = (SearchEngine) o;
        else
          throw new ApplicationException(
              "class ["
                  + o.getClass().getName()
                  + "] does not implement the interface SearchEngine");

        searchEngine.init(
            this,
            ConfigWebUtil.getFile(
                getConfigDir(),
                ConfigWebUtil.translateOldPath(getSearchEngineDirectory()),
                "search",
                getConfigDir(),
                FileUtil.TYPE_DIR,
                this));
      } catch (Exception e) {
        throw Caster.toPageException(e);
      }
    }
    return searchEngine;
  }
Esempio n. 23
0
  public static boolean _call(PageContext pc, Object obj, UDF udf, boolean parallel, int maxThreads)
      throws PageException {

    ExecutorService execute = null;
    List<Future<Data<Object>>> futures = null;
    if (parallel) {
      execute = Executors.newFixedThreadPool(maxThreads);
      futures = new ArrayList<Future<Data<Object>>>();
    }

    boolean res;

    // Array
    if (obj instanceof Array) {
      res = invoke(pc, (Array) obj, udf, execute, futures);
    }

    // Query
    else if (obj instanceof Query) {
      res = invoke(pc, (Query) obj, udf, execute, futures);
    }
    // Struct
    else if (obj instanceof Struct) {
      res = invoke(pc, (Struct) obj, udf, execute, futures);
    }
    // other Iteratorable
    else if (obj instanceof Iteratorable) {
      res = invoke(pc, (Iteratorable) obj, udf, execute, futures);
    }
    // Map
    else if (obj instanceof java.util.Map) {
      res = invoke(pc, (java.util.Map) obj, udf, execute, futures);
    }
    // List
    else if (obj instanceof List) {
      res = invoke(pc, (List) obj, udf, execute, futures);
    }
    // Iterator
    else if (obj instanceof Iterator) {
      res = invoke(pc, (Iterator) obj, udf, execute, futures);
    }
    // Enumeration
    else if (obj instanceof Enumeration) {
      res = invoke(pc, (Enumeration) obj, udf, execute, futures);
    }
    // String List
    else if (obj instanceof StringListData) {
      res = invoke(pc, (StringListData) obj, udf, execute, futures);
    } else
      throw new FunctionException(
          pc,
          "Every",
          1,
          "data",
          "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));

    if (parallel) res = afterCall(pc, futures, execute);

    return res;
  }
Esempio n. 24
0
  /**
   * close a existing ftp connection
   *
   * @return FTPCLient
   * @throws PageException
   */
  private AFTPClient actionClose() throws PageException {
    FTPConnection conn = _createConnection();
    AFTPClient client = pool.remove(conn);

    Struct cfftp = writeCfftp(client);
    cfftp.setEL("succeeded", Caster.toBoolean(client != null));
    return client;
  }
Esempio n. 25
0
 public static boolean afterCall(
     PageContext pc, List<Future<Data<Object>>> futures, ExecutorService es) throws PageException {
   try {
     Iterator<Future<Data<Object>>> it = futures.iterator();
     Data<Object> d;
     while (it.hasNext()) {
       d = it.next().get();
       if (!Caster.toBooleanValue(d.result)) return false;
       pc.write(d.output);
     }
     return true;
   } catch (Exception e) {
     throw Caster.toPageException(e);
   } finally {
     es.shutdown();
   }
 }
Esempio n. 26
0
  @Override
  public ResourceProvider init(String scheme, Map args) {
    this.scheme = scheme;
    this.args = args;

    // CFC Path
    cfcPath = Caster.toString(args.get("cfc"), null);
    if (StringUtil.isEmpty(cfcPath, true)) cfcPath = Caster.toString(args.get("component"), null);
    cfcPath = ConfigWebUtil.fixComponentPath(cfcPath);

    // use Streams for data
    Boolean _useStreams = Caster.toBoolean(args.get("use-streams"), null);
    if (_useStreams == null) _useStreams = Caster.toBoolean(args.get("usestreams"), null);

    if (_useStreams != null) useStreams = _useStreams.booleanValue();

    return this;
  }
Esempio n. 27
0
  @Override
  public Object invoke(PageContext pc, Object[] args) throws PageException {
    if (args.length == 2) return call(pc, Caster.toString(args[0]), Caster.toString(args[1]));
    if (args.length == 3)
      return call(pc, Caster.toString(args[0]), Caster.toString(args[1]), Caster.toString(args[2]));
    if (args.length == 4)
      return call(
          pc,
          Caster.toString(args[0]),
          Caster.toString(args[1]),
          Caster.toString(args[2]),
          Caster.toBooleanValue(args[3]));

    throw new FunctionException(pc, "ListFindNoCase", 2, 4, args.length);
  }
Esempio n. 28
0
 public static double call(PageContext pc, String strFilter, String cacheName)
     throws PageException {
   try {
     CacheKeyFilter f = filter;
     if (CacheGetAllIds.isFilter(strFilter)) f = new WildCardFilter(strFilter, true);
     return Util.getCache(pc, cacheName, ConfigImpl.CACHE_DEFAULT_OBJECT).remove(f);
   } catch (Exception e) {
     throw Caster.toPageException(e);
   }
 }
  private static SQLItem fill(SQLItem item, Struct sct) throws DatabaseException, PageException {
    // type (optional)
    Object oType = sct.get(KeyConstants._cfsqltype, null);
    if (oType == null) oType = sct.get(KeyConstants._sqltype, null);
    if (oType == null) oType = sct.get(KeyConstants._type, null);
    if (oType != null) {
      item.setType(SQLCaster.toSQLType(Caster.toString(oType)));
    }

    // nulls (optional)
    Object oNulls = sct.get(KeyConstants._nulls, null);
    if (oNulls != null) {
      item.setNulls(Caster.toBooleanValue(oNulls));
    }

    // scale (optional)
    Object oScale = sct.get(KeyConstants._scale, null);
    if (oScale != null) {
      item.setScale(Caster.toIntValue(oScale));
    }

    /* list
    if(Caster.toBooleanValue(sct.get("list",null),false)) {
    	String separator=Caster.toString(sct.get("separator",null),",");
    	String v = Caster.toString(item.getValue());
       	Array arr=null;
       	if(StringUtil.isEmpty(v)){
       		arr=new ArrayImpl();
       		arr.append("");
       	}
       	else arr=ListUtil.listToArrayRemoveEmpty(v,separator);

    	int len=arr.size();
    	StringBuilder sb=new StringBuilder();
    	for(int i=1;i<=len;i++) {
    	    query.setParam(item.clone(check(arr.getE(i))));
            if(i>1)sb.append(',');
            sb.append('?');
    	}
    	write(sb.toString());
    }*/
    return item;
  }
Esempio n. 30
0
  @Override
  public Object invoke(PageContext pc, Object[] args) throws PageException {

    if (args.length == 2) return call(pc, Caster.toArray(args[0]), Caster.toFunction(args[1]));
    if (args.length == 3)
      return call(
          pc, Caster.toArray(args[0]), Caster.toFunction(args[1]), Caster.toBooleanValue(args[2]));
    if (args.length == 4)
      return call(
          pc,
          Caster.toArray(args[0]),
          Caster.toFunction(args[1]),
          Caster.toBooleanValue(args[2]),
          Caster.toDoubleValue(args[3]));

    throw new FunctionException(pc, "ArrayEach", 2, 4, args.length);
  }