001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.doxia.parser.module; 020 021/** 022 * An abstract base class that implements the ParserModule interface. 023 * 024 * @since 1.6 025 */ 026public abstract class AbstractParserModule implements ParserModule { 027 /** The source directory. */ 028 private final String sourceDirectory; 029 030 /** The supported file extensions. */ 031 private final String[] extensions; 032 033 /** The default file extension. */ 034 private final String parserId; 035 036 /** 037 * Constructor with null. 038 */ 039 public AbstractParserModule() { 040 this(null, null, (String[]) null); 041 } 042 043 /** 044 * Constructor with same value for everything: source directory and file extension equal parserId. 045 * 046 * @param parserId the parser id 047 */ 048 public AbstractParserModule(String parserId) { 049 this(parserId, parserId, parserId); 050 } 051 052 /** 053 * Constructor with same value for parser id and source directory. 054 * 055 * @param parserId the parser id 056 * @param extension the file extension 057 */ 058 public AbstractParserModule(String parserId, String extension) { 059 this(parserId, parserId, new String[] {extension}); 060 } 061 062 /** 063 * <p>Constructor for AbstractParserModule.</p> 064 * 065 * @param sourceDirectory not null 066 * @param parserId not null (usually equals sourceDirectory) 067 * @param extensions not null 068 * @since 1.7 069 */ 070 protected AbstractParserModule(String sourceDirectory, String parserId, String... extensions) { 071 super(); 072 this.sourceDirectory = sourceDirectory; 073 this.extensions = extensions; 074 this.parserId = parserId; 075 } 076 077 /** 078 * {@inheritDoc} 079 * 080 * @return a {@link java.lang.String} object. 081 */ 082 public String getSourceDirectory() { 083 return sourceDirectory; 084 } 085 086 /** 087 * {@inheritDoc} 088 * 089 * @return an array of {@link java.lang.String} objects. 090 */ 091 public String[] getExtensions() { 092 return extensions; 093 } 094 095 /** 096 * {@inheritDoc} 097 * 098 * @return a {@link java.lang.String} object. 099 */ 100 public String getParserId() { 101 return parserId; 102 } 103}