/** * Equality operation. * @param other the object to compare to. * @return true if the other object contains the same information * as this object. * @since Ant 1.6.3 */ @Override public boolean equals(Object other) { return this == other || other != null && other.getClass() == getClass() && toString().equals(other.toString()); }
/** * Returns the location of the error and the error message. * * @return the location of the error and the error message */ public String toString() { return location.toString() + getMessage(); }
/** * Fired when a task starts building, this pushes a timed element * for the task onto the stack of elements for the current thread, * remembering the current time and the name of the task. * * @param event An event with any relevant extra information. * Will not be <code>null</code>. */ @Override public void taskStarted(BuildEvent event) { TimedElement taskElement = new TimedElement(); taskElement.startTime = System.currentTimeMillis(); taskElement.element = doc.createElement(TASK_TAG); Task task = event.getTask(); String name = event.getTask().getTaskName(); if (name == null) { name = ""; } taskElement.element.setAttribute(NAME_ATTR, name); taskElement.element.setAttribute(LOCATION_ATTR, event.getTask().getLocation().toString()); tasks.put(task, taskElement); getStack().push(taskElement); }
/** * Add location to build exception. * @param ex the build exception, if the build exception * does not include * @param newLocation the location of the calling task (may be null) * @return a new build exception based in the build exception with * location set to newLocation. If the original exception * did not have a location, just return the build exception */ public static BuildException addLocationToBuildException( BuildException ex, Location newLocation) { if (ex.getLocation() == null || ex.getMessage() == null) { return ex; } String errorMessage = String.format("The following error occurred while executing this line:%n%s%s", ex.getLocation().toString(), ex.getMessage()); if (ex instanceof ExitStatusException) { int exitStatus = ((ExitStatusException) ex).getStatus(); if (newLocation == null) { return new ExitStatusException(errorMessage, exitStatus); } return new ExitStatusException(errorMessage, exitStatus, newLocation); } if (newLocation == null) { return new BuildException(errorMessage, ex); } return new BuildException(errorMessage, ex, newLocation); }
public String getUri() { Location loc = getLocation(); return loc == null ? null : loc.toString(); }
/** * Wraps a Ant {@link BuildException} to an {@link InstallerException}. * This is mainly done for the purpose of cutting of the location from the build failure message. * Locations should appear just in logs, not to the user. * * @param e the {@link IzPackException} with the nested {@link BuildException} * @throws InstallerException */ public void throwBuildException(IzPackException e) throws InstallerException { String message; Throwable cause = e.getCause(), nested = e; IzPackException ize = e; while (cause != null) { nested = cause; cause = cause.getCause(); } if (nested instanceof BuildException) { // Workaround for BuildException.toString(): // Filter off the location, just leave the clean failure message Location location = ((BuildException)nested).getLocation(); message = nested.toString().substring(location.toString().length()); ize = new IzPackException(message, e, severity); } throw new InstallerException(ize); }
String location = target.getLocation().toString(); if (!targetMap.containsKey(location) || targetMap.get(location).length() > targetName.length()) {