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