| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Interface for decoders decoding binary data into string data. The | 5 // Interface for decoders decoding binary data into string data. The |
| 6 // decoder keeps track of line breaks during decoding. | 6 // decoder keeps track of line breaks during decoding. |
| 7 interface _StringDecoder { | 7 interface _StringDecoder { |
| 8 // Add more binary data to be decoded. The ownership of the buffer | 8 // Add more binary data to be decoded. The ownership of the buffer |
| 9 // is transfered to the decoder and the caller most not modify it any more. | 9 // is transfered to the decoder and the caller most not modify it any more. |
| 10 int write(List<int> buffer); | 10 int write(List<int> buffer); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 class _StringDecoders { | 31 class _StringDecoders { |
| 32 static _StringDecoder decoder(Encoding encoding) { | 32 static _StringDecoder decoder(Encoding encoding) { |
| 33 if (encoding == Encoding.UTF_8) { | 33 if (encoding == Encoding.UTF_8) { |
| 34 return new _UTF8Decoder(); | 34 return new _UTF8Decoder(); |
| 35 } else if (encoding == Encoding.ISO_8859_1) { | 35 } else if (encoding == Encoding.ISO_8859_1) { |
| 36 return new _Latin1Decoder(); | 36 return new _Latin1Decoder(); |
| 37 } else if (encoding == Encoding.ASCII) { | 37 } else if (encoding == Encoding.ASCII) { |
| 38 return new _AsciiDecoder(); | 38 return new _AsciiDecoder(); |
| 39 } else { | 39 } else { |
| 40 if (encoding is Encoding) { | 40 throw new StreamException("Unsupported encoding ${encoding.name}"); |
| 41 throw new StreamException("Unsupported encoding ${encoding.name}"); | |
| 42 } else { | |
| 43 throw new StreamException("Unsupported encoding ${encoding}"); | |
| 44 } | |
| 45 } | 41 } |
| 46 } | 42 } |
| 47 } | 43 } |
| 48 | 44 |
| 49 | 45 |
| 50 class DecoderException implements Exception { | 46 class DecoderException implements Exception { |
| 51 const DecoderException([String this.message]); | 47 const DecoderException([String this.message]); |
| 52 String toString() => "DecoderException: $message"; | 48 String toString() => "DecoderException: $message"; |
| 53 final String message; | 49 final String message; |
| 54 } | 50 } |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 bool _inputClosed = false; // Is the underlying input stream closed? | 510 bool _inputClosed = false; // Is the underlying input stream closed? |
| 515 bool _closed = false; // Is this stream closed. | 511 bool _closed = false; // Is this stream closed. |
| 516 bool _eof = false; // Has all data been read from the decoder? | 512 bool _eof = false; // Has all data been read from the decoder? |
| 517 Timer _scheduledDataCallback; | 513 Timer _scheduledDataCallback; |
| 518 Timer _scheduledLineCallback; | 514 Timer _scheduledLineCallback; |
| 519 Timer _scheduledCloseCallback; | 515 Timer _scheduledCloseCallback; |
| 520 Function _clientDataHandler; | 516 Function _clientDataHandler; |
| 521 Function _clientLineHandler; | 517 Function _clientLineHandler; |
| 522 Function _clientCloseHandler; | 518 Function _clientCloseHandler; |
| 523 } | 519 } |
| OLD | NEW |