private void readDataBlockHeader(String tokenToLookFor,NexusBlock block) throws ImportException, IOException {
  boolean dim=false, ttl=false, fmt=false;
  String token;
  do {
    token=readToken();
    if (token.equalsIgnoreCase("TITLE")) {
      if (ttl) {
        throw new DuplicateFieldException("TITLE");
      }
      ttl=true;
    }
 else     if (token.equalsIgnoreCase("DIMENSIONS")) {
      if (dim) {
        throw new DuplicateFieldException("DIMENSIONS");
      }
      boolean nchar=(block == TAXA_BLOCK);
      boolean ntax=(block == CHARACTERS_BLOCK);
      do {
        String token2=readToken("=;");
        if (getLastDelimiter() != '=') {
          throw new BadFormatException("Unknown subcommand, '" + token2 + "', or missing '=' in DIMENSIONS command");
        }
        if (token2.equalsIgnoreCase("NTAX")) {
          if (block == CHARACTERS_BLOCK) {
            throw new BadFormatException("NTAX subcommand in CHARACTERS block");
          }
          taxonCount=readInteger(";");
          ntax=true;
        }
 else         if (token2.equalsIgnoreCase("NCHAR")) {
          if (block == TAXA_BLOCK) {
            throw new BadFormatException("NCHAR subcommand in TAXA block");
          }
          siteCount=readInteger(";");
          nchar=true;
        }
 else {
          throw new BadFormatException("Unknown subcommand, '" + token2 + "', in DIMENSIONS command");
        }
      }
 while (getLastDelimiter() != ';');
      if (!ntax) {
        throw new BadFormatException("NTAX subcommand missing from DIMENSIONS command");
      }
      if (!nchar) {
        throw new BadFormatException("NCHAR subcommand missing from DIMENSIONS command");
      }
      dim=true;
    }
 else     if (token.equalsIgnoreCase("FORMAT")) {
      if (fmt) {
        throw new DuplicateFieldException("FORMAT");
      }
      dataType=null;
      do {
        String token2=readToken("=;");
        if (token2.equalsIgnoreCase("GAP")) {
          if (getLastDelimiter() != '=') {
            throw new BadFormatException("Expecting '=' after GAP subcommand in FORMAT command");
          }
          gapCharacters=readToken(";");
        }
 else         if (token2.equalsIgnoreCase("MISSING")) {
          if (getLastDelimiter() != '=') {
            throw new BadFormatException("Expecting '=' after MISSING subcommand in FORMAT command");
          }
          missingCharacters=readToken(";");
        }
 else         if (token2.equalsIgnoreCase("MATCHCHAR")) {
          if (getLastDelimiter() != '=') {
            throw new BadFormatException("Expecting '=' after MATCHCHAR subcommand in FORMAT command");
          }
          matchCharacters=readToken(";");
        }
 else         if (token2.equalsIgnoreCase("DATATYPE")) {
          if (getLastDelimiter() != '=') {
            throw new BadFormatException("Expecting '=' after DATATYPE subcommand in FORMAT command");
          }
          String token3=readToken(";");
          if (token3.equalsIgnoreCase("NUCLEOTIDE") || token3.equalsIgnoreCase("DNA") || token3.equalsIgnoreCase("RNA")) {
            dataType=Nucleotides.INSTANCE;
          }
 else           if (token3.equalsIgnoreCase("STANDARD") || token3.equalsIgnoreCase("BINARY")) {
            dataType=TwoStates.INSTANCE;
          }
 else           if (token3.equalsIgnoreCase("PROTEIN")) {
            dataType=AminoAcids.INSTANCE;
          }
 else           if (token3.equalsIgnoreCase("CONTINUOUS")) {
            throw new UnparsableDataException("Continuous data cannot be parsed at present");
          }
        }
 else         if (token2.equalsIgnoreCase("INTERLEAVE")) {
          isInterleaved=true;
        }
      }
 while (getLastDelimiter() != ';');
      fmt=true;
    }
  }
 while (!token.equalsIgnoreCase(tokenToLookFor));
  if (!dim) {
    throw new MissingFieldException("DIMENSIONS");
  }
  if (block != TAXA_BLOCK && dataType == null) {
    throw new MissingFieldException("DATATYPE");
  }
}

