Java 类net.sf.jasperreports.engine.JRScriptletException 实例源码

项目:jasperreports    文件:WebappScriptlet.java   
@Override
public void afterGroupInit(String groupName) throws JRScriptletException
{
    String allCities = (String)this.getVariableValue("AllCities");
    String city = (String)this.getFieldValue("City");
    StringBuilder sb = new StringBuilder();

    if (allCities != null)
    {
        sb.append(allCities);
        sb.append(", ");
    }

    sb.append(city);
    this.setVariableValue("AllCities", sb.toString());
}
项目:jasperreports    文件:WebappScriptlet.java   
/**
 *
 */
public void afterGroupInit(String groupName) throws JRScriptletException
{
    String allCities = (String)this.getVariableValue("AllCities");
    String city = (String)this.getFieldValue("City");
    StringBuilder sb = new StringBuilder();

    if (allCities != null)
    {
        sb.append(allCities);
        sb.append(", ");
    }

    sb.append(city);
    this.setVariableValue("AllCities", sb.toString());
}
项目:jasperreports    文件:Scriptlet.java   
@Override
public void afterGroupInit(String groupName) throws JRScriptletException
{
    if (groupName.equals("CityGroup"))
    {
        System.out.println("call       afterGroupInit  : City = " + this.getFieldValue("City"));

        String allCities = (String)this.getVariableValue("AllCities");
        String city = (String)this.getFieldValue("City");
        StringBuilder sb = new StringBuilder();

        if (allCities != null)
        {
            sb.append(allCities);
            sb.append(", ");
        }

        sb.append(city);
        this.setVariableValue("AllCities", sb.toString());
    }
}
项目:PDFReporter-Studio    文件:Scriptlet.java   
/**
 *
 */
