View Javadoc

    1   /*
    2    * Copyright (c) 2001-2003 The XDoclet team
    3    * All rights reserved.
    4    */
    5   package xjavadoc;
    6
    7   import org.apache.commons.collections.Predicate;
    8
    9   /***
    10   * A class that can validate tags. It reuses logic from predicates.
    11   *
    12   * @author    Aslak Hellesøy
    13   * @created   24. februar 2003
    14   * @version   $Revision: 1.3 $
    15   */
    16  public class TagValidator
    17  {
    18  	private Predicate  _predicate;
    19
    20  	public TagValidator( Predicate predicate )
    21  	{
    22  		setPredicate( predicate );
    23  	}
    24
    25  	public void setPredicate( Predicate predicate )
    26  	{
    27  		_predicate = predicate;
    28
    29  	}
    30
    31  	public void validate( XTag tag ) throws TagValidationException
    32  	{
    33  		if( !_predicate.evaluate( tag ) )
    34  		{
    35  			throw new TagValidationException( "Validation error", tag );
    36  		}
    37  	}
    38  }