private void readDataBlockHeader ( String tokenToLookFor , NexusBlock block ) throws ImportException , IOException { boolean dim = false , ttl = false , fmt = false ; String token ; do { token = readToken ( ) ; if ( token . equalsIgnoreCase ( "TITLE" ) ) { if ( ttl ) { throw new DuplicateFieldException ( "TITLE" ) ; } ttl = true ; } else if ( token . equalsIgnoreCase ( "DIMENSIONS" ) ) { if ( dim ) { throw new DuplicateFieldException ( "DIMENSIONS" ) ; } boolean nchar = ( block == TAXA_BLOCK ) ; boolean ntax = ( block == CHARACTERS_BLOCK ) ; do { String token2 = readToken ( "=;" ) ; if ( getLastDelimiter ( ) != '=' ) { throw new BadFormatException ( "Unknown subcommand, '" + token2 + "', or missing '=' in DIMENSIONS command" ) ; } if ( token2 . equalsIgnoreCase ( "NTAX" ) ) { if ( block == CHARACTERS_BLOCK ) { throw new BadFormatException ( "NTAX subcommand in CHARACTERS block" ) ; } taxonCount = readInteger ( ";" ) ; ntax = true ; } else if ( token2 . equalsIgnoreCase ( "NCHAR" ) ) { if ( block == TAXA_BLOCK ) { throw new BadFormatException ( "NCHAR subcommand in TAXA block" ) ; } siteCount = readInteger ( ";" ) ; nchar = true ; } else { throw new BadFormatException ( "Unknown subcommand, '" + token2 + "', in DIMENSIONS command" ) ; } } while ( getLastDelimiter ( ) != ';' ) ; if ( ! ntax ) { throw new BadFormatException ( "NTAX subcommand missing from DIMENSIONS command" ) ; } if ( ! nchar ) { throw new BadFormatException ( "NCHAR subcommand missing from DIMENSIONS command" ) ; } dim = true ; } else if ( token . equalsIgnoreCase ( "FORMAT" ) ) { if ( fmt ) { throw new DuplicateFieldException ( "FORMAT" ) ; } dataType = null ; do { String token2 = readToken ( "=;" ) ; if ( token2 . equalsIgnoreCase ( "GAP" ) ) { if ( getLastDelimiter ( ) != '=' ) { throw new BadFormatException ( "Expecting '=' after GAP subcommand in FORMAT command" ) ; } gapCharacters = readToken ( ";" ) ; } else if ( token2 . equalsIgnoreCase ( "MISSING" ) ) { if ( getLastDelimiter ( ) != '=' ) { throw new BadFormatException ( "Expecting '=' after MISSING subcommand in FORMAT command" ) ; } missingCharacters = readToken ( ";" ) ; } else if ( token2 . equalsIgnoreCase ( "MATCHCHAR" ) ) { if ( getLastDelimiter ( ) != '=' ) { throw new BadFormatException ( "Expecting '=' after MATCHCHAR subcommand in FORMAT command" ) ; } matchCharacters = readToken ( ";" ) ; } else if ( token2 . equalsIgnoreCase ( "DATATYPE" ) ) { if ( getLastDelimiter ( ) != '=' ) { throw new BadFormatException ( "Expecting '=' after DATATYPE subcommand in FORMAT command" ) ; } String token3 = readToken ( ";" ) ; if ( token3 . equalsIgnoreCase ( "NUCLEOTIDE" ) || token3 . equalsIgnoreCase ( "DNA" ) || token3 . equalsIgnoreCase ( "RNA" ) ) { dataType = Nucleotides . INSTANCE ; } else if ( token3 . equalsIgnoreCase ( "STANDARD" ) || token3 . equalsIgnoreCase ( "BINARY" ) ) { dataType = TwoStates . INSTANCE ; } else if ( token3 . equalsIgnoreCase ( "PROTEIN" ) ) { dataType = AminoAcids . INSTANCE ; } else if ( token3 . equalsIgnoreCase ( "CONTINUOUS" ) ) { throw new UnparsableDataException ( "Continuous data cannot be parsed at present" ) ; } } else if ( token2 . equalsIgnoreCase ( "INTERLEAVE" ) ) { isInterleaved = true ; } } while ( getLastDelimiter ( ) != ';' ) ; fmt = true ; } } while ( ! token . equalsIgnoreCase ( tokenToLookFor ) ) ; if ( ! dim ) { throw new MissingFieldException ( "DIMENSIONS" ) ; } if ( block != TAXA_BLOCK && dataType == null ) { throw new MissingFieldException ( "DATATYPE" ) ; } }
reads the header information for a ' data ' , ' characters ' or ' taxa ' block .
