Changeset 1486 for trunk/bindings/java/org/nexusformat/NexusFile.java
- Timestamp:
- 24/06/10 11:46:44 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/java/org/nexusformat/NexusFile.java
r1474 r1486 311 311 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 312 312 checkType(type); 313 checkForNull(name); 313 checkForNull(name, rank, iChunk); 314 checkForNegInIntArray(true, dim, iChunk); 314 315 switch(compression_type) { 315 316 case NexusFile.NX_COMP_NONE: … … 320 321 321 322 } 322 nxmakecompdata(handle, name,type,rank,dim,compression_type, iChunk);323 nxmakecompdata(handle, name, type, rank, dim, compression_type, iChunk); 323 324 } 324 325 … … 340 341 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 341 342 checkType(type); 342 checkForNull(name); 343 nxmakedata(handle,name,type,rank,dim); 343 checkForNull(name, dim); 344 checkForNegInIntArray(true, dim); 345 nxmakedata(handle, name, type, rank, dim); 344 346 } 345 347 /** … … 442 444 byte bdata[]; 443 445 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 444 checkForNull(array); 446 checkForNull(start, size, array); 447 checkForNegInIntArray(false, start, size); 445 448 try{ 446 449 HDFArray ha = new HDFArray(array); … … 529 532 530 533 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 531 checkForNull(array); 534 checkForNull(array, start, size); 535 checkForNegInIntArray(false, start,size); 532 536 try{ 533 537 HDFArray ha = new HDFArray(array); … … 741 745 } 742 746 747 /** 748 * checks if any of the ints in the arrays are negative, 749 * throws appropriate runtime exception if so 750 * for some being zero is stupid, but hopefully not fatal 751 */ 752 private void checkForNegInIntArray(boolean allowUnlimited, int[]... args) { 753 boolean first=true; 754 for (int[] array : args) 755 for (int value: array) { 756 if (value<0) 757 if (value == this.NX_UNLIMITED && allowUnlimited && first) { 758 // all ok this time 759 } else 760 throw new IllegalArgumentException("negative dimension received"); 761 first=false; 762 } 763 } 743 764 /** 744 765 * checkType verifies if a parameter is a valid NeXus type code.
Note: See TracChangeset
for help on using the changeset viewer.
