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 */ 029public abstract class AbstractFatherBlock 030 implements Block 031{ 032 private List<Block> blocks; 033 034 /** 035 * <p>before.</p> 036 * 037 * @param sink the Sink to receive events. 038 */ 039 public abstract void before( Sink sink ); 040 041 /** 042 * <p>after.</p> 043 * 044 * @param sink the Sink to receive events. 045 */ 046 public abstract void after( Sink sink ); 047 048 /** 049 * <p>Constructor for AbstractFatherBlock.</p> 050 * 051 * @param childBlocks the child blocks. 052 */ 053 public AbstractFatherBlock( List<Block> childBlocks ) 054 { 055 if ( childBlocks == null ) 056 { 057 throw new IllegalArgumentException( "argument can't be null" ); 058 } 059 060 this.blocks = childBlocks; 061 } 062 063 /** {@inheritDoc} */ 064 public void traverse( Sink sink ) 065 { 066 before( sink ); 067 068 for ( Block block : blocks ) 069 { 070 block.traverse( sink ); 071 } 072 073 after( sink ); 074 } 075 076 /** 077 * <p>Getter for the field <code>blocks</code>.</p> 078 * 079 * @return a {@link java.util.List} object. 080 */ 081 public List<Block> getBlocks() 082 { 083 return blocks; 084 } 085}