Package org.jacoco.report.internal
Class ReportOutputFolder
- java.lang.Object
-
- org.jacoco.report.internal.ReportOutputFolder
-
public class ReportOutputFolder extends java.lang.ObjectLogical representation of a folder in the output structure. This utility ensures valid and unique file names and helps to create relative links.
-
-
Field Summary
Fields Modifier and Type Field Description private NormalizedFileNamesfileNamesprivate IMultiReportOutputoutputprivate ReportOutputFolderparentprivate java.lang.Stringpathprivate java.util.Map<java.lang.String,ReportOutputFolder>subFoldersCached sub-folder instances to guarantee stable normalization
-
Constructor Summary
Constructors Modifier Constructor Description ReportOutputFolder(IMultiReportOutput output)Creates a new root folder for the given output.privateReportOutputFolder(IMultiReportOutput output, ReportOutputFolder parent, java.lang.String path)Creates a new root folder for the given output.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.OutputStreamcreateFile(java.lang.String name)Creates a new file in this folder with the given local name.java.lang.StringgetLink(ReportOutputFolder base, java.lang.String name)Returns a link relative to a given base to a resource within this folder.private booleanisAncestorOf(ReportOutputFolder folder)private java.lang.Stringnormalize(java.lang.String name)ReportOutputFoldersubFolder(java.lang.String name)Creates a sub-folder with the given name.
-
-
-
Field Detail
-
output
private final IMultiReportOutput output
-
parent
private final ReportOutputFolder parent
-
path
private final java.lang.String path
-
subFolders
private final java.util.Map<java.lang.String,ReportOutputFolder> subFolders
Cached sub-folder instances to guarantee stable normalization
-
fileNames
private final NormalizedFileNames fileNames
-
-
Constructor Detail
-
ReportOutputFolder
public ReportOutputFolder(IMultiReportOutput output)
Creates a new root folder for the given output.- Parameters:
output- output for generated files
-
ReportOutputFolder
private ReportOutputFolder(IMultiReportOutput output, ReportOutputFolder parent, java.lang.String path)
Creates a new root folder for the given output.- Parameters:
output- output for generated files
-
-
Method Detail
-
subFolder
public ReportOutputFolder subFolder(java.lang.String name)
Creates a sub-folder with the given name.- Parameters:
name- name of the sub-folder- Returns:
- handle for output into the sub-folder
-
createFile
public java.io.OutputStream createFile(java.lang.String name) throws java.io.IOExceptionCreates a new file in this folder with the given local name.- Parameters:
name- name of the sub-folder- Returns:
- handle for output into the sub-folder
- Throws:
java.io.IOException- if the file creation fails
-
getLink
public java.lang.String getLink(ReportOutputFolder base, java.lang.String name)
Returns a link relative to a given base to a resource within this folder.- Parameters:
base- base to create the relative link fromname- name of the file or folder in this folder- Returns:
- relative link
- Throws:
java.lang.IllegalArgumentException- if this folder and the base do not have the same root
-
isAncestorOf
private boolean isAncestorOf(ReportOutputFolder folder)
-
normalize
private java.lang.String normalize(java.lang.String name)
-
-