All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.conqat.lib.commons.string.LineRange Maven / Gradle / Ivy

The newest version!
package org.conqat.lib.commons.string;

public class LineRange {

	/** The start line (1-based). */
	private final int start;

	/** The end line (1-based). */
	private int end;

	/** Constructor. */
	public LineRange(int start, int end) {
		this.start = start;
		this.end = end;
	}

	/** @see #end */
	public int getEnd() {
		return end;
	}

	/** @see #end */
	public void setEnd(int end) {
		this.end = end;
	}

	/**
	 * Returns the line range as used in the XML report. A range is returned as e.g. 2-5 or simply 3 if
	 * the start and end are equal.
	 */
	private String toReportString() {
		if (start == end) {
			return String.valueOf(start);
		} else {
			return start + "-" + end;
		}
	}

	@Override
	public String toString() {
		return toReportString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy