1 /**
2 * Copyright (c) 2008-2012, 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.events;
17
18 import org.yaml.snakeyaml.error.Mark;
19
20 /**
21 * Base class for all events that mark the beginning of a node.
22 */
23 public abstract class NodeEvent extends Event {
24
25 private final String anchor;
26
27 public NodeEvent(String anchor, Mark startMark, Mark endMark) {
28 super(startMark, endMark);
29 this.anchor = anchor;
30 }
31
32 /**
33 * Node anchor by which this node might later be referenced by a
34 * {@link AliasEvent}.
35 * <p>
36 * Note that {@link AliasEvent}s are by it self <code>NodeEvent</code>s and
37 * use this property to indicate the referenced anchor.
38 *
39 * @return Anchor of this node or <code>null</code> if no anchor is defined.
40 */
41 public String getAnchor() {
42 return this.anchor;
43 }
44
45 @Override
46 protected String getArguments() {
47 return "anchor=" + anchor;
48 }
49 }