public void afterGroupInit(String groupName) throws JRScriptletException
{
    if (groupName.equals("CityGroup"))
    {
        System.out.println("call       afterGroupInit  : City = " + this.getFieldValue("City"));

        String allCities = (String)this.getVariableValue("AllCities");
        String city = (String)this.getFieldValue("City");
        StringBuffer sbuffer = new StringBuffer();

        if (allCities != null)
        {
            sbuffer.append(allCities);
            sbuffer.append(", ");
        }

        sbuffer.append(city);
        this.setVariableValue("AllCities", sbuffer.toString());
    }
}
项目:PDFReporter-Studio    文件:DataPreviewScriptlet.java   
@Override
public void afterDetailEval() throws JRScriptletException {
    if(columns==null){
        columns=(List<String>) getParameterValue(PARAM_COLUMNS);
    }
    if(listeners==null){
        listeners=(List<DatasetReaderListener>) getParameterValue(PARAM_LISTENERS);
    }

    Object[] record=new Object[columns.size()];
    int i=0;
    for(String col : columns){
        record[i++]=getFieldValue(col);
    }

    for(DatasetReaderListener l : listeners){
        if(!l.isValidStatus()){
            // This "dirty" solution will stop report running
            throw new DataPreviewInterruptedException(Messages.DataPreviewScriptlet_InterruptErrorMsg);
        }
        l.newRecord(record);
    }

    super.afterDetailEval();
}
项目:jasperreports    文件:XChartScriptlet.java   
@Override
public void afterReportInit() throws JRScriptletException 
{
    try 
    {
        XYChart xyChart = new XYChartBuilder()
                .width(515)
                .height(400)
                .title("Fruits Order")
                .xAxisTitle("Day of Week")
                .yAxisTitle("Quantity (t)")
                .build();

        xyChart.addSeries("Apples", new double[] { 1, 3, 5}, new double[] {4, 10, 7});
        xyChart.addSeries("Bananas", new double[] { 1, 2, 3, 4, 5}, new double[] {6, 8, 4, 4, 6});
        xyChart.addSeries("Cherries", new double[] { 1, 3, 4, 5}, new double[] {2, 6, 1, 9});
        XYStyler styler = xyChart.getStyler();
        styler.setLegendPosition(Styler.LegendPosition.InsideNW);
        styler.setAxisTitlesVisible(true);
        styler.setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Area);
        styler.setChartBackgroundColor(Color.WHITE);

        BufferedImage bufferedImage = BitmapEncoder.getBufferedImage(xyChart);
        super.setVariableValue("ChartImage", bufferedImage);
    }
    catch(Exception e) 
    {
        throw new JRScriptletException(e);
    }
}
项目:jasperreports    文件:JFreeChartScriptlet.java   
@Override
public void afterReportInit() throws JRScriptletException
{
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Java", new Double(43.2));
    dataset.setValue("Visual Basic", new Double(10.0));
    dataset.setValue("C/C++", new Double(17.5));
    dataset.setValue("PHP", new Double(32.5));
    dataset.setValue("Perl", new Double(1.0));

    JFreeChart chart = 
        ChartFactory.createPieChart3D(
            "Pie Chart 3D Demo 1",
            dataset,
            true,
            true,
            false
            );

    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");

    /*   */
    this.setVariableValue("Chart", new JCommonDrawableRendererImpl(chart));
}
项目:jasperreports    文件:Scriptlet.java   
@Override
public void beforeGroupInit(String groupName) throws JRScriptletException
{
    if (groupName.equals("CityGroup"))
    {
        System.out.println("call       beforeGroupInit : City = " + this.getFieldValue("City"));
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void beforeReportInit() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().beforeReportInit();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void afterReportInit() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().afterReportInit();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void beforePageInit() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().beforePageInit();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void afterPageInit() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().afterPageInit();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void beforeColumnInit() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().beforeColumnInit();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void afterColumnInit() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().afterColumnInit();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void beforeGroupInit(String groupName) throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().beforeGroupInit(groupName);
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void afterGroupInit(String groupName) throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().afterGroupInit(groupName);
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void beforeDetailEval() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().beforeDetailEval();
    }
}
项目:jasperreports    文件:JRFillDatasetScriptlet.java   
@Override
public void afterDetailEval() throws JRScriptletException
{
    for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();)
    {
        it.next().afterDetailEval();
    }
}
项目:jasperreports    文件:DatasetSortUtil.java   
@Override
protected void detail() throws JRScriptletException, JRException 
{
    super.detail();

    List<RecordField> recordFields = sortInfo.getRecordFields();
    int fieldCount = recordFields.size();

    Object[] record = new Object[fieldCount];
    int index = 0;
    for (RecordField recordField : recordFields)
    {
        Object value;
        if (recordField.isVariable())
        {
            value = dataset.getVariableValue(recordField.getName());
        }
        else
        {
            value = dataset.getFieldValue(recordField.getName());
        }

        record[index] = value;
        ++index;
    }

    // also store the original record index
    SortRecord sortRecord = new SortedDataSource.SortRecord(record, recordIndex);

    ++recordIndex;

    records.add(sortRecord);
}
项目:jasperreports    文件:JRFillDatasetRun.java   
protected void group() throws JRException, JRScriptletException
{
    dataset.calculator.estimateGroupRuptures();

    dataset.delegateScriptlet.callBeforeGroupInit();
    dataset.calculator.initializeVariables(ResetTypeEnum.GROUP, IncrementTypeEnum.GROUP);
    dataset.delegateScriptlet.callAfterGroupInit();
}
项目:jasperreports    文件:TimeoutGovernor.java   
@Override
public void beforeDetailEval() throws JRScriptletException
{
    long ellapsedTime = System.currentTimeMillis() - startTime;
    if (timeout < ellapsedTime)
    {
        throw 
            new TimeoutGovernorException(
                ((JasperReport)getParameterValue(JRParameter.JASPER_REPORT, false)).getName(),
                timeout
                );
    }
}
项目:jasperreports    文件:MaxPagesGovernor.java   
@Override
public void afterPageInit() throws JRScriptletException
{
    // cannot use PAGE_NUMBER variable because of timing issues and because of isResetPageNumber flag
    pages++;
    if (maxPages < pages)
    {
        throw 
            new MaxPagesGovernorException(
                ((JasperReport)getParameterValue(JRParameter.JASPER_REPORT, false)).getName(),
                maxPages
                );
    }
}
项目:PDFReporter-Studio    文件:Scriptlet.java   
/**
 *
 */
