本文整理汇总了Java中net.sf.jasperreports.engine.util.JRSaver类的典型用法代码示例。如果您正苦于以下问题:Java JRSaver类的具体用法?Java JRSaver怎么用?Java JRSaver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRSaver类属于net.sf.jasperreports.engine.util包,在下文中一共展示了JRSaver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:26,代码来源:SaveAction.java
示例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);
}
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:26,代码来源:JRPrintSaveContributor.java
示例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;
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:20,代码来源:JRAbstractCompiler.java
示例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;
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:33,代码来源:JasperFillManager.java
示例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);
}
开发者ID:darciopacifico,项目名称:omr,代码行数:17,代码来源:JazzJasperTypeCreator.java
示例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];
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:ExportAsJasperReportsAction.java
示例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();
}
}
开发者ID:rmage,项目名称:gnvc-ims,代码行数:28,代码来源:ReportGenerator.java
示例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;
}
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:23,代码来源:JasperReportCompiler.java
示例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));
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:11,代码来源:PrintServiceApp.java
示例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));
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:11,代码来源:NoReportApp.java
示例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);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:19,代码来源:JasperCompileManager.java
示例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);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:JasperCompileManager.java
示例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);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:JasperFillManager.java
示例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);
}
}
开发者ID:vosskaem,项目名称:jasperstarter,代码行数:11,代码来源:Report.java
示例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");
}
}
开发者ID:vosskaem,项目名称:jasperstarter,代码行数:12,代码来源:Report.java
示例16: 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);
}
}
开发者ID:gg-net,项目名称:dwoss,代码行数:17,代码来源:SalesListingProducerOperation.java
示例17: 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();
}
}
开发者ID:rmage,项目名称:gnvc-ims,代码行数:19,代码来源:ReportGenerator.java
示例18: serializableTest
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
private JasperPrint serializableTest(JasperPrint jasperPrint) throws IOException, JRException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
JRSaver.saveObject(jasperPrint, bos);
bos.flush();
bos.close();
InputStream stream = new ByteArrayInputStream(bos.toByteArray());
return (JasperPrint) JRLoader.loadObject(stream);
}
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:10,代码来源:AbstractJasperTest.java
示例19: copyJasperDesign
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
public static JasperDesign copyJasperDesign(JasperReportsContext jContext, JasperDesign jrd) throws JRException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
JRSaver.saveObject(jrd, out);
JasperDesign jd = (JasperDesign) JRLoader.loadObject(jContext, new ByteArrayInputStream(out.toByteArray()));
return jd;
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:7,代码来源:ModelUtils.java
示例20: compileJRXML
import net.sf.jasperreports.engine.util.JRSaver; //导入依赖的package包/类
public IFile compileJRXML(IResource resource, IProgressMonitor monitor) throws CoreException {
if (!(resource instanceof IFile && resource.exists() && resource.getFileExtension() != null))
return null;
IProject project = resource.getProject();
IPath outLocation = outmap.get(project);
if (outLocation != null && project.hasNature(JavaCore.NATURE_ID))
outLocation = JavaCore.create(project).getOutputLocation();
if (outLocation != null && outLocation.isPrefixOf(resource.getFullPath()))
return null;
if (resource.getFileExtension().equals(FileExtension.JRXML)) {
long stime = System.currentTimeMillis();
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
IFile destFile = null;
try {
monitor.subTask("Compiling " + resource.getFullPath().toOSString());
Markers.deleteMarkers(resource);
IFile file = (IFile) resource;
ClassLoader cl = clmap.get(project);
if (cl == null) {
cl = ClassLoaderUtil.getClassLoader4Project(SubMonitor.convert(monitor), project);
jContext.setClassLoader(cl);
clmap.put(project, cl);
}
Thread.currentThread().setContextClassLoader(cl);
reportCompiler.setErrorHandler(getErrorHandler(file));
destFile = FileExtension.getCompiledFile(file);
JasperReport jasperReport = null;
// Checks if a potential linked resource really exists
if (file.getLocation().toFile().exists())
jasperReport = reportCompiler.compileReport(jContext, file);
if (jasperReport == null) {
if (destFile.exists())
destFile.delete(true, false, SubMonitor.convert(monitor));
} else {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ByteArrayInputStream compiledInput = null;
try {
JRSaver.saveObject(jasperReport, bout);
compiledInput = new ByteArrayInputStream(bout.toByteArray());
if (destFile.exists()) {
if (file.isLinked() && !destFile.isLinked()) {
destFile.delete(true, false, SubMonitor.convert(monitor));
destFile = createDestFile(monitor, project, file, destFile, compiledInput);
} else
destFile.setContents(compiledInput, true, false, SubMonitor.convert(monitor));
} else
destFile = createDestFile(monitor, project, file, destFile, compiledInput);
if (!destFile.isDerived())
destFile.setDerived(true, SubMonitor.convert(monitor));
} catch (JRException e) {
throw new RuntimeException(e);// TODO
} finally {
FileUtils.closeStream(bout);
FileUtils.closeStream(compiledInput);
}
}
} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}
long etime = System.currentTimeMillis();
System.out.println(resource.getFullPath().toOSString() + " " + (etime - stime) + " ms");
return destFile;
} else if (resource.getFileExtension().equals(FileExtension.JASPER)) {
return compileJRXML(FileExtension.getSourceFile((IFile) resource), monitor);
}
return null;
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:70,代码来源:JasperReportsBuilder.java
注:本文中的net.sf.jasperreports.engine.util.JRSaver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论