Whitespace and indentation canonicalization. That's what I get for using two editors.
This commit is contained in:
1 parent
d54ad18b17
commit
8bcd8a4a75
18 files changed
+5249
-5250
No files matched your search
@@ -11,77 +11,77 @@ import com.loomcom.symon.exceptions.*;
|
||||
*/
|
||||
public class MemoryRange implements Comparable<MemoryRange> {
|
||||
|
||||
/** The starting address of the memory range. */
|
||||
public int startAddress;
|
||||
/** The ending address of the memory range. */
|
||||
public int endAddress;
|
||||
/** The starting address of the memory range. */
|
||||
public int startAddress;
|
||||
/** The ending address of the memory range. */
|
||||
public int endAddress;
|
||||
|
||||
public MemoryRange(int startAddress, int endAddress)
|
||||
throws MemoryRangeException {
|
||||
if (startAddress < 0 || endAddress < 0) {
|
||||
throw new MemoryRangeException("Addresses cannot be less than 0.");
|
||||
}
|
||||
if (startAddress >= endAddress) {
|
||||
throw new MemoryRangeException("End address must be greater " +
|
||||
"than start address.");
|
||||
}
|
||||
this.startAddress = startAddress;
|
||||
this.endAddress = endAddress;
|
||||
}
|
||||
public MemoryRange(int startAddress, int endAddress)
|
||||
throws MemoryRangeException {
|
||||
if (startAddress < 0 || endAddress < 0) {
|
||||
throw new MemoryRangeException("Addresses cannot be less than 0.");
|
||||
}
|
||||
if (startAddress >= endAddress) {
|
||||
throw new MemoryRangeException("End address must be greater " +
|
||||
"than start address.");
|
||||
}
|
||||
this.startAddress = startAddress;
|
||||
this.endAddress = endAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the starting address.
|
||||
*/
|
||||
public int startAddress() {
|
||||
return startAddress;
|
||||
}
|
||||
/**
|
||||
* @returns the starting address.
|
||||
*/
|
||||
public int startAddress() {
|
||||
return startAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the ending address.
|
||||
*/
|
||||
public int endAddress() {
|
||||
return endAddress;
|
||||
}
|
||||
/**
|
||||
* @returns the ending address.
|
||||
*/
|
||||
public int endAddress() {
|
||||
return endAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for address inclusion in the range.
|
||||
*
|
||||
* @returns true if the address is included within this range,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean includes(int address) {
|
||||
return (address <= endAddress &&
|
||||
address >= startAddress);
|
||||
}
|
||||
/**
|
||||
* Checks for address inclusion in the range.
|
||||
*
|
||||
* @returns true if the address is included within this range,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean includes(int address) {
|
||||
return (address <= endAddress &&
|
||||
address >= startAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for overlapping memory ranges.
|
||||
*
|
||||
* @returns true if this range overlaps in any way with the other.
|
||||
*/
|
||||
public boolean overlaps(MemoryRange other) {
|
||||
return (this.includes(other.startAddress()) ||
|
||||
other.includes(this.startAddress()));
|
||||
}
|
||||
/**
|
||||
* Checks for overlapping memory ranges.
|
||||
*
|
||||
* @returns true if this range overlaps in any way with the other.
|
||||
*/
|
||||
public boolean overlaps(MemoryRange other) {
|
||||
return (this.includes(other.startAddress()) ||
|
||||
other.includes(this.startAddress()));
|
||||
}
|
||||
|
||||
// Implementation of Comparable interface
|
||||
public int compareTo(MemoryRange other) {
|
||||
if (other == null) {
|
||||
throw new NullPointerException("Cannot compare to null.");
|
||||
}
|
||||
if (this == other) {
|
||||
return 0;
|
||||
}
|
||||
Integer thisStartAddr = new Integer(this.startAddress());
|
||||
Integer thatStartAddr = new Integer(other.startAddress());
|
||||
return thisStartAddr.compareTo(thatStartAddr);
|
||||
}
|
||||
// Implementation of Comparable interface
|
||||
public int compareTo(MemoryRange other) {
|
||||
if (other == null) {
|
||||
throw new NullPointerException("Cannot compare to null.");
|
||||
}
|
||||
if (this == other) {
|
||||
return 0;
|
||||
}
|
||||
Integer thisStartAddr = new Integer(this.startAddress());
|
||||
Integer thatStartAddr = new Integer(other.startAddress());
|
||||
return thisStartAddr.compareTo(thatStartAddr);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer desc = new StringBuffer("@");
|
||||
desc.append(String.format("0x%04x", startAddress));
|
||||
desc.append("-");
|
||||
desc.append(String.format("0x%04x", endAddress));
|
||||
return desc.toString();
|
||||
}
|
||||
public String toString() {
|
||||
StringBuffer desc = new StringBuffer("@");
|
||||
desc.append(String.format("0x%04x", startAddress));
|
||||
desc.append("-");
|
||||
desc.append(String.format("0x%04x", endAddress));
|
||||
return desc.toString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user