@@ -118,19 +118,16 @@ public class ComponentSampleModel extends SampleModel
118118 * @param scanlineStride the line stride of the region of image
119119 * data described
120120 * @param bandOffsets the offsets of all bands
121- * @throws IllegalArgumentException if {@code w} or
122- * {@code h} is not greater than 0
123- * @throws IllegalArgumentException if {@code pixelStride}
124- * is less than 0
125- * @throws IllegalArgumentException if {@code scanlineStride}
126- * is less than 0
127- * @throws IllegalArgumentException if {@code numBands}
128- * is less than 1
121+ * @throws IllegalArgumentException if {@code w} and {@code h}
122+ * are not both greater than 0
129123 * @throws IllegalArgumentException if the product of {@code w}
130- * and {@code h} is greater than
131- * {@code Integer.MAX_VALUE}
124+ * and {@code h} is greater than {@code Integer.MAX_VALUE}
125+ * @throws IllegalArgumentException if {@code pixelStride} is less than 0
126+ * @throws IllegalArgumentException if {@code scanlineStride} is less than 0
127+ * @throws NullPointerException if {@code bandOffsets} is {@code null}
128+ * @throws IllegalArgumentException if {@code bandOffsets.length} is 0
132129 * @throws IllegalArgumentException if {@code dataType} is not
133- * one of the supported data types
130+ * one of the supported data types for this sample model.
134131 */
135132 public ComponentSampleModel (int dataType ,
136133 int w , int h ,
@@ -150,9 +147,6 @@ public ComponentSampleModel(int dataType,
150147 if (scanlineStride < 0 ) {
151148 throw new IllegalArgumentException ("Scanline stride must be >= 0" );
152149 }
153- if (numBands < 1 ) {
154- throw new IllegalArgumentException ("Must have at least one band." );
155- }
156150 if ((dataType < DataBuffer .TYPE_BYTE ) ||
157151 (dataType > DataBuffer .TYPE_DOUBLE )) {
158152 throw new IllegalArgumentException ("Unsupported dataType." );
@@ -181,19 +175,22 @@ public ComponentSampleModel(int dataType,
181175 * data described
182176 * @param bankIndices the bank indices of all bands
183177 * @param bandOffsets the band offsets of all bands
184- * @throws IllegalArgumentException if {@code w} or
185- * {@code h} is not greater than 0
186- * @throws IllegalArgumentException if {@code pixelStride}
187- * is less than 0
188- * @throws IllegalArgumentException if {@code scanlineStride}
189- * is less than 0
178+ * @throws IllegalArgumentException if {@code w} and {@code h}
179+ * are not both greater than 0
180+ * @throws IllegalArgumentException if the product of {@code w}
181+ * and {@code h} is greater than {@code Integer.MAX_VALUE}
182+ * @throws IllegalArgumentException if {@code pixelStride} is less than 0
183+ * @throws IllegalArgumentException if {@code scanlineStride} is less than 0
184+ * @throws NullPointerException if {@code bankIndices} is {@code null}
185+ * @throws NullPointerException if {@code bandOffsets} is {@code null}
186+ * @throws IllegalArgumentException if {@code bandOffsets.length} is 0
190187 * @throws IllegalArgumentException if the length of
191188 * {@code bankIndices} does not equal the length of
192- * {@code bankOffsets }
189+ * {@code bandOffsets }
193190 * @throws IllegalArgumentException if any of the bank indices
194191 * of {@code bandIndices} is less than 0
195192 * @throws IllegalArgumentException if {@code dataType} is not
196- * one of the supported data types
193+ * one of the supported data types for this sample model
197194 */
198195 public ComponentSampleModel (int dataType ,
199196 int w , int h ,
@@ -207,6 +204,10 @@ public ComponentSampleModel(int dataType,
207204 this .scanlineStride = scanlineStride ;
208205 this .bandOffsets = bandOffsets .clone ();
209206 this .bankIndices = bankIndices .clone ();
207+ if (this .bandOffsets .length != this .bankIndices .length ) {
208+ throw new IllegalArgumentException ("Length of bandOffsets must " +
209+ "equal length of bankIndices." );
210+ }
210211 if (pixelStride < 0 ) {
211212 throw new IllegalArgumentException ("Pixel stride must be >= 0" );
212213 }
@@ -235,10 +236,6 @@ else if (this.bankIndices[i] < 0) {
235236 }
236237 numBanks = maxBank +1 ;
237238 numBands = this .bandOffsets .length ;
238- if (this .bandOffsets .length != this .bankIndices .length ) {
239- throw new IllegalArgumentException ("Length of bandOffsets must " +
240- "equal length of bankIndices." );
241- }
242239 verify ();
243240 }
244241
0 commit comments