本文整理汇总了Java中net.sf.jasperreports.engine.util.JRSaver.saveObject方法的典型用法代码示例。如果您正苦于以下问题:Java JRSaver.saveObject方法的具体用法?Java JRSaver.saveObject怎么用?Java JRSaver.saveObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.util.JRSaver
的用法示例。
在下文中一共展示了JRSaver.saveObject方法的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: 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;
}
示例4: 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);
}
示例5: 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();
}
}
示例6: 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;
}
示例7: 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));
}
示例8: 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));
}
示例9: 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);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
}
示例13: 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");
}
}
示例14: compileReportToTempFile
import net.sf.jasperreports.engine.util.JRSaver; //导入方法依赖的package包/类
/**
*
* @param name the fileName in the jar, but without jrxml
* @return
*/
private String compileReportToTempFile(final String name) {
// Optimize, only do it on updates.
String reportFile = TempUtil.getDirectory("jasper") + "/" + name + ".jasper";
URL url = Objects.requireNonNull(getClass().getResource(name + ".jrxml"), "The Resource " + getClass().getPackage() + "/" + name + ".jrxml not found.");
try (InputStream is = url.openStream()) {
JRSaver.saveObject(JasperCompileManager.compileReport(is), reportFile);
return reportFile;
} catch (IOException | JRException ex) {
throw new RuntimeException(ex);
}
}
示例15: fillReportToFile
import net.sf.jasperreports.engine.util.JRSaver; //导入方法依赖的package包/类
/**
* Filling compiled report template and store JasperPrint Object to file.
*
* @param dest
* Destination path and file name.
*
*/
protected void fillReportToFile(String dest) {
if (null == getJasperPrint()) {
fillReport();
}
try {
JRSaver.saveObject(getJasperPrint(), dest);
} catch (JRException jre) {
jre.printStackTrace();
}
}