Examples of JRException


Examples of net.sf.jasperreports.engine.JRException

      firstPageIndex < 0 ||
      firstPageIndex > lastPageIndex ||
      lastPageIndex >= jasperPrint.getPages().size()
      )
    {
      throw new JRException(
        "Invalid page index range : " +
        firstPageIndex + " - " +
        lastPageIndex + " of " +
        jasperPrint.getPages().size()
        );
    }

    pageOffset = firstPageIndex;

    PrinterJob printJob = PrinterJob.getPrinterJob();

    // fix for bug ID 6255588 from Sun bug database
    initPrinterJobFields(printJob);
   
    PageFormat pageFormat = printJob.defaultPage();
    Paper paper = pageFormat.getPaper();

    printJob.setJobName("JasperReports - " + jasperPrint.getName());
   
    switch (jasperPrint.getOrientationValue())
    {
      case LANDSCAPE :
      {
        pageFormat.setOrientation(PageFormat.LANDSCAPE);
        paper.setSize(jasperPrint.getPageHeight(), jasperPrint.getPageWidth());
        paper.setImageableArea(
          0,
          0,
          jasperPrint.getPageHeight(),
          jasperPrint.getPageWidth()
          );
        break;
      }
      case
      PORTRAIT :
      default :
      {
        pageFormat.setOrientation(PageFormat.PORTRAIT);
        paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight());
        paper.setImageableArea(
          0,
          0,
          jasperPrint.getPageWidth(),
          jasperPrint.getPageHeight()
          );
      }
    }

    pageFormat.setPaper(paper);

    Book book = new Book();
    book.append(this, pageFormat, lastPageIndex - firstPageIndex + 1);
    printJob.setPageable(book);
    try
    {
      if (withPrintDialog)
      {
        if (printJob.printDialog())
        {
          printJob.print();
        }
        else
        {
          isOK = false;
        }
      }
      else
      {
        printJob.print();
      }
    }
    catch (Exception ex)
    {
      throw new JRException("Error printing report.", ex);
    }

    return isOK;
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

    String location = atts.getValue(ATTRIBUTE_valueLocation);
    ValueLocationEnum loc = ValueLocationEnum.getByName(atts.getValue(ATTRIBUTE_valueLocation));
    if (loc == null)
    {
      throw new JRException("Invalid thermometer value location: " + location);
    }
    else
    {
      thermometerPlot.setValueLocation(loc);
    }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

          {
            destFile = new File(fileName);
          }
          else
          {
            throw new JRException("No output specified for the exporter.");
          }
        }

        try
        {
          os = new FileOutputStream(destFile);
          exportReportToStream(os);
          os.flush();
        }
        catch (IOException e)
        {
          throw new JRException("Error trying to export to file : " + destFile, e);
        }
        finally
        {
          if (os != null)
          {
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

          for(int pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++)
          {
            if (Thread.interrupted())
            {
              throw new JRException("Current thread interrupted.");
            }

            JRPrintPage page = (JRPrintPage)pages.get(pageIndex);

            document.newPage();
           
            pdfContentByte = pdfWriter.getDirectContent();

            pdfContentByte.setLineCap(2);//PdfContentByte.LINE_CAP_PROJECTING_SQUARE since iText 1.02b

            writePageAnchor(pageIndex);

            /*   */
            exportPage(page);
          }
        }
        else
        {
          document.newPage();
          pdfContentByte = pdfWriter.getDirectContent();
          pdfContentByte.setLiteral("\n");
        }
      }

      closeDocuments = false;
      document.close();
      imageTesterDocument.close();
    }
    catch(DocumentException e)
    {
      throw new JRException("PDF Document error : " + jasperPrint.getName(), e);
    }
    catch(IOException e)
    {
      throw new JRException("Error generating PDF report : " + jasperPrint.getName(), e);
    }
    finally
    {
      if (closeDocuments) //only on exception
      {
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

            /*
             * Everything in the result is a string, apart from Member
             */
            if (valueClass.equals(mondrian.olap.Member.class)) {
                if (!(value instanceof mondrian.olap.Member)) {
                    throw new JRException("Field '" + jrField.getName() + "' is of class '"
                        + value.getClass()
                        + "' and can not be converted to class " + valueClass.getName());
                }

                return value;
            }

            /*
             * Convert the rest from String
             */
            String fieldValue = (String) value;

            if (fieldValue == null)
            { 
              return null;
            }
            if (Number.class.isAssignableFrom(valueClass)){
                fieldValue = fieldValue.trim();
            }
            if (fieldValue.length() == 0){
               fieldValue = "0";
            }

            if (valueClass.equals(String.class)) {
                return fieldValue;
            } else if (valueClass.equals(Boolean.class)) {
                return fieldValue.equalsIgnoreCase("true") ? Boolean.TRUE : Boolean.FALSE;
            } else if (valueClass.equals(Byte.class)) {
                return new Byte(fieldValue);
            } else if (valueClass.equals(Integer.class)) {
                return Integer.valueOf(fieldValue);
            } else if (valueClass.equals(Long.class)) {
                return new Long(fieldValue);
            } else if (valueClass.equals(Short.class)) {
                return new Short(fieldValue);
            } else if (valueClass.equals(Double.class)) {
                return new Double(fieldValue);
            } else if (valueClass.equals(Float.class)) {
                return new Float(fieldValue);
            } else if (valueClass.equals(java.math.BigDecimal.class)) {
                return new java.math.BigDecimal(fieldValue);
            } else if (valueClass.equals(java.util.Date.class)) {
                return dateFormat.parse(fieldValue);
            } else if (valueClass.equals(java.sql.Timestamp.class)) {
                return new java.sql.Timestamp(dateFormat.parse(fieldValue).getTime());
            } else if (valueClass.equals(java.sql.Time.class)) {
                return new java.sql.Time(dateFormat.parse(fieldValue).getTime());
            } else if (valueClass.equals(java.lang.Number.class)) {
                return new Double(fieldValue);
            } else {
                throw new JRException("Field '" + jrField.getName() + "', string value '" + fieldValue + "' is of class '"
                + fieldValues.get(jrField.getName()).getClass()
                + "' and can not be converted to class " + valueClass.getName());
            }
        } catch (Exception e) {
            throw new JRException("Unable to get value for field '" + jrField.getName() + "' of class '" + valueClass.getName() + "'", e);
        }
    }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

    {
       ds = new JRCsvDataSource(reader);
    }
    else
    {
      throw new JRException("Cannot find a source to read the data from");
    }

    ds.setDateFormat(dateFormat);
    ds.setNumberFormat(numberFormat);
    ds.setFieldDelimiter(fieldDelimiter);
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

      {
        value = PropertyUtils.getProperty(bean, propertyName);
      }
      catch (java.lang.IllegalAccessException e)
      {
        throw new JRException("Error retrieving field value from bean : " + propertyName, e);
      }
      catch (java.lang.reflect.InvocationTargetException e)
      {
        throw new JRException("Error retrieving field value from bean : " + propertyName, e);
      }
      catch (java.lang.NoSuchMethodException e)
      {
        throw new JRException("Error retrieving field value from bean : " + propertyName, e);
      }
      catch (IllegalArgumentException e)
      {
        //FIXME replace with NestedNullException when upgrading to BeanUtils 1.7
        if (!e.getMessage().startsWith("Null property value for "))
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

      for (int i = 0; i < sourceFiles.length; ++i)
      {
        files.append(sourceFiles[i].getPath());
        files.append(' ');
      }
      throw new JRException("Error compiling report java source files : " + files, e);
    }
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

    {
      return createDocumentBuilder().parse(is);
    }
    catch (SAXException e)
    {
      throw new JRException("Failed to parse the xml document", e);
    }
    catch (IOException e)
    {
      throw new JRException("Failed to parse the xml document", e);
    }
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRException

    {
      return createDocumentBuilder().parse(file);
    }
    catch (SAXException e)
    {
      throw new JRException("Failed to parse the xml document", e);
    }
    catch (IOException e)
    {
      throw new JRException("Failed to parse the xml document", e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.