Package org.zkoss.zss.engine.xel

Examples of org.zkoss.zss.engine.xel.SSErrorXelException


    try{
      numberHA = CommonFns.toInt(args[0]);
    }
    //filter out invaild number.
    catch(ClassCastException e) {
      throw new SSErrorXelException(SSError.NAME);
    }
    int form = 0;
    int paraNum = args.length;
    if( paraNum == 2)
    {
      try {
        form = CommonFns.toInt(args[1]);
      }
      catch(ClassCastException e) {
        if(!CommonFns.toBoolean(args[1]))
          form = 4;
      }
    }
    // if the input is negative or > 3999, or wrong style parameter, return #VALUE! as MSFT Excel.
    if(numberHA < 0 || numberHA > 3999 || form < 0 || form > 4)
    {
      throw new SSErrorXelException(SSError.VALUE);
    }
    else
   
      //convert Arabic numerical to Roman.
      char[]  unit = {'I','X','C','M'};       
View Full Code Here


    }
   
    return new Double(result);
    }
    catch(ClassCastException e){
      throw new SSErrorXelException(SSError.VALUE);
    }
  }
View Full Code Here

   * @return a positive square root
   */
  public static Object mathSqrt(Object[] args, XelContext ctx){
    double n = CommonFns.toNumber(args[0]).doubleValue();
    if(n<0)
      throw new SSErrorXelException(SSError.NUM);
    return UtilFns.validateNumber(Math.sqrt(n));
  }
View Full Code Here

   * @return the square root of (number * pi)
   */
  public static Object mathSqrtpi(Object[] args, XelContext ctx){
    double number = CommonFns.toNumber(args[0]).doubleValue();
    if(number < 0) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      return new Double(Math.sqrt(number*Math.PI));     
    }

  }
 
View Full Code Here

    //check if the same dimension
    for(int j = 1; j < args.length; ++j) {
      final int[] sz = UtilFns.getMatrixSize(args[j]);
      if (rowsz != sz[0|| colsz != sz[1]) {
        throw new SSErrorXelException(SSError.VALUE);
      }
    }
   
    final double[] mul = new double[rowsz * colsz];
    for(int j = 0; j < mul.length; ++j) {
View Full Code Here

      double x[] = UtilFns.toDoubleArray((Object [])args[0]);
      double y[] = UtilFns.toDoubleArray((Object [])args[1]);
      double result = 0;
      if(x.length != y.length)
      {
        throw new SSErrorXelException(SSError.NA);
      }
      else
      {
        for(int i = 0; i < x.length; i++)
        {
          result += Math.pow(x[i], 2) - Math.pow(y[i], 2);
        }
     
        return new Double(result);
      }
    }
    catch(ClassCastException e){
      throw new SSErrorXelException(SSError.VALUE);
    }   
  }
View Full Code Here

      double x[] = UtilFns.toDoubleArray((Object [])args[0]);
      double y[] = UtilFns.toDoubleArray((Object [])args[1]);
      double result = 0;
      if(x.length != y.length)
      {
        throw new SSErrorXelException(SSError.NA);
      }
      else
      {
        for(int i = 0; i < x.length; i++)
        {
          result += Math.pow(x[i], 2) + Math.pow(y[i], 2);
        }
     
        return new Double(result);
      }
    }
    catch(ClassCastException e){
      throw new SSErrorXelException(SSError.VALUE);
    }   
  }
View Full Code Here

      double x[] = UtilFns.toDoubleArray((Object [])args[0]);
      double y[] = UtilFns.toDoubleArray((Object [])args[1]);
      double result = 0;
      if(x.length != y.length)
      {
        throw new SSErrorXelException(SSError.NA);
      }
      else
      {
        for(int i = 0; i < x.length; i++)
        {
          result += Math.pow(x[i]-y[i], 2);
        }
     
        return new Double(result);
      }
    }
    catch(ClassCastException e){
      throw new SSErrorXelException(SSError.VALUE);
    }
  }
View Full Code Here

  }
 
  /* returns the sum of sqaured values */
  private static double addsq(double total, Object arg, XelContext ctx) {
    if (arg instanceof SSError) {
      throw new SSErrorXelException((SSError) arg);
    } else if (arg instanceof Range) { // a range, iterator thru available
                      // cells
      final Range rng = (Range) arg;
      final Collection cells = rng.getCells();
      for(final Iterator it = cells.iterator(); it.hasNext();) {
View Full Code Here

      x = ((Double)UtilFns.validateNumber(CommonFns.toNumber(args[0]).doubleValue())).doubleValue();
      //get |x| for finding which way to calculate In(x)
      absX = Math.abs(x);
      n = CommonFns.toNumber(args[1]).intValue();
      if (n < 0)
        throw new SSErrorXelException(SSError.NUM);
    }
    catch (ClassCastException e){
      throw new SSErrorXelException(SSError.VALUE);
    }
   
    //use iteration method.
    if( absX < THRESHOLD )
    {
View Full Code Here

TOP

Related Classes of org.zkoss.zss.engine.xel.SSErrorXelException

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.