| 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 { | 10 class _Tag { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 get hashCode => name.hashCode; | 49 int get hashCode => name.hashCode; |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** The abstract class for YAML nodes. */ | 52 /** The abstract class for YAML nodes. */ |
| 53 class _Node { | 53 abstract class _Node { |
| 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; |
| 64 return tag == other.tag; | 64 return tag == other.tag; |
| 65 } | 65 } |
| 66 | 66 |
| 67 int get hashCode => _hashCode([tag, anchor]); | 67 int get hashCode => _hashCode([tag, anchor]); |
| 68 | 68 |
| 69 abstract visit(_Visitor v); | 69 visit(_Visitor v); |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** A sequence node represents an ordered list of nodes. */ | 72 /** A sequence node represents an ordered list of nodes. */ |
| 73 class _SequenceNode extends _Node { | 73 class _SequenceNode extends _Node { |
| 74 /** The nodes in the sequence. */ | 74 /** The nodes in the sequence. */ |
| 75 List<_Node> content; | 75 List<_Node> content; |
| 76 | 76 |
| 77 _SequenceNode(String tagName, this.content) | 77 _SequenceNode(String tagName, this.content) |
| 78 : super(new _Tag.sequence(tagName)); | 78 : super(new _Tag.sequence(tagName)); |
| 79 | 79 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 String toString() { | 229 String toString() { |
| 230 var strContent = Strings.join(content.keys. | 230 var strContent = Strings.join(content.keys. |
| 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 get hashCode => super.hashCode ^ _hashCode(content); | 235 int get 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 |