class DataUtilities {

	public static boolean isUndefinedRange(Program program, Address startAddress,
			Address endAddress) {
		MemoryBlock block = program.getMemory().getBlock(startAddress);
		// start and end address must be in the same block of memory.
		if (block == null || !block.contains(endAddress)) {
			return false;
		}
		if (startAddress.compareTo(endAddress) > 0) {
			return false; // start shouldn't be after end.
		}
		Listing listing = program.getListing();
		Data data = listing.getDataContaining(startAddress);
		if (data == null || !Undefined.isUndefined(data.getDataType())) {
			return false; // Instruction or Defined Data at startAddress.
		}
		Address maxAddress = data.getMaxAddress();
		while (maxAddress.compareTo(endAddress) < 0) {
			CodeUnit codeUnit = listing.getDefinedCodeUnitAfter(maxAddress);
			if (codeUnit == null) {
				return true; // No more instructions or Defined Data.
			}
			Address minAddress = codeUnit.getMinAddress();
			if (minAddress.compareTo(endAddress) > 0) {
				return true; // Beyond endAddress so all are undefined.
			}
			if (!(codeUnit instanceof Data) ||
				!Undefined.isUndefined(((Data) codeUnit).getDataType())) {
				return false; // Instruction or Defined Data in range.
			}
			maxAddress = codeUnit.getMaxAddress();
		}
		return true; // Got to endAddress with only undefined.
	}

	private  DataUtilities();

}