View Javadoc

1   /*
2    PlantUMLDependencyBaseDirectoryOption.java
3    Creation date : 5/07/2010
4    Copyright © Benjamin Croizet (graffity2199@yahoo.fr)
5   
6    This program is free software; you can redistribute it and/or
7    modify it under the terms of the GNU General Public License
8    or GNU Lesser General Public License as published by the
9    Free Software Foundation; either version 3 of the License,
10   or (at your option) any later version.
11  
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16  
17   You should have received copies of the GNU General Public License
18   and GNU Lesser General Public License along with this program;
19   if not, write to the Free Software Foundation, Inc.,
20   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21   http://www.fsf.org/licensing/licenses/gpl.html
22   http://www.gnu.org/licenses/lgpl.html
23   */
24  
25  package net.sourceforge.plantumldependency.cli.main.option.basedirectory;
26  
27  import static java.util.Arrays.asList;
28  import static java.util.Collections.unmodifiableSet;
29  import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.DOT_CHAR;
30  import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
31  import static net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus.ACTIVE_OPTIONAL_OPTION_STATUS;
32  
33  import java.io.File;
34  import java.util.Set;
35  import java.util.TreeSet;
36  
37  import net.sourceforge.plantumldependency.commoncli.command.CommandLine;
38  import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
39  import net.sourceforge.plantumldependency.commoncli.option.AbstractOptionWithArgument;
40  import net.sourceforge.plantumldependency.commoncli.option.argument.impl.directory.ExistingDirectoryOptionArgumentImpl;
41  
42  /**
43   * The base directory option, telling the program where to look for source files. <i>Note : no
44   * option should have the same main or secondary names</i>.
45   *
46   * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
47   * @since 1.0.0
48   * @version 1.3.0
49   */
50  public class PlantUMLDependencyBaseDirectoryOption extends AbstractOptionWithArgument < File > {
51  
52      /** Serial version UID. */
53      private static final long serialVersionUID = 2742023948261611955L;
54  
55      /** Option main synopsis. */
56      public static final String OPTION_MAIN_SYNOPSIS = "-b";
57  
58      /** Option synopsis alias. */
59      public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >(
60              asList(new String[] {"--basedir"})));
61  
62      /**
63       * Default constructor.
64       *
65       * @since 1.0.0
66       */
67      public PlantUMLDependencyBaseDirectoryOption() {
68          super(
69                  OPTION_MAIN_SYNOPSIS,
70                  OPTION_SYNOPSIS,
71                  new ExistingDirectoryOptionArgumentImpl(true),
72                  new StringBuilder(
73                          "The base directory where to look for source files. If not specified, the default pattern is \".\" i.e. the directory where the program is launched from."),
74                  SPACE_CHAR, ACTIVE_OPTIONAL_OPTION_STATUS);
75      }
76  
77      /**
78       * {@inheritDoc}
79       *
80       * @since 1.0.0
81       */
82      @Override
83      public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
84              throws CommandLineException {
85          return DOT_CHAR;
86      }
87  
88      /**
89       * {@inheritDoc}
90       *
91       * @since 1.0.0
92       */
93      @Override
94      public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
95              throws CommandLineException {
96          return DOT_CHAR;
97      }
98  }