11adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov/**
211a89b445f3bde56bf07e6a0d04f0b0256dcb215Andrey Somov * Copyright (c) 2008, http://www.snakeyaml.org
31adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
41adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * Licensed under the Apache License, Version 2.0 (the "License");
51adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * you may not use this file except in compliance with the License.
61adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * You may obtain a copy of the License at
71adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
81adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *     http://www.apache.org/licenses/LICENSE-2.0
91adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
101adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * Unless required by applicable law or agreed to in writing, software
111adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * distributed under the License is distributed on an "AS IS" BASIS,
121adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * See the License for the specific language governing permissions and
141adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * limitations under the License.
159629be70863521bead138c295351f3dec926ab1Andrey Somov */
169629be70863521bead138c295351f3dec926ab1Andrey Somovpackage org.yaml.snakeyaml.events;
179629be70863521bead138c295351f3dec926ab1Andrey Somov
189629be70863521bead138c295351f3dec926ab1Andrey Somovimport org.yaml.snakeyaml.error.Mark;
199629be70863521bead138c295351f3dec926ab1Andrey Somov
209629be70863521bead138c295351f3dec926ab1Andrey Somov/**
215276a6f69a288c609ad58a2d17423a862d44c9a5scm * Base class for the start events of the collection nodes.
229629be70863521bead138c295351f3dec926ab1Andrey Somov */
239629be70863521bead138c295351f3dec926ab1Andrey Somovpublic abstract class CollectionStartEvent extends NodeEvent {
249629be70863521bead138c295351f3dec926ab1Andrey Somov    private final String tag;
25ab2e864982dc460583b287da179712eaadbbf409Andrey Somov    // The implicit flag of a collection start event indicates if the tag may be
26ab2e864982dc460583b287da179712eaadbbf409Andrey Somov    // omitted when the collection is emitted
279629be70863521bead138c295351f3dec926ab1Andrey Somov    private final boolean implicit;
28ab2e864982dc460583b287da179712eaadbbf409Andrey Somov    // flag indicates if a collection is block or flow
299629be70863521bead138c295351f3dec926ab1Andrey Somov    private final Boolean flowStyle;
309629be70863521bead138c295351f3dec926ab1Andrey Somov
319629be70863521bead138c295351f3dec926ab1Andrey Somov    public CollectionStartEvent(String anchor, String tag, boolean implicit, Mark startMark,
329629be70863521bead138c295351f3dec926ab1Andrey Somov            Mark endMark, Boolean flowStyle) {
339629be70863521bead138c295351f3dec926ab1Andrey Somov        super(anchor, startMark, endMark);
349629be70863521bead138c295351f3dec926ab1Andrey Somov        this.tag = tag;
359629be70863521bead138c295351f3dec926ab1Andrey Somov        this.implicit = implicit;
369629be70863521bead138c295351f3dec926ab1Andrey Somov        this.flowStyle = flowStyle;
379629be70863521bead138c295351f3dec926ab1Andrey Somov    }
389629be70863521bead138c295351f3dec926ab1Andrey Somov
395276a6f69a288c609ad58a2d17423a862d44c9a5scm    /**
405276a6f69a288c609ad58a2d17423a862d44c9a5scm     * Tag of this collection.
4137f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *
4237f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @return The tag of this collection, or <code>null</code> if no explicit
4337f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *         tag is available.
445276a6f69a288c609ad58a2d17423a862d44c9a5scm     */
459629be70863521bead138c295351f3dec926ab1Andrey Somov    public String getTag() {
469629be70863521bead138c295351f3dec926ab1Andrey Somov        return this.tag;
479629be70863521bead138c295351f3dec926ab1Andrey Somov    }
489629be70863521bead138c295351f3dec926ab1Andrey Somov
495276a6f69a288c609ad58a2d17423a862d44c9a5scm    /**
5037f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * <code>true</code> if the tag can be omitted while this collection is
5137f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * emitted.
5237f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *
535276a6f69a288c609ad58a2d17423a862d44c9a5scm     * @return True if the tag can be omitted while this collection is emitted.
545276a6f69a288c609ad58a2d17423a862d44c9a5scm     */
559629be70863521bead138c295351f3dec926ab1Andrey Somov    public boolean getImplicit() {
569629be70863521bead138c295351f3dec926ab1Andrey Somov        return this.implicit;
579629be70863521bead138c295351f3dec926ab1Andrey Somov    }
589629be70863521bead138c295351f3dec926ab1Andrey Somov
595276a6f69a288c609ad58a2d17423a862d44c9a5scm    /**
605276a6f69a288c609ad58a2d17423a862d44c9a5scm     * <code>true</code> if this collection is in flow style, <code>false</code>
615276a6f69a288c609ad58a2d17423a862d44c9a5scm     * for block style.
6237f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *
635276a6f69a288c609ad58a2d17423a862d44c9a5scm     * @return If this collection is in flow style.
645276a6f69a288c609ad58a2d17423a862d44c9a5scm     */
659629be70863521bead138c295351f3dec926ab1Andrey Somov    public Boolean getFlowStyle() {
669629be70863521bead138c295351f3dec926ab1Andrey Somov        return this.flowStyle;
679629be70863521bead138c295351f3dec926ab1Andrey Somov    }
689629be70863521bead138c295351f3dec926ab1Andrey Somov
699629be70863521bead138c295351f3dec926ab1Andrey Somov    @Override
709629be70863521bead138c295351f3dec926ab1Andrey Somov    protected String getArguments() {
719629be70863521bead138c295351f3dec926ab1Andrey Somov        return super.getArguments() + ", tag=" + tag + ", implicit=" + implicit;
729629be70863521bead138c295351f3dec926ab1Andrey Somov    }
739629be70863521bead138c295351f3dec926ab1Andrey Somov}
74