1 /**
2 * Copyright (c) 2008-2011, 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
17 package org.yaml.snakeyaml.events;
18
19 import org.yaml.snakeyaml.error.Mark;
20
21 /**
22 * Base class for the start events of the collection nodes.
23 */
24 public abstract class CollectionStartEvent extends NodeEvent {
25 private final String tag;
26 // The implicit flag of a collection start event indicates if the tag may be
27 // omitted when the collection is emitted
28 private final boolean implicit;
29 // flag indicates if a collection is block or flow
30 private final Boolean flowStyle;
31
32 public CollectionStartEvent(String anchor, String tag, boolean implicit, Mark startMark,
33 Mark endMark, Boolean flowStyle) {
34 super(anchor, startMark, endMark);
35 this.tag = tag;
36 this.implicit = implicit;
37 this.flowStyle = flowStyle;
38 }
39
40 /**
41 * Tag of this collection.
42 *
43 * @return The tag of this collection, or <code>null</code> if no explicit
44 * tag is available.
45 */
46 public String getTag() {
47 return this.tag;
48 }
49
50 /**
51 * <code>true</code> if the tag can be omitted while this collection is
52 * emitted.
53 *
54 * @return True if the tag can be omitted while this collection is emitted.
55 */
56 public boolean getImplicit() {
57 return this.implicit;
58 }
59
60 /**
61 * <code>true</code> if this collection is in flow style, <code>false</code>
62 * for block style.
63 *
64 * @return If this collection is in flow style.
65 */
66 public Boolean getFlowStyle() {
67 return this.flowStyle;
68 }
69
70 @Override
71 protected String getArguments() {
72 return super.getArguments() + ", tag=" + tag + ", implicit=" + implicit;
73 }
74 }