View Javadoc
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 extension not null
73       * @param parserId not null
74       * @since 1.1.1
75       * @deprecated can cause confusion with constructor with multiple extensions
76       */
77      protected AbstractParserModule( String sourceDirectory, String extension, String parserId )
78      {
79          super();
80          this.sourceDirectory = sourceDirectory;
81          this.extensions = new String[] { extension };
82          this.parserId = parserId;
83      }
84  
85      /**
86       * <p>Constructor for AbstractParserModule.</p>
87       *
88       * @param sourceDirectory not null
89       * @param parserId not null (usually equals sourceDirectory)
90       * @param extensions not null
91       * @since 1.7
92       */
93      protected AbstractParserModule( String sourceDirectory, String parserId, String... extensions )
94      {
95          super();
96          this.sourceDirectory = sourceDirectory;
97          this.extensions = extensions;
98          this.parserId = parserId;
99      }
100 
101     /**
102      * {@inheritDoc}
103      *
104      * @return a {@link java.lang.String} object.
105      */
106     public String getSourceDirectory()
107     {
108         return sourceDirectory;
109     }
110 
111     /**
112      * {@inheritDoc}
113      *
114      * @return an array of {@link java.lang.String} objects.
115      */
116     public String[] getExtensions()
117     {
118         return extensions;
119     }
120 
121     /**
122      * {@inheritDoc}
123      *
124      * @return a {@link java.lang.String} object.
125      */
126     public String getParserId()
127     {
128         return parserId;
129     }
130 }