Revision: 12393
http://sourceforge.net/p/foray/code/12393
Author: victormote
Date: 2022-01-13 20:48:41 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
Use new MarkedIndexOutOfBoundsException for sequence classes.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -33,6 +33,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.ByteSequenceMutable;
import org.axsl.common.sequence.ByteSequencePlus;
@@ -319,7 +321,7 @@
@Override
public byte byteAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -361,7 +363,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacityInternal(newLength);
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.CharSequenceMutable;
import java.util.Arrays;
@@ -211,7 +213,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacityInternal(newLength);
@@ -253,7 +255,7 @@
@Override
public char charAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.IntSequence;
import org.axsl.common.sequence.IntSequenceMutable;
@@ -79,7 +81,7 @@
@Override
public int intAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -87,13 +89,13 @@
@Override
public IntSequence subSequence(final int start, final int end) {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
if (end > this.length) {
- throw new IndexOutOfBoundsException("Index out of range: " + end);
+ throw new MarkedIndexOutOfBoundsException(end, this.length);
}
if (start > end) {
- throw new StringIndexOutOfBoundsException("Index out of range: " + (end - start));
+ throw new IllegalArgumentException("start " + start + " exceeds end " + end);
}
final IntArrayBuilder returnBuilder = new IntArrayBuilder(this.length);
for (int index = start; index < end; index ++) {
@@ -176,7 +178,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacity(newLength);
if (newLength > this.length) {
@@ -271,7 +273,7 @@
*/
public IntArrayBuilder deleteIntAt(final int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
System.arraycopy(this.backingArray, index + 1, this.backingArray, index, this.length - index - 1);
this.length--;
@@ -291,7 +293,7 @@
*/
public IntArrayBuilder delete(final int start, final int end) throws IndexOutOfBoundsException {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
int adjustedEnd = end;
if (end > this.length) {
@@ -298,7 +300,7 @@
adjustedEnd = this.length;
}
if (start > adjustedEnd) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
final int len = adjustedEnd - start;
if (len > 0) {
@@ -362,7 +364,7 @@
public void insert(final int index, final int newInt) {
if (index < 0
|| index > length()) {
- throw new IndexOutOfBoundsException();
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
ensureCapacity(length() + 1);
System.arraycopy(this.backingArray, index, this.backingArray, index + 1, this.length - index);
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.LongPrimitiveIterator;
import org.axsl.common.sequence.LongSequence;
import org.axsl.common.sequence.LongSequenceMutable;
@@ -81,7 +83,7 @@
@Override
public long longAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -89,10 +91,10 @@
@Override
public LongSequence subSequence(final int start, final int end) {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
if (end > this.length) {
- throw new IndexOutOfBoundsException("Index out of range: " + end);
+ throw new MarkedIndexOutOfBoundsException(end, this.length);
}
if (start > end) {
throw new StringIndexOutOfBoundsException("Index out of range: " + (end - start));
@@ -223,7 +225,7 @@
*/
public LongArrayBuilder deleteLongAt(final int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
System.arraycopy(this.backingArray, index + 1, this.backingArray, index, this.length - index - 1);
this.length--;
@@ -243,7 +245,7 @@
*/
public LongArrayBuilder delete(final int start, final int end) throws IndexOutOfBoundsException {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
int adjustedEnd = end;
if (end > this.length) {
@@ -250,7 +252,7 @@
adjustedEnd = this.length;
}
if (start > adjustedEnd) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
final int len = adjustedEnd - start;
if (len > 0) {
@@ -311,7 +313,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacity(newLength);
if (newLength > this.length) {
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.ShortSequence;
import org.axsl.common.sequence.ShortSequenceMutable;
@@ -79,7 +81,7 @@
@Override
public short shortAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -87,10 +89,10 @@
@Override
public ShortSequence subSequence(final int start, final int end) {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
if (end > this.length) {
- throw new IndexOutOfBoundsException("Index out of range: " + end);
+ throw new MarkedIndexOutOfBoundsException(end, this.length);
}
if (start > end) {
throw new StringIndexOutOfBoundsException("Index out of range: " + (end - start));
@@ -204,7 +206,7 @@
*/
public ShortArrayBuilder deleteShortAt(final int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
System.arraycopy(this.backingArray, index + 1, this.backingArray, index, this.length - index - 1);
this.length--;
@@ -224,7 +226,7 @@
*/
public ShortArrayBuilder delete(final int start, final int end) throws IndexOutOfBoundsException {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
int adjustedEnd = end;
if (end > this.length) {
@@ -277,7 +279,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacity(newLength);
if (newLength > this.length) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|