private String [ ] getHeaderValues ( String header ) { String [ ] data = new String [ 0 ] ; ArrayList < String > values = new ArrayList < String > ( ) ; StringBuffer sb = new StringBuffer ( ) ; //commented out 1/11/2012 to resolve an issue where headers do contain a length= at the end that are not recognized //if(header.indexOf("length=") != -1){ // data = new String[1]; // int index = header.indexOf("length="); // data[0] = header.substring(0, index).trim(); // logger.debug("accession=" + data[0]); // return data; //} else if ( ! header . startsWith ( "PDB:" ) ) { for ( int i = 0 ; i < header . length ( ) ; i ++ ) { if ( header . charAt ( i ) == ' ' ) { values . add ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; //faster than = new StringBuffer(); } else if ( i == header . length ( ) - 1 ) { sb . append ( header . charAt ( i ) ) ; values . add ( sb . toString ( ) ) ; } else { sb . append ( header . charAt ( i ) ) ; } data = new String [ values . size ( ) ] ; values . toArray ( data ) ; } } else { data = header . split ( " " ) ; } return data ; }
Parse out the components where some have a | and others do not