001package org.apache.maven.doxia.module.confluence.parser;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.List;
023
024import org.apache.maven.doxia.sink.Sink;
025
026/**
027 * <p>Abstract AbstractFatherBlock class.</p>
028 *
029 * @version $Id$
030 */
031public abstract class AbstractFatherBlock
032    implements Block
033{
034    private List<Block> blocks;
035
036    /**
037     * <p>before.</p>
038     *
039     * @param sink the Sink to receive events.
040     */
041    public abstract void before( Sink sink );
042
043    /**
044     * <p>after.</p>
045     *
046     * @param sink the Sink to receive events.
047     */
048    public abstract void after( Sink sink );
049
050    /**
051     * <p>Constructor for AbstractFatherBlock.</p>
052     *
053     * @param childBlocks the child blocks.
054     */
055    public AbstractFatherBlock( List<Block> childBlocks )
056    {
057        if ( childBlocks == null )
058        {
059            throw new IllegalArgumentException( "argument can't be null" );
060        }
061
062        this.blocks = childBlocks;
063    }
064
065    /** {@inheritDoc} */
066    public void traverse(  Sink sink )
067    {
068        before( sink );
069
070        for ( Block block : blocks )
071        {
072            block.traverse( sink );
073        }
074
075        after( sink );
076    }
077
078    /**
079     * <p>Getter for the field <code>blocks</code>.</p>
080     *
081     * @return a {@link java.util.List} object.
082     */
083    public List<Block> getBlocks()
084    {
085        return blocks;
086    }
087}