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 // This file contains the node classes for the internal representations of YAML | 5 // This file contains the node classes for the internal representations of YAML |
6 // documents. These nodes are used for both the serialization tree and the | 6 // documents. These nodes are used for both the serialization tree and the |
7 // representation graph. | 7 // representation graph. |
8 | 8 |
9 /** A tag that indicates the type of a YAML node. */ | 9 /** A tag that indicates the type of a YAML node. */ |
10 class _Tag implements Hashable { | 10 class _Tag { |
Mads Ager (google)
2012/09/27 12:48:27
hep
| |
11 // TODO(nweiz): it would better match the semantics of the spec if there were | 11 // TODO(nweiz): it would better match the semantics of the spec if there were |
12 // a singleton instance of this class for each tag. | 12 // a singleton instance of this class for each tag. |
13 | 13 |
14 static const SCALAR_KIND = 0; | 14 static const SCALAR_KIND = 0; |
15 static const SEQUENCE_KIND = 1; | 15 static const SEQUENCE_KIND = 1; |
16 static const MAPPING_KIND = 2; | 16 static const MAPPING_KIND = 2; |
17 | 17 |
18 static const String YAML_URI_PREFIX = 'tag:yaml.org,2002:'; | 18 static const String YAML_URI_PREFIX = 'tag:yaml.org,2002:'; |
19 | 19 |
20 /** The name of the tag, either a URI or a local tag beginning with "!". */ | 20 /** The name of the tag, either a URI or a local tag beginning with "!". */ |
(...skipping 22 matching lines...) Expand all Loading... | |
43 return '!!${name.substring(YAML_URI_PREFIX.length)}'; | 43 return '!!${name.substring(YAML_URI_PREFIX.length)}'; |
44 } else { | 44 } else { |
45 return '!<$name>'; | 45 return '!<$name>'; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 int hashCode() => name.hashCode(); | 49 int hashCode() => name.hashCode(); |
50 } | 50 } |
51 | 51 |
52 /** The abstract class for YAML nodes. */ | 52 /** The abstract class for YAML nodes. */ |
53 class _Node implements Hashable { | 53 class _Node { |
Mads Ager (google)
2012/09/27 12:48:27
hep
| |
54 /** Every YAML node has a tag that describes its type. */ | 54 /** Every YAML node has a tag that describes its type. */ |
55 _Tag tag; | 55 _Tag tag; |
56 | 56 |
57 /** Any YAML node can have an anchor associated with it. */ | 57 /** Any YAML node can have an anchor associated with it. */ |
58 String anchor; | 58 String anchor; |
59 | 59 |
60 _Node(this.tag, [this.anchor]); | 60 _Node(this.tag, [this.anchor]); |
61 | 61 |
62 bool operator ==(other) { | 62 bool operator ==(other) { |
63 if (other is! _Node) return false; | 63 if (other is! _Node) return false; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 String toString() { | 229 String toString() { |
230 var strContent = Strings.join(content.getKeys(). | 230 var strContent = Strings.join(content.getKeys(). |
231 map((k) => '${k}: ${content[k]}'), ', '); | 231 map((k) => '${k}: ${content[k]}'), ', '); |
232 return '$tag {$strContent}'; | 232 return '$tag {$strContent}'; |
233 } | 233 } |
234 | 234 |
235 int hashCode() => super.hashCode() ^ _hashCode(content); | 235 int hashCode() => super.hashCode() ^ _hashCode(content); |
236 | 236 |
237 visit(_Visitor v) => v.visitMapping(this); | 237 visit(_Visitor v) => v.visitMapping(this); |
238 } | 238 } |
OLD | NEW |