private String computePath( final BundleWriterState state ) { final String absolutePathWithDummy = IOUtils.getInstance().getAbsolutePath( "dummy", state.getFileName() ); final String absolutePath = absolutePathWithDummy.substring( 0, absolutePathWithDummy.length() - "dummy".length() ); if ( absolutePath.endsWith( "/" ) ) { return absolutePath.substring( 0, absolutePath.length() - 1 ); } return absolutePath; } }
public BundleWriterState( final BundleWriterState parent, final AbstractReportDefinition report, final String bundleFileName ) { if ( report == null ) { throw new NullPointerException(); } if ( parent == null ) { throw new NullPointerException(); } if ( bundleFileName == null ) { throw new NullPointerException(); } this.masterReport = parent.masterReport; this.globalBundle = parent.globalBundle; this.bundleWriter = parent.bundleWriter; this.report = report; this.bundleFileName = IOUtils.getInstance().getAbsolutePath( bundleFileName, parent.getFileName() ); }
/** * Returns an unique name for the given pattern, producing a file relative to the parent file name. The returned path * will be an <b>absolute</b> path starting from the root of the bundle. When linking to this path via href-references * that imply relative paths, use {@link org.pentaho.reporting.libraries.base.util.IOUtils#createRelativePath(java * .lang.String, * java.lang.String)} to transform the absolute path returned here into a path relative to your current context. * * @param bundle the document bundle for which we seek a new unique file name. * @param parent the parent path to which the pattern is relative to. * @param pattern the file name pattern. We expect one parameter only. * @return the unique file name, never null. * @throws IllegalStateException if the first 2 million entries we test do not yield a unique name we can use. */ public static String getUniqueName( final DocumentBundle bundle, final String parent, final String pattern ) { final String fullPattern = IOUtils.getInstance().getAbsolutePath( pattern, parent ); return getUniqueName( bundle, fullPattern ); }