~ubuntu-branches/ubuntu/vivid/doxia/vivid-proposed

« back to all changes in this revision

Viewing changes to doxia-core/src/main/java/org/apache/maven/doxia/macro/AbstractMacro.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-10-08 14:20:22 UTC
  • mfrom: (2.3.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091008142022-f6ccxganfr2tbaig
Tags: 1.1-3build1
Upload to karmic, avoiding new version from unstable. LP: #443292.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * under the License.
20
20
 */
21
21
 
 
22
import org.apache.maven.doxia.logging.Log;
 
23
import org.apache.maven.doxia.logging.SystemStreamLog;
 
24
import org.codehaus.plexus.util.StringUtils;
 
25
 
22
26
/**
23
27
 * Abstract base class to execute <code>Macro</code>.
24
28
 *
25
29
 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
26
 
 * @version $Id: AbstractMacro.java 567311 2007-08-18 18:30:54Z vsiveton $
 
30
 * @version $Id: AbstractMacro.java 747735 2009-02-25 10:43:09Z ltheussl $
27
31
 * @since 1.0
28
32
 */
29
33
public abstract class AbstractMacro
30
34
    implements Macro
31
35
{
32
 
    // nop
 
36
    /** Log instance. */
 
37
    private Log logger;
 
38
 
 
39
    /** {@inheritDoc} */
 
40
    public void enableLogging( Log log )
 
41
    {
 
42
        this.logger = log;
 
43
    }
 
44
 
 
45
    /**
 
46
     * Returns a logger for this macro.
 
47
     * If no logger has been configured, a new SystemStreamLog is returned.
 
48
     *
 
49
     * @return Log
 
50
     * @since 1.1
 
51
     */
 
52
    protected Log getLog()
 
53
    {
 
54
        if ( logger == null )
 
55
        {
 
56
            logger = new SystemStreamLog();
 
57
        }
 
58
 
 
59
        return logger;
 
60
    }
 
61
 
 
62
    /**
 
63
     * Check if the given parameter is required. Throws an
 
64
     * IllegalArgumentException if paramValue is null or empty.
 
65
     *
 
66
     * @param paramName The name of the parameter to check.
 
67
     * @param paramValue The parameter value.
 
68
     * @since 1.1
 
69
     */
 
70
    protected void required( String paramName, String paramValue )
 
71
    {
 
72
        if ( StringUtils.isEmpty( paramValue ) )
 
73
        {
 
74
            throw new IllegalArgumentException( paramName + " is a required parameter!" );
 
75
        }
 
76
    }
33
77
}