Changeset 2778


Ignore:
Timestamp:
05/11/07 14:38:41 (13 years ago)
Author:
curtis
Message:

Rearrange methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/DataTools.java

    r2526 r2778  
    380380  } 
    381381 
     382  // -- Byte swapping -- 
     383 
     384  public static short swap(short x) { 
     385    return (short) ((x << 8) | ((x >> 8) & 0xFF)); 
     386  } 
     387 
     388  public static char swap(char x) { 
     389    return (char) ((x << 8) | ((x >> 8) & 0xFF)); 
     390  } 
     391 
     392  public static int swap(int x) { 
     393    return (int) ((swap((short) x) << 16) | (swap((short) (x >> 16)) & 0xFFFF)); 
     394  } 
     395 
     396  public static long swap(long x) { 
     397    return (long) (((long) swap((int) x) << 32) | 
     398      ((long) swap((int) (x >> 32)) & 0xFFFFFFFFL)); 
     399  } 
     400 
     401  // -- Miscellaneous -- 
     402 
    382403  /** Remove null bytes from a string. */ 
    383404  public static String stripString(String toStrip) { 
     
    490511  } 
    491512 
    492   // -- Byte swapping -- 
    493  
    494   public static short swap(short x) { 
    495     return (short) ((x << 8) | ((x >> 8) & 0xFF)); 
    496   } 
    497  
    498   public static char swap(char x) { 
    499     return (char) ((x << 8) | ((x >> 8) & 0xFF)); 
    500   } 
    501  
    502   public static int swap(int x) { 
    503     return (int) ((swap((short) x) << 16) | (swap((short) (x >> 16)) & 0xFFFF)); 
    504   } 
    505  
    506   public static long swap(long x) { 
    507     return (long) (((long) swap((int) x) << 32) | 
    508       ((long) swap((int) (x >> 32)) & 0xFFFFFFFFL)); 
    509   } 
    510  
    511513} 
Note: See TracChangeset for help on using the changeset viewer.