• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2008, http://www.snakeyaml.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.yaml.snakeyaml.nodes;
17 
18 import java.util.List;
19 
20 import org.yaml.snakeyaml.error.Mark;
21 
22 /**
23  * Represents a sequence.
24  * <p>
25  * A sequence is a ordered collection of nodes.
26  * </p>
27  */
28 public class SequenceNode extends CollectionNode {
29     final private List<Node> value;
30 
SequenceNode(Tag tag, boolean resolved, List<Node> value, Mark startMark, Mark endMark, Boolean flowStyle)31     public SequenceNode(Tag tag, boolean resolved, List<Node> value, Mark startMark, Mark endMark,
32             Boolean flowStyle) {
33         super(tag, startMark, endMark, flowStyle);
34         if (value == null) {
35             throw new NullPointerException("value in a Node is required.");
36         }
37         this.value = value;
38         this.resolved = resolved;
39     }
40 
SequenceNode(Tag tag, List<Node> value, Boolean flowStyle)41     public SequenceNode(Tag tag, List<Node> value, Boolean flowStyle) {
42         this(tag, true, value, null, null, flowStyle);
43     }
44 
45     @Override
getNodeId()46     public NodeId getNodeId() {
47         return NodeId.sequence;
48     }
49 
50     /**
51      * Returns the elements in this sequence.
52      *
53      * @return Nodes in the specified order.
54      */
getValue()55     public List<Node> getValue() {
56         return value;
57     }
58 
setListType(Class<? extends Object> listType)59     public void setListType(Class<? extends Object> listType) {
60         for (Node node : value) {
61             node.setType(listType);
62         }
63     }
64 
toString()65     public String toString() {
66         return "<" + this.getClass().getName() + " (tag=" + getTag() + ", value=" + getValue()
67                 + ")>";
68     }
69 }
70