/** * Creates a new {@link IApiProblem} * * @param resourcepath the path to the resource this problem was found in * @param typeName the type name this problem was found in * @param messageargs listing of arguments to pass in to the localized * message. The arguments are passed into the string in the order * they appear in the array. * @param argumentids the ids of arguments passed into the problem * @param arguments the arguments that correspond to the listing of ids * @param linenumber the number of the line the problem occurred on * @param charstart the start of a char selection range * @param charend the end of a char selection range * @param id the composite id of the problem * @return a new {@link IApiProblem} */ public static IApiProblem newApiProblem(String resourcepath, String typeName, String[] messageargs, String[] argumentids, Object[] arguments, int linenumber, int charstart, int charend, int id) { return new ApiProblem(resourcepath, typeName, messageargs, argumentids, arguments, linenumber, charstart, charend, id); }
@Override public int hashCode() { return getId() + (fResourcePath != null ? fResourcePath.hashCode() : 0) + argumentsHashcode(fMessageArguments) + (fTypeName != null ? fTypeName.hashCode() : 0); }
/** * Returns the string representation of the kind of an {@link IApiProblem}, * given its category * * @param category * @param kind * @return the string of the {@link IApiProblem} kind */ public static String getProblemKind(int category, int kind) { switch (category) { case IApiProblem.CATEGORY_COMPATIBILITY: return Util.getDeltaKindName(kind); case IApiProblem.CATEGORY_SINCETAGS: return ApiProblem.getTagsProblemKindName(kind); case IApiProblem.CATEGORY_USAGE: return ApiProblem.getUsageProblemKindName(kind); case IApiProblem.CATEGORY_VERSION: return ApiProblem.getVersionProblemKindName(kind); case IApiProblem.CATEGORY_API_BASELINE: return ApiProblem.getApiBaselineProblemKindName(kind); case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION: return ApiProblem.getApiComponentResolutionProblemKindName(kind); case IApiProblem.CATEGORY_API_USE_SCAN_PROBLEM: return ApiProblem.getApiUseScanProblemKindName(kind); default: return Util.UNKNOWN_KIND; } }
@Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("API problem: "); //$NON-NLS-1$ buffer.append(fResourcePath != null ? fResourcePath : "no path").append("\n"); //$NON-NLS-1$//$NON-NLS-2$ buffer.append("\tseverity: "); //$NON-NLS-1$ buffer.append(Util.getSeverity(getSeverity())).append("\n"); //$NON-NLS-1$ buffer.append("\tcategory: "); //$NON-NLS-1$ buffer.append(ApiProblem.getProblemCategory(getCategory())).append("\n"); //$NON-NLS-1$ buffer.append("\telement kind: "); //$NON-NLS-1$ buffer.append(ApiProblem.getProblemElementKind(getCategory(), getElementKind())).append("\n"); //$NON-NLS-1$ buffer.append("\tkind: "); //$NON-NLS-1$ buffer.append(ApiProblem.getProblemKind(getCategory(), getKind())).append("\n"); //$NON-NLS-1$ buffer.append("\tflags: "); //$NON-NLS-1$ buffer.append(ApiProblem.getProblemFlagsName(getCategory(), getFlags())).append("\n"); //$NON-NLS-1$ buffer.append("\tmessage id: "); //$NON-NLS-1$ buffer.append(getMessageid()); buffer.append("\n\tmessage: "); //$NON-NLS-1$ buffer.append(getMessage()); return buffer.toString(); }
/** * Returns the string representation of the element kind of an * {@link IApiProblem}, given its category * * @param category * @param kind * @return the string of the {@link IApiProblem} element kind */ public static String getProblemElementKind(int category, int kind) { switch (category) { case IApiProblem.CATEGORY_COMPATIBILITY: case IApiProblem.CATEGORY_SINCETAGS: { return Util.getDeltaElementType(kind); } case IApiProblem.CATEGORY_USAGE: case IApiProblem.CATEGORY_VERSION: case IApiProblem.CATEGORY_API_BASELINE: case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION: { return ApiProblem.getDescriptorKind(kind); } case IApiProblem.CATEGORY_API_USE_SCAN_PROBLEM: { return Util.getApiElementType(kind); } default: return Util.UNKNOWN_KIND; } }
@Override public boolean equals(Object obj) { if (obj instanceof IApiProblem) { IApiProblem problem = (IApiProblem) obj; if (problem.getId() == fId && argumentsEqual(problem.getMessageArguments())) { String resourcePath = problem.getResourcePath(); if (resourcePath == null) { if (this.fResourcePath != null) { return false; } } else if (this.fResourcePath == null) { return false; } else if (!new Path(resourcePath).equals(new Path(fResourcePath))) { return false; } String typeName = problem.getTypeName(); if (typeName == null) { if (this.fTypeName != null) { return false; } return true; } else if (this.fTypeName == null) { return false; } return typeName.equals(this.fTypeName); } return false; } return super.equals(obj); }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (IApiXmlConstants.ELEMENT_API_PROBLEM.equalsIgnoreCase(qName)) { String[] argumentids = new String[extraargs.size()]; Object[] arguments = new Object[extraargs.size()]; int i = 0; for (Entry<String, String> entry : extraargs.entrySet()) { argumentids[i] = entry.getKey(); arguments[i] = entry.getValue(); } ApiProblem problem = new ApiProblem(null, typename, messageargs.toArray(new String[messageargs.size()]), argumentids, arguments, linenumber, charstart, charend, id); problems.add(problem); } }