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