Package org.zkoss.zss.engine.xel

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


   * @return the average of its arguments
   */
  public static Object statAverage(Object[] args, XelContext ctx){
    final List ls = UtilFns.toList(args, ctx);
    if (ls.isEmpty()) {
      throw new SSErrorXelException(SSError.DIV0);
    }
    return UtilFns.validateNumber(UtilFns.getStats(UtilFns.toDoubleArray(ls)).getMean());
  }
View Full Code Here


        use the AVERAGE function
     */

    final List ls = UtilFns.toAList(args, ctx);
    if (ls.isEmpty()) {
      throw new SSErrorXelException(SSError.DIV0);
    }
   
    return UtilFns.validateNumber(UtilFns.getStats(UtilFns.toDoubleArray(ls)).getMean());
  }
View Full Code Here

    int trails = CommonFns.toNumber(args[1]).intValue();
    double p_s = CommonFns.toNumber(args[2]).doubleValue();
    boolean isCumulative = ((Boolean)args[3]).booleanValue();
   
    if(number>trails || number <0)
      throw new SSErrorXelException(SSError.NUM);
    else{
      DistributionFactory factory = DistributionFactory.newInstance();
      BinomialDistribution bd = factory.createBinomialDistribution(trails, p_s);
      if(isCumulative)
        return UtilFns.validateNumber(bd.cumulativeProbability(number));
View Full Code Here

  public static Object statChidist(Object[] args, XelContext ctx) throws MathException{
    //EXCEL: CHIDIST(x,degrees_freedom)
    double x = CommonFns.toNumber(args[0]).doubleValue();
    double df = CommonFns.toNumber(args[1]).doubleValue();
    if(x <0)
      throw new SSErrorXelException(SSError.NUM);
    else{   
      DistributionFactory factory = DistributionFactory.newInstance();
      return UtilFns.validateNumber(1-factory.createChiSquareDistribution(df).cumulativeProbability(x));
    }
  }
View Full Code Here

   */
  public static Object statChiinv(Object[] args, XelContext ctx) throws MathException{
    double p = CommonFns.toNumber(args[0]).doubleValue();
    double df = CommonFns.toNumber(args[1]).doubleValue();
    if(p<0 || p>1)
      throw new SSErrorXelException(SSError.NUM);
    else{
      DistributionFactory factory = DistributionFactory.newInstance();
      return UtilFns.validateNumber(factory.createChiSquareDistribution(df).inverseCumulativeProbability((1-p)));
    }
  }
View Full Code Here

   * @param ctx context information for XEL evalution.
   * @return the sum of deviation
   */
  private static double sumDeviation(double total, Object arg, double mean, 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 Book book = rng.getSheet().getBook();
      final Collection cells = rng.getCells();
View Full Code Here

    return _ref;
  }
  public Collection getCells() {
     final Ref2d ref = (Ref2d) _ref;
    if (ref.getLtIndex() == null || ref.getRbIndex() == null) {
      throw new SSErrorXelException(SSError.REF);
    }
    return super.getCells();
  }
View Full Code Here

    Date issue = UtilFns.stringToDate(args[0].toString());
    Date firI = UtilFns.stringToDate(args[1].toString());
    Date settlement = UtilFns.stringToDate(args[2].toString());
    if(settlement.before(issue))
    {
      throw new SSErrorXelException(SSError.NUM);
    }
    double rate = CommonFns.toNumber(args[3]).doubleValue();
    double Par;
    int freq;
    try{
      Par = CommonFns.toNumber(args[4]).doubleValue();
    }catch(ClassCastException e){
      Par = 10E+3; //provided as MSFT Excel help says
    }
    try{
    freq = CommonFns.toNumber(args[5]).intValue();
    }catch(ClassCastException e){
      throw new SSErrorXelException(SSError.NUM);
    }
    int basis = 0;
    boolean method = true;
    if(args.length == 7)
    {
      try{
        basis = basis(CommonFns.toNumber(args[6]).intValue());
      }catch(ClassCastException e){
        basis = 0;
      }
    }
    else if(args.length == 8)
    {
      try{
        basis = basis(CommonFns.toNumber(args[6]).intValue());
      }catch(ClassCastException e){
        basis = 0;
      }
      try{
        method = CommonFns.toBoolean(args[7]);
      }catch(ClassCastException e){
        method = true;
      }
    }
   
    if(!(freq == 1 || freq == 2 || freq == 4))
    {
      throw new SSErrorXelException(SSError.NUM);
    }
    if( rate <= 0 || Par <= 0)
    {
      throw new SSErrorXelException(SSError.NUM);
    }
   
    double result = 0;
    //TODO:only only a few situations are correct
    if(method) //because Par * rate / freq * diff * freq == Par * rate * diff
 
View Full Code Here

 
  /* return frequency */
 
  private static int frequency(int frequency) {
    if(frequency != 1 && frequency != 2 && frequency != 4) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      return 12/frequency;
    }
  }
View Full Code Here

  }
 
  /* return basis */
  private static int basis(int basis) {
    if(basis > 4 || basis < 0) {
      throw new SSErrorXelException(SSError.NUM);
    } else {
      return basis;     
    }
  }
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.