OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 part of dart.core; | |
6 | |
7 /** | |
8 * A resource that can be read into the program. | |
9 * | |
10 * A resource is data that can be located using a URI and read into | |
11 * the program at runtime. | |
12 * The URI may use the `package` scheme to read resources provided | |
13 * along with package sources. | |
14 */ | |
15 abstract class Resource { | |
16 /** | |
17 * Creates a resource object with the given [uri] as location. | |
18 * | |
19 * The `uri` is a string containing a valid URI. | |
20 * If the string is not a valid URI, using any of the functions on | |
21 * the resource object will fail. | |
22 * | |
23 * The URI may be relative, in which case it will be resolved | |
24 * against [Uri.base] before being used. | |
25 * | |
26 * The URI may use the `package` scheme, which is always supported. | |
27 * Other schemes may also be supported where possible. | |
28 */ | |
29 external const factory Resource(String uri); | |
30 | |
31 /** | |
32 * The location `uri` of this resource. | |
33 * | |
34 * This is a [Uri] of the `uri` parameter given to the constructor. | |
35 * If the parameter was not a valid URI, reading `uri` may fail. | |
36 */ | |
37 Uri get uri; | |
38 | |
39 /** Read the resource content as a stream of bytes. */ | |
40 Stream<List<int>> openRead(); | |
41 | |
42 /** Read the resource content. */ | |
43 Future<List<int>> readAsBytes(); | |
44 | |
45 /** | |
46 * Read the resource content as a string. | |
47 * | |
48 * The content is decoded into a string using an [Encoding]. | |
49 * If no other encoding is provided, it defaults to UTF-8. | |
50 */ | |
51 Future<String> readAsString({Encoding encoding}); | |
52 } | |
OLD | NEW |