/** * Adds package and type part of the element reference. * * @param buffer the buffer to append to. * @param ref the element in the report to reference. */ protected void constructFilePath(final StringBuilder buffer, final JavaElementRef ref) { addQualifiedType(buffer, ref); }
/** * Default constructor. * * @param config the configuration of this strategy instance. * @throws NullArgumentException if <code>config</code> is <code>null</code>. */ protected AbstractLinkConstructorStrategy( final LinkConstructorStrategyConfig config) throws NullArgumentException { checkArguments(config); this.config = config; }
/** * 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; }
/** * Adds package and type part of the element reference. * * @param buffer the buffer to append to. * @param ref the element in the report to reference. */ protected void addQualifiedType(final StringBuilder buffer, final JavaElementRef ref) { final String packageName = ref.getPackageName(); if (StringUtils.isNotBlank(packageName)) { addPackagePart(buffer, packageName); } final String typeName = ref.getTypeName(); appendTypePart(buffer, typeName); }
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(); }