Changeset 7083


Ignore:
Timestamp:
10/18/10 10:56:23 (9 years ago)
Author:
melissa
Message:

Added better type detection to the text reader, see  omero:#2740.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/components/bio-formats/src/loci/formats/in/TextReader.java

    r7007 r7083  
    100100  public TextReader() { 
    101101    super("Text", new String[] {"txt", "csv"}); 
     102    suffixSufficient = false; 
    102103  } 
    103104 
     
    111112 
    112113  // -- IFormatReader methods -- 
     114 
     115  /* @see IFormatReader#isThisType(RandomAccessInputStream) */ 
     116  public boolean isThisType(RandomAccessInputStream stream) throws IOException { 
     117    final int blockLen = 8192; 
     118    if (!FormatTools.validStream(stream, blockLen, false)) return false; 
     119    String data = stream.readString(blockLen); 
     120    List<String> lines = Arrays.asList(data.split("\n")); 
     121    String[] line = getNextLine(lines); 
     122    return line != null; 
     123  } 
    113124 
    114125  /* @see IFormatReader#openBytes(int, byte[], int, int, int, int) */ 
     
    155166      channels = null; 
    156167      sizeX = sizeY = 0; 
     168      row = 0; 
    157169    } 
    158170  } 
  • trunk/components/bio-formats/src/loci/formats/in/TextReader.java

    r6881 r7083  
    100100  public TextReader() { 
    101101    super("Text", new String[] {"txt", "csv"}); 
     102    suffixSufficient = false; 
    102103  } 
    103104 
     
    111112 
    112113  // -- IFormatReader methods -- 
     114 
     115  /* @see IFormatReader#isThisType(RandomAccessInputStream) */ 
     116  public boolean isThisType(RandomAccessInputStream stream) throws IOException { 
     117    final int blockLen = 8192; 
     118    if (!FormatTools.validStream(stream, blockLen, false)) return false; 
     119    String data = stream.readString(blockLen); 
     120    List<String> lines = Arrays.asList(data.split("\n")); 
     121    String[] line = getNextLine(lines); 
     122    return line != null; 
     123  } 
    113124 
    114125  /* @see IFormatReader#openBytes(int, byte[], int, int, int, int) */ 
     
    155166      channels = null; 
    156167      sizeX = sizeY = 0; 
     168      row = 0; 
    157169    } 
    158170  } 
Note: See TracChangeset for help on using the changeset viewer.