本文整理汇总了Java中net.sf.jasperreports.engine.util.JRSaver类的典型用法代码示例。如果您正苦于以下问题:Java JRSaver类的具体用法?Java JRSaver怎么用?Java JRSaver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRSaver类属于net.sf.jasperreports.engine.util包,在下文中一共展示了JRSaver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performAction
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
@Override
public void performAction()
{
// JasperDesign jasperDesign = getJasperDesign();
JasperDesignCache cache = JasperDesignCache.getInstance(getJasperReportsContext(), getReportContext());
Map<String, JasperDesignReportResource> cachedResources = cache.getCachedResources();
for (String uri : cachedResources.keySet())
{
JasperDesignReportResource resource = cachedResources.get(uri);
JasperDesign jasperDesign = resource.getJasperDesign();
if (jasperDesign != null)
{
JasperReport jasperReport = resource.getReport();
String appRealPath = null;//FIXMECONTEXT WebFileRepositoryService.getApplicationRealPath();
try
{
JRSaver.saveObject(jasperReport, new File(new File(new File(appRealPath), "WEB-INF/repository"), uri));//FIXMEJIVE harcoded
}
catch (JRException e)
{
throw new JRRuntimeException(e);
}
}
}
}
示例2: save
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
@Override
public void save(JasperPrint jasperPrint, File file) throws JRException
{
if (!file.getName().toLowerCase().endsWith(EXTENSION_JRPRINT))
{
file = new File(file.getAbsolutePath() + EXTENSION_JRPRINT);
}
if (
!file.exists() ||
JOptionPane.OK_OPTION ==
JOptionPane.showConfirmDialog(
null,
MessageFormat.format(
getBundleString("file.exists"),
new Object[]{file.getName()}
),
getBundleString("save"),
JOptionPane.OK_CANCEL_OPTION
)
)
{
JRSaver.saveObject(jasperPrint, file);
}
}
示例3: getSourceFile
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
protected File getSourceFile(File saveSourceDir, String unitName, JRCompilationSourceCode sourceCode)
{
File sourceFile = null;
if (saveSourceDir != null && sourceCode != null && sourceCode.getCode() != null)
{
String fileName = getSourceFileName(unitName);
sourceFile = new File(saveSourceDir, fileName);
try
{
JRSaver.saveClassSource(sourceCode.getCode(), sourceFile);
}
catch (JRException e)
{
throw new JRRuntimeException(e);
}
}
return sourceFile;
}
示例4: fillToFile
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
* Fills the compiled report design loaded from the specified file.
* The result of this operation is another file that will contain the serialized
* {@link JasperPrint} object representing the generated document,
* having the same name as the report design as declared in the source file,
* plus the <code>*.jrprint</code> extension, located in the same directory as the source file.
*
* @param sourceFileName source file containing the compile report design
* @param params report parameters map
* @param connection JDBC connection object to use for executing the report internal SQL query
*/
public String fillToFile(
String sourceFileName,
Map<String,Object> params,
Connection connection
) throws JRException
{
File sourceFile = new File(sourceFileName);
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile);
File destFile = new File(sourceFile.getParent(), jasperReport.getName() + ".jrprint");
String destFileName = destFile.toString();
JasperReportsContext lcJrCtx = getLocalJasperReportsContext(sourceFile);
JasperPrint jasperPrint = JRFiller.fill(lcJrCtx, jasperReport, params, connection);
JRSaver.saveObject(jasperPrint, destFileName);
return destFileName;
}
示例5: writeObject
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException {
if (object == null || !(object instanceof JasperReport))
throw new DatabindingException("Erro ao tentar converter JasperReport para array de bytes!");
JasperReport jasperReport = (JasperReport) object;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
JRSaver.saveObject(jasperReport, baos);
} catch (JRException e) {
throw new DatabindingException("Erro ao tentar salvar arquivo jasper para byte array!", e);
}
super.writeObject(baos.toByteArray(), writer, context);
}
示例6: exportWithProgress
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
@Override
protected void exportWithProgress(File file, JRExportProgressMonitor monitor) throws Throwable {
final java.io.File f = file.getAbsoluteFile();
final Throwable[] ex = new Throwable[1];
BusyIndicator.showWhile(null, new Runnable() {
public void run() {
try {
JRSaver.saveObject(getReportViewer().getReport(), f);
} catch (Throwable e) {
ex[0] = e;
}
}
});
if (ex[0] != null)
throw ex[0];
}
示例7: compileToFile
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
* Compile Template Design and produce .jasper file
*
* @throws IDXReportException
*/
private void compileToFile() {
try {
log.info("JRXML_FILE:" + JRXML_FILENAME);
setJasperDesign(JRXmlLoader.load(new FileInputStream(JRXML_FILENAME)));
/*
* JasperDesign design = JRXmlLoader.load(
new LegacyJasperInputStream(new FileInputStream("MyXsdBasedDesign.jrxml"))
);
*/
if (getJasperDesign() == null) {
log.error("jasper design is null");
}
setJasperReport(JasperCompileManager.compileReport(getJasperDesign()));
JRSaver.saveObject(getJasperReport(), JASPER_FILENAME);
} catch (FileNotFoundException ex) {
log.error(ex);
} catch (JRException jre) {
jre.printStackTrace();
}
}
示例8: compileReport
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
public JasperReport compileReport( final File sourcePath, final File outputPath,
String reportName) throws Throwable
{
String name = reportName;
if (!name.contains(".jasper"))
{
name = name+".jasper";
}
JasperReport jasperReport = null;
JasperDesign jasperDesign = getDesignFile(sourcePath, reportName);
File outputReport = new File(outputPath.getAbsolutePath() + "/" + name);
jasperReport = JasperCompileManager.compileReport(jasperDesign);
JRSaver.saveObject(jasperReport, outputReport);
logger.warn("Saving compiled report : " + outputReport.getName());
// Compile sub reports
JRElementsVisitor.visitReport(jasperReport, createVisitor(sourcePath, outputPath));
if (subReportException != null)
throw new RuntimeException(subReportException);
return jasperReport;
}
示例9: fill
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
long start = System.currentTimeMillis();
JasperPrint jasperPrint = getJasperPrint();
JRSaver.saveObject(jasperPrint, "build/reports/PrintServiceReport.jrprint");
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
示例10: fill
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
long start = System.currentTimeMillis();
JasperPrint jasperPrint = getJasperPrint();
JRSaver.saveObject(jasperPrint, "build/reports/NoReport.jrprint");
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
示例11: compileToFile
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
* Compiles the report design object received as the first parameter, placing the result
* in the file specified by the second parameter.
* The resulting file will contain a serialized instance of a
* {@link net.sf.jasperreports.engine.JasperReport} object representing the compiled report design.
*
* @param jasperDesign source report design object
* @param destFileName file name to place the compiled report design into
*/
public void compileToFile(
JasperDesign jasperDesign,
String destFileName
) throws JRException
{
JasperReport jasperReport = compile(jasperDesign);
JRSaver.saveObject(jasperReport, destFileName);
}
示例12: compileToStream
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
* Compiles the report design object represented by the first parameter and
* writes the generated compiled report design object to the output stream specified
* by the second parameter.
*
* @param jasperDesign source report design object
* @param outputStream output stream to write the compiled report design to
*/
public void compileToStream(
JasperDesign jasperDesign,
OutputStream outputStream
) throws JRException
{
JasperReport jasperReport = compile(jasperDesign);
JRSaver.saveObject(jasperReport, outputStream);
}
示例13: fillToStream
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
/**
* Fills the compiled report design supplied as the first parameter and writes
* the generated report object to the output stream specified by the second parameter.
*
* @param jasperReport compiled report design object to use for filling
* @param outputStream output stream to write the generated report object to
* @param parameters report parameters map
* @param connection JDBC connection object to use for executing the report internal SQL query
*/
public void fillToStream(
JasperReport jasperReport,
OutputStream outputStream,
Map<String,Object> parameters,
Connection connection
) throws JRException
{
JasperPrint jasperPrint = fill(jasperReport, parameters, connection);
JRSaver.saveObject(jasperPrint, outputStream);
}
示例14: compile
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
private void compile() throws JRException {
jasperReport = JasperCompileManager.compileReport(jasperDesign);
// this option is only available if command process is active
if (config.isWriteJasper()) {
String inputBasename = inputFile.getName().split("\\.(?=[^\\.]+$)")[0];
String outputDir = inputFile.getParent();
File outputFile = new File(outputDir + "/" + inputBasename + ".jasper");
JRSaver.saveObject(jasperReport, outputFile);
}
}
示例15: compileToFile
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
public void compileToFile() {
if (initialInputType == InputType.JASPER_DESIGN) {
try {
JRSaver.saveObject(jasperReport, this.output.getAbsolutePath() + ".jasper");
} catch (JRException ex) {
throw new IllegalArgumentException("outputFile" + this.output.getAbsolutePath() + ".jasper" + "could not be written");
}
} else {
throw new IllegalArgumentException("input file: \"" + inputFile + "\" is not a valid jrxml file");
}
}