/** * Creates the congfiguration instance. * * @return the congfiguration instance. */ public LinkConstructorStrategyConfig build() { if (reportLocation == null) { throw new IllegalArgumentException( "The report location must not be 'null'"); } if (StringUtils.isBlank(labelKey)) { throw new IllegalArgumentException( "The label for the link must not be blank."); } return new LinkConstructorStrategyConfig(this); }
/** * Adds the type part of the link. * * @param buffer the buffer to append to. * @param typeName the name of the package to render. * @impl The default implementation adds the extension separated by a dot. */ protected void appendTypePart(final StringBuilder buffer, final String typeName) { buffer.append(typeName).append('.').append(config.getExtension()); }
/** * Returns the key to the label to use as a label for the rendered link. * * @return the key to the label to use as a label for the rendered link. */ public String getLabelKey() { return strategy.getConfig().getLabelKey(); }
private boolean isReferencedReportExisting(final JavaElementRef ref) { final File baseDir = config.getReportLocation(); final StringBuilder buffer = new StringBuilder(); constructFilePath(buffer, ref); final String filePath = buffer.toString(); final File file = new File(baseDir, filePath); return file.exists(); }
/** * Constructs a path to the specified Java element. * * @param baseLink the base link to prepend. * @param ref the element in the report to reference. * @return the path to the element or <code>null</code> if the referenced * element does not exit (only the existence of the file is checked, * not the element within the file). */ public String constructLink(final String baseLink, final JavaElementRef ref) { if (isReferencedReportExisting(ref)) { final StringBuilder buffer = new StringBuilder(64); buffer.append(baseLink); appendBasePathSeparator(buffer); addQualifiedType(buffer, ref); final MethodInfo memberName = ref.getElementName(); if (config.isReferenceMember() && memberName != null) { appendMemberPart(buffer, memberName); } return buffer.toString(); } return null; }
private String createRelativeReportLocationLink(final ReportId reportId, final LinkConstructorStrategy strategy) { final LinkConstructorStrategyConfig config = strategy.getConfig(); final File reportLocation = config.getReportLocation(); final String reportArtifactId = reportId.getReportArtifactId(); final String location; if (reportLocation.exists() || isReportPluginRegistered(reportArtifactId)) { location = calcRelativePath(reportLocation); } else { location = null; if (log != null && log.isWarnEnabled()) { log.warn("Cannot locate report of '" + reportArtifactId + "'. Disabling references to that report."); } } return location; }