本文整理了Java中fr.opensagres.xdocreport.core.XDocReportException
类的一些代码示例,展示了XDocReportException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XDocReportException
类的具体详情如下:
包路径:fr.opensagres.xdocreport.core.XDocReportException
类名称:XDocReportException
[英]XDocReport exception.
[中]XDocReport异常。
代码示例来源:origin: opensagres/xdocreport.samples
public static void main( String[] args )
{
try
{
// 1) Load Docx file by filling Velocity template engine and cache
// it to the registry
InputStream in =
DocxNativeLineBreakAndTabWithVelocity.class.getResourceAsStream( "DocxNativeLineBreakAndTabWithVelocity.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity );
// 2) Create context Java model
IContext context = report.createContext();
context.put( "comments", "aaa\tbbb\nccc\n\nddd\n\teeee\n\t\tfff\n\nggg\t\thhh" );
// 3) Generate report by merging Java model with the Docx
OutputStream out = new FileOutputStream( new File( "DocxNativeLineBreakAndTabWithVelocity_Out.docx" ) );
report.process( context, out );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
private void checkOriginalArchive()
throws XDocReportException
{
if ( originalArchive == null )
{
throw new XDocReportException(
"Original document archive is not available. Call IXDocReport#setCacheOriginalDocument(true) before loading document." );
}
}
代码示例来源:origin: opensagres/xdocreport.samples
public static void main( String[] args )
{
try
{
// 1) Load ODT file by filling Freemarker template engine and cache
// it to the registry
InputStream in =
ODTNativeLineBreakAndTabWithFreemarker.class.getResourceAsStream( "ODTNativeLineBreakAndTabWithFreemarker.odt" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Freemarker );
// 2) Create context Java model
IContext context = report.createContext();
context.put( "comments", "aaa\tbbb\nccc\n\nddd\n\teeee\n\t\tfff\n\nggg\t\thhh" );
// 3) Generate report by merging Java model with the ODT
OutputStream out = new FileOutputStream( new File( "ODTNativeLineBreakAndTabWithFreemarker_Out.odt" ) );
report.process( context, out );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
/**
* Retruns zipped XML document (odt, docx...) and throws {@link XDocReportException} if it is not defined.
*
* @return
* @throws XDocReportException
*/
private XDocArchive internalGetDocumentArchive()
throws XDocReportException
{
if ( preprocessedArchive == null )
{
throw new XDocReportException(
"Null document archive (odt, docx). Load document archive (docx, odt....file) with IXDocReport#load." );
}
return preprocessedArchive;
}
代码示例来源:origin: opensagres/xdocreport.samples
public static void main( String[] args )
{
try
{
// 1) Load ODT file by filling Velocity template engine and cache
// it to the registry
InputStream in =
ODTNativeLineBreakAndTabWithVelocity.class.getResourceAsStream( "ODTNativeLineBreakAndTabWithVelocity.odt" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity );
// 2) Create context Java model
IContext context = report.createContext();
context.put( "comments", "aaa\tbbb\nccc\n\nddd\n\teeee\n\t\tfff\n\nggg\t\thhh" );
// 3) Generate report by merging Java model with the ODT
OutputStream out = new FileOutputStream( new File( "ODTNativeLineBreakAndTabWithVelocity_Out.odt" ) );
report.process( context, out );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
/**
* Returns template engine (freemarker, velocity...) to use for the report generation and throws
* {@link XDocReportException} if template engien is not defined.
*
* @return
* @throws XDocReportException
*/
private ITemplateEngine internalGetTemplateEngine()
throws XDocReportException
{
if ( templateEngine == null )
{
throw new XDocReportException(
"Null template engine. Set template engine with IXDocReport#setTemplateEngine." );
}
return templateEngine;
}
代码示例来源:origin: opensagres/xdocreport.samples
public static void main( String[] args )
{
try
{
// 1) Load Docx file by filling Freemarker template engine and cache
// it to the registry
InputStream in =
DocxNativeLineBreakAndTabWithFreemarker.class.getResourceAsStream( "DocxNativeLineBreakAndTabWithFreemarker.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Freemarker );
// 2) Create context Java model
IContext context = report.createContext();
context.put( "comments", "aaa\tbbb\nccc\n\nddd\n\teeee\n\t\tfff\n\nggg\t\thhh" );
// 3) Generate report by merging Java model with the Docx
OutputStream out = new FileOutputStream( new File( "DocxNativeLineBreakAndTabWithFreemarker_Out.docx" ) );
report.process( context, out );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.remoting.shared
private ByteArrayInputStream getInputStream( byte[] document )
throws XDocReportException
{
if ( document == null )
{
throw new XDocReportException( "Byte array of the document cannot be null." );
}
return new ByteArrayInputStream( document );
}
代码示例来源:origin: opensagres/xdocreport.samples
e.printStackTrace();
} catch (XDocReportException e) {
e.printStackTrace();
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
/**
* Check if registry can register the report with this id.
*
* @param reportId
* @throws XDocReportException
*/
public void checkReportId( String reportId )
throws XDocReportException
{
if ( cachedReports.containsKey( reportId ) )
{
String msg =
String.format( "Cannot register report. A report with id=%s already exists in the registry", reportId );
LOGGER.warning( msg );
throw new XDocReportException( msg );
}
}
代码示例来源:origin: opensagres/xdocreport.samples
public static void main(String[] args) {
try {
// 1) Load ODT file by filling Velocity template engine and cache
// it to the registry
InputStream in = ODTProjectWithFreemarker.class
.getResourceAsStream("ODTProjectWithFreemarker.odt");
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(
in, TemplateEngineKind.Freemarker);
// 2) Create context Java model
IContext context = report.createContext();
Project project = new Project("XDocReport");
context.put("project", project);
// 3) Generate report by merging Java model with the ODT
OutputStream out = new FileOutputStream(new File(
"ODTProjectWithFreemarker_Out.odt"));
report.process(context, out);
} catch (IOException e) {
e.printStackTrace();
} catch (XDocReportException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
@Override
protected Document getSource( XDocArchive documentArchive, String entryName )
throws XDocReportException, IOException
{
try
{
return DOMUtils.load( documentArchive.getEntryInputStream( entryName ) );
}
catch ( ParserConfigurationException e )
{
throw new XDocReportException( e );
}
catch ( SAXException e )
{
throw new XDocReportException( e );
}
}
代码示例来源:origin: opensagres/xdocreport.samples
public static void main(String[] args) {
try {
// 1) Load ODP file by filling Velocity template engine and cache
// it to the registry
InputStream in = ODPProjectWithVelocity.class
.getResourceAsStream("ODPProjectWithVelocity.odp");
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(
in, TemplateEngineKind.Velocity);
// 2) Create context Java model
IContext context = report.createContext();
Project project = new Project("XDocReport");
context.put("project", project);
// 3) Generate report by merging Java model with the ODP
OutputStream out = new FileOutputStream(new File(
"ODPProjectWithVelocity_Out.odp"));
report.process(context, out);
} catch (IOException e) {
e.printStackTrace();
} catch (XDocReportException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
/**
* Returns the dumper registered with the given kind in the registry.
*
* @param kind the dumper kind.
* @return
* @throws XDocReportException thrown when the dumper is not found.
*/
public IDumper findDumper( String kind )
throws XDocReportException
{
IDumper dumper = getDumper( kind );
if ( dumper == null )
{
String msg = String.format( "Cannot find dumper with kind=%s", dumper );
LOGGER.severe( msg );
throw new XDocReportException( msg );
}
return dumper;
}
代码示例来源:origin: opensagres/xdocreport.samples
public static void main(String[] args) {
try {
// 1) Load Docx file by filling Freemarker template engine and cache
// it to the registry
InputStream in = DocxProjectWithFreemarker.class
.getResourceAsStream("DocxProjectWithFreemarker.docx");
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(
in, TemplateEngineKind.Freemarker);
// 2) Create context Java model
IContext context = report.createContext();
Project project = new Project("XDocReport");
context.put("project", project);
// 3) Generate report by merging Java model with the Docx
OutputStream out = new FileOutputStream(new File(
"DocxProjectWithFreemarker_Out.docx"));
report.process(context, out);
} catch (IOException e) {
e.printStackTrace();
} catch (XDocReportException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
public ITransformResult transform( String content, IDocumentHandler handler )
throws XDocReportException
{
try
{
doTransform( content, handler );
ITransformResult result = handler;
if ( LOGGER.isLoggable( Level.FINE ) )
{
LOGGER.fine( result.toString() );
}
return result;
}
catch ( Throwable e )
{
if ( LOGGER.isLoggable( Level.SEVERE ) )
{
LOGGER.severe( e.getMessage() );
}
if ( e instanceof XDocReportException )
{
throw (XDocReportException) e;
}
throw new XDocReportException( e );
}
}
代码示例来源:origin: opensagres/xdocreport.samples
e.printStackTrace();
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.document
private ImageProviderInfo processNullImage( String fieldName, IImageProvider imageProvider )
throws XDocReportException
{
NullImageBehaviour behaviour = getBehaviour( imageProvider, getFieldBehaviour( fieldName ), defaultBehaviour );
switch ( behaviour )
{
case RemoveImageTemplate:
return ImageProviderInfo.RemoveImageTemplate;
case KeepImageTemplate:
return ImageProviderInfo.KeepImageTemplate;
}
throw new XDocReportException( "Image provider for field [" + fieldName + "] cannot be null!" );
}
代码示例来源:origin: opensagres/xdocreport.samples
e.printStackTrace();
代码示例来源:origin: fr.opensagres/fr.opensagres.xdocreport.template.velocity
protected synchronized VelocityEngine getVelocityEngine()
throws XDocReportException {
if (velocityEngine == null) {
velocityEngine = new VelocityEngine();
Properties p = new Properties();
// Initialize properties to use XDocReportEntryResourceLoader to
// load template from entry name of XDocArchive.
p.setProperty("resource.loader", "file, class, jar ,report");
p.setProperty("report.resource.loader.class",
XDocReportEntryResourceLoader.class.getName());
p.setProperty("report.resource.loader.cache", "true");
p.setProperty("report.resource.loader.modificationCheckInterval",
"1");
ITemplateEngineConfiguration configuration = super
.getConfiguration();
if (configuration != null && configuration.escapeXML()) {
p.setProperty("eventhandler.referenceinsertion.class",
XDocReportEscapeReference.class.getName());
}
try {
velocityEngine.setProperty(VELOCITY_TEMPLATE_ENGINE_KEY, this);
velocityEngine.init(p);
} catch (Exception e) {
throw new XDocReportException(e);
}
}
return velocityEngine;
}
内容来源于网络,如有侵权,请联系作者删除!