001package org.apache.maven.doxia.parser.module;
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
022/**
023 * An abstract base class that implements the ParserModule interface.
024 *
025 * @since 1.6
026 */
027public abstract class AbstractParserModule
028    implements ParserModule
029{
030    /** The source directory. */
031    private final String sourceDirectory;
032
033    /** The default file extension. */
034    private final String extension;
035
036    /** The default file extension. */
037    private final String parserId;
038
039    /**
040     * Constructor with null.
041     */
042    public AbstractParserModule()
043    {
044        this( null, null, null );
045    }
046
047    /**
048     * Constructor with same value for everything: source directory and file extension equal parserId.
049     */
050    public AbstractParserModule( String parserId )
051    {
052        this( parserId, parserId, parserId );
053    }
054
055    /**
056     * Constructor with same value for parser id and source directory.
057     */
058    public AbstractParserModule( String parserId, String extension )
059    {
060        this( parserId, extension, parserId );
061    }
062
063    /**
064     * @param sourceDirectory not null
065     * @param extension not null
066     * @param parserId not null
067     * @since 1.1.1
068     */
069    protected AbstractParserModule( String sourceDirectory, String extension, String parserId )
070    {
071        super();
072        this.sourceDirectory = sourceDirectory;
073        this.extension = extension;
074        this.parserId = parserId;
075    }
076
077    /** {@inheritDoc} */
078    public String getSourceDirectory()
079    {
080        return sourceDirectory;
081    }
082
083    /** {@inheritDoc} */
084    public String getExtension()
085    {
086        return extension;
087    }
088
089    /** {@inheritDoc} */
090    public String getParserId()
091    {
092        return parserId;
093    }
094}