public void writeDSR ( String dsr ) throws IOException { if ( state != State . INITIAL ) throw new DapException ( "Attempt to write DSR twice" ) ; if ( dsr == null ) throw new DapException ( "Attempt to write empty DSR" ) ; // Strip off any trailing sequence of CR or LF. int len = dsr . length ( ) ; while ( len > 0 ) { char c = dsr . charAt ( len - 1 ) ; if ( c != ' ' && c != ' ' ) break ; len -- ; } if ( dsr . length ( ) == 0 ) throw new DapException ( "Attempt to write empty DSR" ) ; dsr = dsr . substring ( 0 , len ) + DapUtil . CRLF ; // Add <?xml...?> prefix dsr = XMLDOCUMENTHEADER + "\n" + dsr ; // Convert the dsr to UTF-8 and then to byte[] byte [ ] dsr8 = DapUtil . extract ( DapUtil . UTF8 . encode ( dsr ) ) ; sendDXR ( dsr8 ) ; state = State . END ; }
Write the DSR ; do not bother to cache .