public void beforeGroupInit(String groupName) throws JRScriptletException
{
    if (groupName.equals("CityGroup"))
    {
        System.out.println("call       beforeGroupInit : City = " + this.getFieldValue("City"));
    }
}
项目:gsn    文件:ReportScriptlet.java   
private void setServerTimeZone () throws JRScriptletException {
    this.setVariableValue("serverTimeZone", 
            TimeZone.getDefault().getDisplayName().toString() + 
            " - " +
            TimeZone.getDefault().getID().toString()
    );
}
项目:gsn    文件:ReportScriptlet.java   
@SuppressWarnings("unchecked")
private void setListOfVirtualSensors () throws JRScriptletException {
    Collection<VirtualSensor> virtualSensors = (Collection<VirtualSensor>) this.getFieldValue("virtualSensors");
    StringBuilder sb = new StringBuilder () ;
    Iterator iter = (Iterator) virtualSensors.iterator();
    String nextName;
    while (iter.hasNext()) {
        nextName = ((VirtualSensor)iter.next()).getVirtualSensorName();
        sb.append(nextName);
        if (iter.hasNext()) sb.append(", ") ;
    }
    this.setVariableValue("listOfVirtualSensors", sb.toString());
}
项目:dynamicreports-jasper    文件:JasperScriptlet.java   
private JasperCustomValues getCustomValues() {
    try {
        return (JasperCustomValues) getParameterValue(JasperCustomValues.NAME, false);
    } catch (JRScriptletException e) {
        throw new JasperDesignException("Custom values not found", e);
    }
}
项目:dynamicreports-jasper    文件:JasperScriptlet.java   
@Override
public void afterReportInit() throws JRScriptletException {
    super.afterReportInit();
    JasperCustomValues customValues = getCustomValues();
    if (customValues != null) {
        customValues.setJasperScriptlet(this);
    }
}
项目:dynamicreports-jasper    文件:CustomScriptlet.java   
private JasperReportParameters getReportParameters() {
    if (reportParameters == null) {
        try {
            reportParameters = ((JasperScriptlet) getParameterValue(JasperScriptlet.SCRIPTLET_NAME)).getReportParameters();
        } catch (JRScriptletException e) {          
        }
    }
    return reportParameters;
}
项目:dynamicreports-jasper    文件:JasperReportParameters.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getFieldValue(String name) {
    try {
        return (T) jasperScriptlet.getFieldValue(name);
    } catch (JRScriptletException e) {
        throw new DRReportException(e);
    }
}
项目:dynamicreports-jasper    文件:JasperReportParameters.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getVariableValue(String name) {
    try {
        return (T) jasperScriptlet.getVariableValue(name);
    } catch (JRScriptletException e) {
        throw new DRReportException(e);
    }
}
项目:dynamicreports-jasper    文件:JasperReportParameters.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getParameterValue(String name) {
    try {
        return (T) ((Map<?, ?>) jasperScriptlet.getParameterValue(JRParameter.REPORT_PARAMETERS_MAP)).get(name);
    } catch (JRScriptletException e) {
        throw new DRReportException(e);
    }
}
项目:dynamicreports-jasper    文件:StartPageNumberScriptlet.java   
private JasperCustomValues getCustomValues() {
    try {
        return (JasperCustomValues) getParameterValue(JasperCustomValues.NAME, false);
    } catch (JRScriptletException e) {
        throw new JasperDesignException("Custom values not found", e);
    }
}
项目:dynamicreports-jasper    文件:StartPageNumberScriptlet.java   
@Override
public void afterReportInit() throws JRScriptletException {
    super.afterReportInit();
    JasperCustomValues customValues = getCustomValues();
    if (customValues != null && customValues.getStartPageNumber() != null) {
        setVariableValue(JRVariable.PAGE_NUMBER, customValues.getStartPageNumber());
    }
}
项目:dynamicreports-jasper    文件:ReportScriptlet.java   
@Override
public void beforeDetailEval() throws JRScriptletException {
    super.beforeDetailEval();
    dynamicSubreport = report();
    dynamicSubreport
      .setPageFormat(515, PageType.A4.getHeight(), PageOrientation.PORTRAIT)
      .setPageMargin(margin(0))
      .columns(
        col.column("Column1", "field1", type.stringType()),
        col.column("Column2", "field2", type.integerType()))
      .title(cmp.text("dynamic subreport"));
}
项目:dynamicreports-jasper    文件:ReportScriptlet.java   
@Override
public void beforeDetailEval() throws JRScriptletException {
    super.beforeDetailEval();
    dynamicSubreport = report();
    dynamicSubreport
      .setTemplate(Templates.reportTemplate)
      .setPageFormat(515, PageType.A4.getHeight(), PageOrientation.PORTRAIT)
      .setPageMargin(margin(0))
      .columns(
        col.column("Item",        "item",      type.stringType()),
        col.column("Quantity",    "quantity",  type.integerType()),
        col.column("Unit price",  "unitprice", type.integerType()))
      .title(cmp.text("Dynamic subreport").setStyle(Templates.bold12CenteredStyle));
}
项目:jasperreports    文件:WebappScriptlet.java   
/**
 *
 */
public String hello() throws JRScriptletException
{
    return "Hello! I'm the report's scriptlet object.";
}
项目:jasperreports    文件:WebappScriptlet.java   
/**
 *
 */
public String hello() throws JRScriptletException
{
    return "Hello! I'm the report's scriptlet object.";
}
项目:jasperreports    文件:Scriptlet.java   
@Override
public void beforeReportInit() throws JRScriptletException
{
    System.out.println("call beforeReportInit");
}
项目:jasperreports    文件:Scriptlet.java   
@Override
public void afterReportInit() throws JRScriptletException
{
    System.out.println("call afterReportInit");
}
项目:jasperreports    文件:Scriptlet.java   
@Override
public void beforePageInit() throws JRScriptletException
{
    System.out.println("call   beforePageInit : PAGE_NUMBER = " + this.getVariableValue("PAGE_NUMBER"));
}