/** * Default constructor. * * @param packageName the name of the package. * @param typeName the name of the Java class. * @param elementName the name of the element. * @throws IllegalArgumentException if <code>typeName</code> is blank or * <code>packageName</code> is empty or consists only of * whitespaces. * @todo All elements are currently provided to be fully URL encoded. */ public JavaElementRef(final String packageName, final String typeName, final MethodInfo elementName) throws IllegalArgumentException { checkArguments(packageName, typeName); this.packageName = packageName; this.typeName = typeName; this.elementName = elementName; }
/** * 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); }
/** * Constructs a link to the given Java element. * * @param packageName packageName the name of the package. * @param typeName typeName the name of the Java type. * @param method the test method to link to. * @return the requested relative link. */ public String constructLink(final String packageName, final String typeName, final MethodInfo method) { final JavaElementRef ref = new JavaElementRef(packageName, typeName, method); return constructLink(ref); }
/** * 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; }