Changeset 5903 for branches/cleanup


Ignore:
Timestamp:
02/11/10 14:12:06 (10 years ago)
Author:
melissa
Message:

Added provider for ByteArrayHandles constructed from existing byte arrays and fixed bugs exposed by the new provider.

Location:
branches/cleanup/components/common
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/common/src/loci/common/ByteArrayHandle.java

    r5897 r5903  
    101101  public void setLength(long length) throws IOException { 
    102102    if (length > buffer.capacity()) { 
    103       ByteBuffer tmp = ByteBuffer.allocate((int) (length() * 2)); 
    104       tmp.put(buffer); 
    105       buffer = tmp; 
     103      long fp = getFilePointer(); 
     104      ByteBuffer tmp = ByteBuffer.allocate((int) (length * 2)); 
     105      ByteOrder order = buffer == null ? null : getOrder(); 
     106      seek(0); 
     107      buffer = tmp.put(buffer); 
     108      if (order != null) setOrder(order); 
     109      seek(fp); 
    106110    } 
    107111    buffer.limit((int) length); 
     
    157161  /* @see IRandomAccess.seek(long) */ 
    158162  public void seek(long pos) throws IOException { 
    159     validateLength((int) pos); 
     163    if (pos > length()) setLength(pos); 
    160164    buffer.position((int) pos); 
    161165  } 
  • branches/cleanup/components/common/test/loci/common/utests/providers/IRandomAccessProviderFactory.java

    r5876 r5903  
    4343  static { 
    4444    providers.put("NewByteArrayHandle", new NewByteArrayHandleProvider()); 
     45    providers.put("ExistingByteArrayHandle", 
     46      new ExistingByteArrayHandleProvider()); 
    4547    providers.put("ByteArrayHandle", new ByteArrayHandleProvider()); 
    4648    providers.put("BZip2Handle", new BZip2HandleProvider()); 
  • branches/cleanup/components/common/test/loci/common/utests/testng-template.xml

    r5876 r5903  
    1616        <parameter name="provider" value="NewByteArrayHandle"/> 
    1717        <parameter name="checkGrowth" value="true"/> 
     18        <groups> 
     19            <run> 
     20                <include name="writeTests"/> 
     21                <exclude name="initialLengthTest"/> 
     22            </run> 
     23        </groups> 
     24        <packages> 
     25            <package name="loci.common.utests"/> 
     26        </packages> 
     27    </test> 
     28    <test name="ExistingByteArrayHandle"> 
     29        <parameter name="provider" value="ExistingByteArrayHandle"/> 
    1830        <groups> 
    1931            <run> 
Note: See TracChangeset for help on using the changeset viewer.