org.eclipse.birt.data.aggregation_3.7.2.v20120213

16:41:31.901 INFO  jd.cli.Main - Decompiling org.eclipse.birt.data.aggregation_3.7.2.v20120213.jar
package org.eclipse.birt.data.aggregation.api;

public abstract interface IBuildInAggregation
{
  public static final String TOTAL_COUNT_FUNC = "COUNT";
  public static final String TOTAL_SUM_FUNC = "SUM";
  public static final String TOTAL_MAX_FUNC = "MAX";
  public static final String TOTAL_MIN_FUNC = "MIN";
  public static final String TOTAL_AVE_FUNC = "AVE";
  public static final String TOTAL_WEIGHTEDAVE_FUNC = "WEIGHTEDAVE";
  public static final String TOTAL_MOVINGAVE_FUNC = "MOVINGAVE";
  public static final String TOTAL_MEDIAN_FUNC = "MEDIAN";
  public static final String TOTAL_MODE_FUNC = "MODE";
  public static final String TOTAL_STDDEV_FUNC = "STDDEV";
  public static final String TOTAL_VARIANCE_FUNC = "VARIANCE";
  public static final String TOTAL_FIRST_FUNC = "FIRST";
  public static final String TOTAL_LAST_FUNC = "LAST";
  public static final String TOTAL_RUNNINGSUM_FUNC = "RUNNINGSUM";
  public static final String TOTAL_IRR_FUNC = "IRR";
  public static final String TOTAL_MIRR_FUNC = "MIRR";
  public static final String TOTAL_NPV_FUNC = "NPV";
  public static final String TOTAL_RUNNINGNPV_FUNC = "RUNNINGNPV";
  public static final String TOTAL_COUNTDISTINCT_FUNC = "COUNTDISTINCT";
  public static final String TOTAL_RANK_FUNC = "RANK";
  public static final String TOTAL_TOP_N_FUNC = "ISTOPN";
  public static final String TOTAL_TOP_PERCENT_FUNC = "ISTOPNPERCENT";
  public static final String TOTAL_BOTTOM_N_FUNC = "ISBOTTOMN";
  public static final String TOTAL_BOTTOM_PERCENT_FUNC = "ISBOTTOMNPERCENT";
  public static final String TOTAL_PERCENT_RANK_FUNC = "PERCENTRANK";
  public static final String TOTAL_PERCENTILE_FUNC = "PERCENTILE";
  public static final String TOTAL_QUARTILE_FUNC = "QUARTILE";
  public static final String TOTAL_PERCENTSUM_FUNC = "PERCENTSUM";
  public static final String TOTAL_RUNNINGCOUNT_FUNC = "RUNNINGCOUNT";
  public static final String TOTAL_CONCATENATE_FUNC = "CONCATENATE";
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.api.IBuildInAggregation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import java.math.BigDecimal;
import java.math.MathContext;
import org.eclipse.birt.core.data.DataTypeUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.engine.core.DataException;

public class BigDecimalCalculator
  implements ICalculator
{
  public Number add(Object a, Object b)
    throws DataException
  {
    BigDecimal[] args = convert(a, b);
    return args[0].add(args[1]);
  }
  
  public Number divide(Object dividend, Object divisor)
    throws DataException
  {
    BigDecimal[] args = convert(dividend, divisor);
    return args[0].divide(args[1], MathContext.DECIMAL128);
  }
  
  public Number multiply(Object a, Object b)
    throws DataException
  {
    BigDecimal[] args = convert(a, b);
    return args[0].multiply(args[1]);
  }
  
  public Number safeDivide(Object dividend, Object divisor, Number ifZero)
    throws DataException
  {
    try
    {
      return divide(dividend, divisor);
    }
    catch (ArithmeticException localArithmeticException) {}
    return ifZero;
  }
  
  public Number subtract(Object a, Object b)
    throws DataException
  {
    BigDecimal[] args = convert(a, b);
    return args[0].subtract(args[1]);
  }
  
  private BigDecimal[] convert(Object a, Object b)
    throws DataException
  {
    BigDecimal[] args = new BigDecimal[2];
    args[0] = (!(a instanceof BigDecimal) ? 
      BigDecimal.valueOf(((Number)a).doubleValue()) : 
      (BigDecimal)a);
    args[1] = (!(b instanceof BigDecimal) ? 
      BigDecimal.valueOf(((Number)b).doubleValue()) : 
      (BigDecimal)b);
    return args;
  }
  
  public Object getTypedObject(Object obj)
    throws DataException
  {
    try
    {
      return DataTypeUtil.toBigDecimal(obj);
    }
    catch (BirtException e)
    {
      throw DataException.wrap(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.BigDecimalCalculator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import org.eclipse.birt.data.engine.core.DataException;

public class BooleanCalculator
  extends NumberCalculator
{
  public Number add(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.add(args[0], args[1]);
  }
  
  public Number divide(Object dividend, Object divisor)
    throws DataException
  {
    Number[] args = convert(dividend, divisor);
    return super.divide(args[0], args[1]);
  }
  
  public Number multiply(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.multiply(args[0], args[1]);
  }
  
  public Number safeDivide(Object dividend, Object divisor, Number ifZero)
    throws DataException
  {
    Number[] args = convert(dividend, divisor);
    return super.safeDivide(args[0], args[1], ifZero);
  }
  
  public Number subtract(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.subtract(args[0], args[1]);
  }
  
  private Number[] convert(Object a, Object b)
  {
    Number[] args = new Number[2];
    
    args[0] = ((a instanceof Boolean) ? 
      Double.valueOf(((Boolean)a).booleanValue() ? 1.0D : 0.0D) : (Number)a);
    args[1] = ((b instanceof Boolean) ? 
      Double.valueOf(((Boolean)b).booleanValue() ? 1.0D : 0.0D) : (Number)b);
    return args;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.BooleanCalculator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import java.math.BigDecimal;
import java.util.Date;

public class CalculatorFactory
{
  public static ICalculator getCalculator(Class<?> clz)
  {
    if (clz.equals(Boolean.class)) {
      return new BooleanCalculator();
    }
    if (Date.class.isAssignableFrom(clz)) {
      return new DateCalculator();
    }
    if (clz.equals(String.class)) {
      return new StringCalculator();
    }
    if (clz.equals(BigDecimal.class)) {
      return new BigDecimalCalculator();
    }
    return new NumberCalculator();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.CalculatorFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import java.util.Date;
import org.eclipse.birt.data.engine.core.DataException;

public class DateCalculator
  extends NumberCalculator
{
  public Number add(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.add(args[0], args[1]);
  }
  
  public Number divide(Object dividend, Object divisor)
    throws DataException
  {
    Number[] args = convert(dividend, divisor);
    return super.divide(args[0], args[1]);
  }
  
  public Number multiply(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.multiply(args[0], args[1]);
  }
  
  public Number safeDivide(Object dividend, Object divisor, Number ifZero)
    throws DataException
  {
    Number[] args = convert(dividend, divisor);
    return super.safeDivide(args[0], args[1], ifZero);
  }
  
  public Number subtract(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.subtract(args[0], args[1]);
  }
  
  private Number[] convert(Object a, Object b)
    throws DataException
  {
    Number[] args = new Number[2];
    args[0] = ((a instanceof Date) ? Long.valueOf(((Date)a).getTime()) : (Number)a);
    args[1] = ((b instanceof Date) ? Long.valueOf(((Date)b).getTime()) : (Number)b);
    return args;
  }
  
  public Object getTypedObject(Object obj)
    throws DataException
  {
    Double ret = (Double)super.getTypedObject(obj);
    return new Date(ret.longValue());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.DateCalculator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import org.eclipse.birt.data.engine.core.DataException;

public abstract interface ICalculator
{
  public abstract Object getTypedObject(Object paramObject)
    throws DataException;
  
  public abstract Number add(Object paramObject1, Object paramObject2)
    throws DataException;
  
  public abstract Number subtract(Object paramObject1, Object paramObject2)
    throws DataException;
  
  public abstract Number multiply(Object paramObject1, Object paramObject2)
    throws DataException;
  
  public abstract Number divide(Object paramObject1, Object paramObject2)
    throws DataException;
  
  public abstract Number safeDivide(Object paramObject1, Object paramObject2, Number paramNumber)
    throws DataException;
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.ICalculator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import org.eclipse.birt.core.data.DataTypeUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.engine.core.DataException;

public class NumberCalculator
  implements ICalculator
{
  public Number add(Object a, Object b)
    throws DataException
  {
    return Double.valueOf(((Number)a).doubleValue() + ((Number)b).doubleValue());
  }
  
  public Number subtract(Object a, Object b)
    throws DataException
  {
    return Double.valueOf(((Number)a).doubleValue() - ((Number)b).doubleValue());
  }
  
  public Number multiply(Object a, Object b)
    throws DataException
  {
    return Double.valueOf(((Number)a).doubleValue() * ((Number)b).doubleValue());
  }
  
  public Number divide(Object dividend, Object divisor)
    throws DataException
  {
    return Double.valueOf(((Number)dividend).doubleValue() / 
      ((Number)divisor).doubleValue());
  }
  
  public Number safeDivide(Object dividend, Object divisor, Number ifZero)
    throws DataException
  {
    try
    {
      return divide(dividend, divisor);
    }
    catch (ArithmeticException localArithmeticException) {}
    return ifZero;
  }
  
  public Object getTypedObject(Object obj)
    throws DataException
  {
    try
    {
      return DataTypeUtil.toDouble(obj);
    }
    catch (BirtException e)
    {
      throw DataException.wrap(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.NumberCalculator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.calculator;

import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.util.ULocale;
import java.text.ParseException;
import org.eclipse.birt.core.exception.CoreException;
import org.eclipse.birt.data.engine.core.DataException;

public class StringCalculator
  extends NumberCalculator
{
  private static ULocale locale = ;
  
  public Number add(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.add(args[0], args[1]);
  }
  
  public Number divide(Object dividend, Object divisor)
    throws DataException
  {
    Number[] args = convert(dividend, divisor);
    return super.divide(args[0], args[1]);
  }
  
  public Number multiply(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.multiply(args[0], args[1]);
  }
  
  public Number safeDivide(Object dividend, Object divisor, Number ifZero)
    throws DataException
  {
    Number[] args = convert(dividend, divisor);
    return super.safeDivide(args[0], args[1], ifZero);
  }
  
  public Number subtract(Object a, Object b)
    throws DataException
  {
    Number[] args = convert(a, b);
    return super.subtract(args[0], args[1]);
  }
  
  private Number[] convert(Object a, Object b)
    throws DataException
  {
    Number[] arguments = new Number[2];
    
    arguments[0] = ((a instanceof String) ? toDouble((String)a) : 
      (Number)a);
    arguments[1] = ((b instanceof String) ? toDouble((String)b) : 
      (Number)b);
    return arguments;
  }
  
  private Double toDouble(String source)
    throws DataException
  {
    try
    {
      return Double.valueOf(source);
    }
    catch (NumberFormatException localNumberFormatException)
    {
      try
      {
        Number number = NumberFormat.getInstance(locale)
          .parse(source);
        if (number != null) {
          return new Double(number.doubleValue());
        }
        throw DataException.wrap(new CoreException("CONVERT_FAILS", 
          new Object[] {
          source.toString(), "Double" }));
      }
      catch (ParseException localParseException)
      {
        throw DataException.wrap(new CoreException("CONVERT_FAILS", 
          new Object[] {
          source.toString(), "Double" }));
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.calculator.StringCalculator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.i18n;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class Messages
{
  private static final String BUNDLE_NAME = "org.eclipse.birt.data.aggregation.i18n.messages";
  private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("org.eclipse.birt.data.aggregation.i18n.messages");
  
  public static String getString(String key)
  {
    try
    {
      return RESOURCE_BUNDLE.getString(key);
    }
    catch (MissingResourceException localMissingResourceException) {}
    return '!' + key + '!';
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.i18n.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.i18n;

public class ResourceConstants
{
  public static final String UNSUPPORTED_DATA_TYPE = "aggregation.BadOperandType";
  public static final String DATATYPEUTIL_ERROR = "aggregation.DataConversionError";
  public static final String BAD_PARAM_COUNT = "aggregation.BadParameterCount";
  public static final String BAD_PARAM_TYPE = "aggregation.BadParameterType";
  public static final String NO_SOLUTION_FOUND = "aggregation.NoIrrSolution";
  public static final String INVALID_PERCENTILE_COLUMN = "aggregation.InvalidPercentileColumn";
  public static final String INVALID_TOP_BOTTOM_ARGUMENT = "aggregation.InvalidTopBottomArgument";
  public static final String INVALID_TOP_BOTTOM_N_ARGUMENT = "aggregation.InvalidTopBottomNArgument";
  public static final String INVALID_TOP_BOTTOM_PERCENT_ARGUMENT = "aggregation.InvalidTopBottomPercentArgument";
  public static final String INVALID_TOP_BOTTOM_N = "aggregation.InvalidTopBottomN";
  public static final String INVALID_PERCENTILE_ARGUMENT = "aggregation.InvalidPercentileArgument";
  public static final String INVALID_QUARTILE_ARGUMENT = "aggregation.InvalidQuartileArgument";
  public static final String ILLEGAL_PARAMETER_FUN = "aggregation.BadAggrFuncParam";
  public static final String RESET_RATE = "aggregation.ResetRateGuess";
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.i18n.ResourceConstants
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import java.util.ResourceBundle;
import org.eclipse.birt.core.exception.BirtException;

public class AggrException
  extends BirtException
{
  private static final long serialVersionUID = 1336188710963460825L;
  private static final String _pluginId = "org.eclipse.birt.data.aggregation";
  private static final String BUNDLE_NAME = "org.eclipse.birt.data.aggregation.i18n.messages";
  private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("org.eclipse.birt.data.aggregation.i18n.messages");
  
  public AggrException(String errorCode)
  {
    super("org.eclipse.birt.data.aggregation", errorCode, RESOURCE_BUNDLE);
  }
  
  public AggrException(String errorCode, Throwable cause)
  {
    super("org.eclipse.birt.data.aggregation", errorCode, RESOURCE_BUNDLE, cause);
  }
  
  public AggrException(String errorCode, Object[] args, Throwable cause)
  {
    super("org.eclipse.birt.data.aggregation", errorCode, args, RESOURCE_BUNDLE, cause);
  }
  
  public AggrException(String errorCode, Object arg0, Throwable cause)
  {
    super("org.eclipse.birt.data.aggregation", errorCode, arg0, RESOURCE_BUNDLE, cause);
  }
  
  public AggrException(String errorCode, Object[] args)
  {
    super("org.eclipse.birt.data.aggregation", errorCode, args, RESOURCE_BUNDLE);
  }
  
  public AggrException(String errorCode, Object arg0)
  {
    super("org.eclipse.birt.data.aggregation", errorCode, arg0, RESOURCE_BUNDLE);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.AggrException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import org.eclipse.birt.data.engine.api.aggregation.IAggrFunction;

public abstract class AggrFunction
  implements IAggrFunction
{
  public Object getDefaultValue()
  {
    return null;
  }
  
  public int getNumberOfPasses()
  {
    return 1;
  }
  
  public boolean isDataOrderSensitive()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.AggrFunction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.birt.data.aggregation.impl.rank.TotalIsBottomN;
import org.eclipse.birt.data.aggregation.impl.rank.TotalIsBottomNPercent;
import org.eclipse.birt.data.aggregation.impl.rank.TotalIsTopN;
import org.eclipse.birt.data.aggregation.impl.rank.TotalIsTopNPercent;
import org.eclipse.birt.data.aggregation.impl.rank.TotalPercentRank;
import org.eclipse.birt.data.aggregation.impl.rank.TotalPercentSum;
import org.eclipse.birt.data.aggregation.impl.rank.TotalPercentile;
import org.eclipse.birt.data.aggregation.impl.rank.TotalQuartile;
import org.eclipse.birt.data.aggregation.impl.rank.TotalRank;
import org.eclipse.birt.data.engine.api.aggregation.IAggrFunction;
import org.eclipse.birt.data.engine.api.aggregation.IAggregationFactory;

public class BuildInAggregationFactory
  implements IAggregationFactory
{
  private Map aggrMap = new HashMap();
  private List aggregations = new ArrayList();
  
  private void populateAggregations()
  {
    TotalCount totalCount = new TotalCount();
    aggrMap.put("COUNT", totalCount);
    aggregations.add(totalCount);
    TotalSum totalSum = new TotalSum();
    aggrMap.put("SUM", totalSum);
    aggregations.add(totalSum);
    TotalMax totalMax = new TotalMax();
    aggrMap.put("MAX", totalMax);
    aggregations.add(totalMax);
    TotalMin totalMin = new TotalMin();
    aggrMap.put("MIN", totalMin);
    aggregations.add(totalMin);
    TotalAve totalAve = new TotalAve();
    aggrMap.put("AVE", totalAve);
    aggregations.add(totalAve);
    TotalWeightedAve totalWeightedAve = new TotalWeightedAve();
    aggrMap.put("WEIGHTEDAVE", 
      totalWeightedAve);
    aggregations.add(totalWeightedAve);
    TotalMovingAve totalMovingAve = new TotalMovingAve();
    aggrMap.put("MOVINGAVE", totalMovingAve);
    aggregations.add(totalMovingAve);
    TotalMedian totalMedian = new TotalMedian();
    aggrMap.put("MEDIAN", totalMedian);
    aggregations.add(totalMedian);
    TotalMode totalMode = new TotalMode();
    aggrMap.put("MODE", totalMode);
    aggregations.add(totalMode);
    TotalStdDev totalStdDev = new TotalStdDev();
    aggrMap.put("STDDEV", totalStdDev);
    aggregations.add(totalStdDev);
    TotalVariance totalVariance = new TotalVariance();
    aggrMap.put("VARIANCE", totalVariance);
    aggregations.add(totalVariance);
    TotalFirst totalFirst = new TotalFirst();
    aggrMap.put("FIRST", totalFirst);
    aggregations.add(totalFirst);
    TotalLast totalLast = new TotalLast();
    aggrMap.put("LAST", totalLast);
    aggregations.add(totalLast);
    TotalRunningSum totalRunningSum = new TotalRunningSum();
    aggrMap.put("RUNNINGSUM", totalRunningSum);
    aggregations.add(totalRunningSum);
    TotalIrr totalIrr = new TotalIrr();
    aggrMap.put("IRR", totalIrr);
    aggregations.add(totalIrr);
    TotalMirr totalMirr = new TotalMirr();
    aggrMap.put("MIRR", totalMirr);
    aggregations.add(totalMirr);
    TotalNpv totalNpv = new TotalNpv();
    aggrMap.put("NPV", totalNpv);
    aggregations.add(totalNpv);
    TotalRunningNpv totalRunningNpv = new TotalRunningNpv();
    aggrMap.put("RUNNINGNPV", totalRunningNpv);
    aggregations.add(totalRunningNpv);
    TotalCountDistinct totalCountDistinct = new TotalCountDistinct();
    aggrMap.put("COUNTDISTINCT", 
      totalCountDistinct);
    aggregations.add(totalCountDistinct);
    TotalRank totalRank = new TotalRank();
    aggrMap.put("RANK", totalRank);
    aggregations.add(totalRank);
    TotalIsTopN totalIsTopN = new TotalIsTopN();
    aggrMap.put("ISTOPN", totalIsTopN);
    aggregations.add(totalIsTopN);
    TotalIsTopNPercent totalIsTopNPercent = new TotalIsTopNPercent();
    aggrMap.put("ISTOPNPERCENT", 
      totalIsTopNPercent);
    aggregations.add(totalIsTopNPercent);
    TotalIsBottomN totalIsBottomN = new TotalIsBottomN();
    aggrMap.put("ISBOTTOMN", totalIsBottomN);
    aggregations.add(totalIsBottomN);
    TotalIsBottomNPercent totalIsBottomNPercent = new TotalIsBottomNPercent();
    aggrMap.put("ISBOTTOMNPERCENT", 
      totalIsBottomNPercent);
    aggregations.add(totalIsBottomNPercent);
    TotalPercentRank totalPercentRank = new TotalPercentRank();
    aggrMap.put("PERCENTRANK", 
      totalPercentRank);
    aggregations.add(totalPercentRank);
    TotalPercentile totalPercentile = new TotalPercentile();
    aggrMap.put("PERCENTILE", totalPercentile);
    aggregations.add(totalPercentile);
    TotalQuartile totalQuartile = new TotalQuartile();
    aggrMap.put("QUARTILE", totalQuartile);
    aggregations.add(totalQuartile);
    TotalPercentSum totalPercentSum = new TotalPercentSum();
    aggrMap.put("PERCENTSUM", totalPercentSum);
    aggregations.add(totalPercentSum);
    TotalRunningCount totalRunningCount = new TotalRunningCount();
    aggrMap.put("RUNNINGCOUNT", 
      totalRunningCount);
    aggregations.add(totalRunningCount);
    TotalConcatenate totalConcatenate = new TotalConcatenate();
    aggrMap.put("CONCATENATE", totalConcatenate);
    aggregations.add(totalConcatenate);
  }
  
  public BuildInAggregationFactory()
  {
    populateAggregations();
  }
  
  public List getAggregations()
  {
    return aggregations;
  }
  
  public IAggrFunction getAggregation(String name)
  {
    return (IAggrFunction)aggrMap.get(name.toUpperCase());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.BuildInAggregationFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import org.eclipse.birt.data.aggregation.i18n.Messages;

public class Constants
{
  public static final String EXPRESSION_NAME = "Expression";
  public static final String EXPRESSION_DISPLAY_NAME = Messages.getString("Constants.Expression");
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.Constants
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
null
package org.eclipse.birt.data.aggregation.impl;

import org.eclipse.birt.data.engine.api.aggregation.IParameterDefn;

public class ParameterDefn
  implements IParameterDefn
{
  private String name;
  private boolean isOptional = false;
  private boolean isDataField = false;
  private String displayName;
  private String description;
  private int[] supportedDataTypes;
  
  public ParameterDefn(String name, String displayName, boolean isOptional, boolean isDataField, int[] supportedDataTypes, String description)
  {
    assert (name != null);
    assert (supportedDataTypes != null);
    
    this.name = name;
    this.isOptional = isOptional;
    this.isDataField = isDataField;
    this.displayName = displayName;
    this.supportedDataTypes = supportedDataTypes;
    this.description = description;
  }
  
  public void setOptional(boolean isOptional)
  {
    this.isOptional = isOptional;
  }
  
  public void setDataField(boolean isDataField)
  {
    this.isDataField = isDataField;
  }
  
  public void setDisplayName(String displayName)
  {
    this.displayName = displayName;
  }
  
  public void setDescription(String description)
  {
    this.description = description;
  }
  
  public String getName()
  {
    return name;
  }
  
  public void setName(String name)
  {
    this.name = name;
  }
  
  public String getDescription()
  {
    return description;
  }
  
  public String getDisplayName()
  {
    return displayName;
  }
  
  public boolean isDataField()
  {
    return isDataField;
  }
  
  public boolean isOptional()
  {
    return isOptional;
  }
  
  public boolean supportDataType(int dataType)
  {
    if (dataType == -1) {
      return true;
    }
    for (int i = 0; i < supportedDataTypes.length; i++) {
      if ((supportedDataTypes[i] == 0) || (supportedDataTypes[i] == dataType)) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.ParameterDefn
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import org.eclipse.birt.data.aggregation.calculator.ICalculator;
import org.eclipse.birt.data.engine.api.aggregation.Accumulator;
import org.eclipse.birt.data.engine.core.DataException;

public abstract class RunningAccumulator
  extends Accumulator
{
  protected ICalculator calculator;
  
  public void start()
    throws DataException
  {
    calculator = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.RunningAccumulator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import java.math.BigDecimal;
import java.util.Date;
import org.eclipse.birt.core.data.DataTypeUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.aggregation.calculator.ICalculator;
import org.eclipse.birt.data.engine.api.aggregation.Accumulator;
import org.eclipse.birt.data.engine.core.DataException;

public abstract class SummaryAccumulator
  extends Accumulator
{
  protected int dataType = -1;
  protected boolean isFinished = false;
  protected ICalculator calculator;
  
  public void start()
  {
    isFinished = false;
    dataType = -1;
    calculator = null;
  }
  
  public void finish()
    throws DataException
  {
    isFinished = true;
  }
  
  public Object getValue()
    throws DataException
  {
    if (!isFinished) {
      throw new RuntimeException("Error! Call summary total function before finished the dataset");
    }
    return getSummaryValue();
  }
  
  protected Object getTypedData(Object obj)
    throws DataException
  {
    Object value = obj;
    switch (dataType)
    {
    case -1: 
      if ((obj instanceof Date))
      {
        dataType = 6;
      }
      else if ((obj instanceof BigDecimal))
      {
        dataType = 4;
      }
      else
      {
        value = toDouble(obj);
        dataType = 3;
      }
      break;
    case 3: 
      value = toDouble(obj);
    }
    return value;
  }
  
  protected Object toDouble(Object obj)
    throws DataException
  {
    Object value = null;
    try
    {
      value = DataTypeUtil.toDouble(obj);
    }
    catch (BirtException e)
    {
      throw new DataException("data.engine.DataConversionError", e);
    }
    return value;
  }
  
  public abstract Object getSummaryValue()
    throws DataException;
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.SummaryAccumulator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

public class SupportedDataTypes
{
  public static final int[] ANY = new int[1];
  public static final int[] CALCULATABLE = {
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    9, 
    10 };
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.SupportedDataTypes
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import java.io.File;

public class TempDir
{
  private static TempDir instance;
  private String path;
  
  private TempDir(String path)
  {
    this.path = path;
  }
  
  public static void createInstance(String path)
  {
    instance = new TempDir(path);
  }
  
  public static TempDir getInstance()
  {
    if (instance == null)
    {
      String tempDir = System.getProperty("java.io.tmpdir") + 
        "AggregationPlugin_temp" + File.separator;
      
      File f = new File(tempDir);
      if (f.exists()) {
        deleteDirectory(f);
      }
      instance = new TempDir(tempDir);
    }
    return instance;
  }
  
  public String getPath()
  {
    return path;
  }
  
  public static void release()
  {
    if (instance != null)
    {
      File f = new File(instance.getPath());
      if (f.exists()) {
        deleteDirectory(f);
      }
      instance = null;
    }
  }
  
  private static void deleteDirectory(File dir)
  {
    File[] subFiles = dir.listFiles();
    if (subFiles != null) {
      for (int i = 0; i < subFiles.length; i++) {
        if (subFiles[i].isDirectory()) {
          deleteDirectory(subFiles[i]);
        } else {
          safeDelete(subFiles[i]);
        }
      }
    }
    safeDelete(dir);
  }
  
  private static void safeDelete(File file)
  {
    if (!file.delete()) {
      file.deleteOnExit();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.TempDir
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import org.eclipse.birt.data.aggregation.calculator.CalculatorFactory;
import org.eclipse.birt.data.aggregation.calculator.ICalculator;
import org.eclipse.birt.data.engine.core.DataException;

class TotalAve$MyAccumulator
  extends SummaryAccumulator
{
  private Number sum = Double.valueOf(0.0D);
  private int count = 0;
  
  public void start()
  {
    super.start();
    sum = Double.valueOf(0.0D);
    count = 0;
  }
  
  public void onRow(Object[] args)
    throws DataException
  {
    assert (args.length > 0);
    if (args[0] != null)
    {
      if (calculator == null) {
        calculator = CalculatorFactory.getCalculator(args[0].getClass());
      }
      sum = calculator.add(sum, args[0]);
      count += 1;
    }
  }
  
  public Object getSummaryValue()
  {
    if (count > 0)
    {
      Number ret = null;
      try
      {
        ret = calculator.divide(sum, Integer.valueOf(count));
        return calculator.getTypedObject(ret);
      }
      catch (DataException localDataException)
      {
        return null;
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.TotalAve.MyAccumulator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import org.eclipse.birt.data.aggregation.calculator.CalculatorFactory;
import org.eclipse.birt.data.aggregation.calculator.ICalculator;
import org.eclipse.birt.data.aggregation.i18n.Messages;
import org.eclipse.birt.data.engine.api.aggregation.Accumulator;
import org.eclipse.birt.data.engine.api.aggregation.IParameterDefn;
import org.eclipse.birt.data.engine.core.DataException;

public class TotalAve
  extends AggrFunction
{
  public String getName()
  {
    return "AVE";
  }
  
  public int getType()
  {
    return 0;
  }
  
  public int getDataType()
  {
    return 3;
  }
  
  public Accumulator newAccumulator()
  {
    return new MyAccumulator(null);
  }
  
  private static class MyAccumulator
    extends SummaryAccumulator
  {
    private Number sum = Double.valueOf(0.0D);
    private int count = 0;
    
    public void start()
    {
      super.start();
      sum = Double.valueOf(0.0D);
      count = 0;
    }
    
    public void onRow(Object[] args)
      throws DataException
    {
      assert (args.length > 0);
      if (args[0] != null)
      {
        if (calculator == null) {
          calculator = CalculatorFactory.getCalculator(args[0].getClass());
        }
        sum = calculator.add(sum, args[0]);
        count += 1;
      }
    }
    
    public Object getSummaryValue()
    {
      if (count > 0)
      {
        Number ret = null;
        try
        {
          ret = calculator.divide(sum, Integer.valueOf(count));
          return calculator.getTypedObject(ret);
        }
        catch (DataException localDataException)
        {
          return null;
        }
      }
      return null;
    }
  }
  
  public String getDescription()
  {
    return Messages.getString("TotalAve.description");
  }
  
  public String getDisplayName()
  {
    return Messages.getString("TotalAve.displayName");
  }
  
  public IParameterDefn[] getParameterDefn()
  {
    return new IParameterDefn[] {
      new ParameterDefn("Expression", 
      Constants.EXPRESSION_DISPLAY_NAME, 
      false, 
      true, 
      SupportedDataTypes.CALCULATABLE, 
      "") };
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.TotalAve
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import org.eclipse.birt.core.data.DataTypeUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.aggregation.i18n.Messages;
import org.eclipse.birt.data.engine.api.aggregation.IParameterDefn;
import org.eclipse.birt.data.engine.core.DataException;

class TotalConcatenate$MyAccumulator
  extends SummaryAccumulator
{
  private Collection<String> values;
  private String separator;
  private int maxLength;
  private boolean isInitialized;
  private static final int DEFAULT_MAX_LENGTH = 1024;
  
  private TotalConcatenate$MyAccumulator(TotalConcatenate paramTotalConcatenate) {}
  
  public void start()
  {
    super.start();
    values = null;
    separator = "";
    isInitialized = false;
    maxLength = 1024;
  }
  
  public void onRow(Object[] args)
    throws DataException
  {
    assert ((args != null) && (args.length >= 1));
    try
    {
      if (!isInitialized)
      {
        isInitialized = true;
        setSeparator(args.length >= 2 ? args[1] : null);
        setMaxLength(args.length >= 3 ? args[2] : 
          Integer.valueOf(1024));
        setShowAllValues(args.length == 4 ? args[3] : Boolean.valueOf(false));
      }
      if (args[0] != null) {
        values.add(DataTypeUtil.toString(args[0]));
      }
    }
    catch (BirtException e)
    {
      throw DataException.wrap(e);
    }
  }
  
  public Object getSummaryValue()
  {
    if (values == null) {
      return null;
    }
    StringBuffer buffer = new StringBuffer();
    Iterator<String> valueIterator = values.iterator();
    while (valueIterator.hasNext())
    {
      String currentValue = (String)valueIterator.next();
      if (buffer.length() > maxLength - currentValue.length()) {
        break;
      }
      if (currentValue.trim().length() > 0) {
        buffer.append(currentValue).append(separator);
      }
    }
    if (buffer.length() > 0) {
      return buffer.toString().substring(0, 
        buffer.length() - separator.length());
    }
    return buffer.toString();
  }
  
  private void setSeparator(Object source)
    throws BirtException
  {
    String value = DataTypeUtil.toString(source);
    if (value != null) {
      separator = value;
    }
  }
  
  private void setMaxLength(Object source)
    throws DataException
  {
    try
    {
      if ((source == null) || 
        (DataTypeUtil.toString(source).trim().length() == 0))
      {
        maxLength = 1024;
      }
      else
      {
        int value = DataTypeUtil.toInteger(source).intValue();
        if (value == 0) {
          maxLength = 1024;
        }
        if (value < 0) {
          throw new DataException(Messages.getString("aggregation.InvalidParameterValue"), 
            new Object[] { this$0.getParameterDefn()[2].getDisplayName(), 
            this$0.getDisplayName(), 
            Integer.valueOf(value) });
        }
        maxLength = value;
      }
    }
    catch (BirtException e)
    {
      throw DataException.wrap(e);
    }
  }
  
  private void setShowAllValues(Object source)
    throws BirtException
  {
    boolean showAllValues;
    boolean showAllValues;
    if ((source == null) || 
      (DataTypeUtil.toString(source).trim().length() == 0))
    {
      showAllValues = false;
    }
    else if ((source instanceof String))
    {
      try
      {
        showAllValues = DataTypeUtil.toBoolean(source).booleanValue();
      }
      catch (Exception localException)
      {
        boolean showAllValues;
        throw new DataException(Messages.getString("aggregation.InvalidParameterValue"), 
          new Object[] { this$0.getParameterDefn()[3].getDisplayName().replaceAll("&", ""), 
          this$0.getDisplayName(), 
          source });
      }
    }
    else
    {
      if (!(source instanceof Boolean)) {
        throw new DataException(Messages.getString("aggregation.InvalidParameterType") + 
          this$0.getName());
      }
      showAllValues = DataTypeUtil.toBoolean(source).booleanValue();
    }
    if (showAllValues) {
      values = new ArrayList();
    } else {
      values = new LinkedHashSet();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.data.aggregation.impl.TotalConcatenate.MyAccumulator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.data.aggregation.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import org.eclipse.birt.core.data.DataTypeUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.aggregation.i18n.Messages;
import org.eclipse.birt.data.engine.api.aggregation.Accumulator;
import org.eclipse.birt.data.engine.api.aggregation.IParameterDefn;
import org.eclipse.birt.data.engine.core.DataException;

public class TotalConcatenate
  extends AggrFunction
{
  public String getName()
  {
    return "CONCATENATE";
  }
  
  public int getType()
  {
    return 0;
  }
  
  public int getDataType()
  {
    return 5;
  }
  
  public IParameterDefn[] getParameterDefn()
  {
    IParameterDefn[] paramDefn = {
      new ParameterDefn("Expression", 
      Constants.EXPRESSION_DISPLAY_NAME, 
      false, 
      true, 
      SupportedDataTypes.ANY, 
      Messages.getString("TotalConcatenate.paramDescription.expression")), 
      new ParameterDefn(Messages.getString("TotalConcatenate.param.separator"), 
      Messages.getString("TotalConcatenate.param.separator"), 
      true, 
      false, 
      SupportedDataTypes.CALCULATABLE, 
      Messages.getString("TotalConcatenate.paramDescription.separator")), 
      new ParameterDefn(Messages.getString("TotalConcatenate.param.maxLength"), 
      Messages.getString("TotalConcatenate.param.maxLength"), 
      true, 
      false, 
      SupportedDataTypes.CALCULATABLE, 
      Messages.getString("TotalConcatenate.paramDescription.maxLength")), 
      new ParameterDefn(Messages.getString("TotalConcatenate.param.showAllValues"), 
      Messages.getString("TotalConcatenate.param.showAllValues"), 
      true, 
      false, 
      SupportedDataTypes.CALCULATABLE, 
1 2 3 4 5

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd