1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.doxia.parser.module; 20 21 /** 22 * An abstract base class that implements the ParserModule interface. 23 * 24 * @since 1.6 25 */ 26 public abstract class AbstractParserModule implements ParserModule { 27 /** The source directory. */ 28 private final String sourceDirectory; 29 30 /** The supported file extensions. */ 31 private final String[] extensions; 32 33 /** The default file extension. */ 34 private final String parserId; 35 36 /** 37 * Constructor with null. 38 */ 39 public AbstractParserModule() { 40 this(null, null, (String[]) null); 41 } 42 43 /** 44 * Constructor with same value for everything: source directory and file extension equal parserId. 45 * 46 * @param parserId the parser id 47 */ 48 public AbstractParserModule(String parserId) { 49 this(parserId, parserId, parserId); 50 } 51 52 /** 53 * Constructor with same value for parser id and source directory. 54 * 55 * @param parserId the parser id 56 * @param extension the file extension 57 */ 58 public AbstractParserModule(String parserId, String extension) { 59 this(parserId, parserId, new String[] {extension}); 60 } 61 62 /** 63 * <p>Constructor for AbstractParserModule.</p> 64 * 65 * @param sourceDirectory not null 66 * @param parserId not null (usually equals sourceDirectory) 67 * @param extensions not null 68 * @since 1.7 69 */ 70 protected AbstractParserModule(String sourceDirectory, String parserId, String... extensions) { 71 super(); 72 this.sourceDirectory = sourceDirectory; 73 this.extensions = extensions; 74 this.parserId = parserId; 75 } 76 77 /** 78 * {@inheritDoc} 79 * 80 * @return a {@link java.lang.String} object. 81 */ 82 public String getSourceDirectory() { 83 return sourceDirectory; 84 } 85 86 /** 87 * {@inheritDoc} 88 * 89 * @return an array of {@link java.lang.String} objects. 90 */ 91 public String[] getExtensions() { 92 return extensions; 93 } 94 95 /** 96 * {@inheritDoc} 97 * 98 * @return a {@link java.lang.String} object. 99 */ 100 public String getParserId() { 101 return parserId; 102 } 103 }