1 /*
2 ExcludeFilePatternOptionArgumentImpl.java
3 Creation date : 15/06/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.commoncli.option.argument.impl.filepattern;
26
27 import static net.sourceforge.plantumldependency.common.constants.CommonConstants.CURRENT_DIRECTORY;
28 import static net.sourceforge.plantumldependency.common.utils.string.StringUtils.isNotEmpty;
29 import static net.sourceforge.plantumldependency.commoncli.constants.log.ErrorConstants.EMPTY_OPTION_ARGUMENT_ERROR;
30 import static net.sourceforge.plantumldependency.commoncli.utils.fileset.FileSetUtils.createFileSet;
31 import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
32
33 import org.apache.tools.ant.types.FileSet;
34
35 /**
36 * The exclude file pattern implementation of the
37 * {@link net.sourceforge.plantumldependency.commoncli.option.argument.OptionArgument} interface,
38 * specifying an exclude {@link FileSet} argument.
39 *
40 * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
41 * @since 1.3.0
42 * @version 1.3.0
43 */
44 public class ExcludeFilePatternOptionArgumentImpl extends AbstractFilePatternOptionArgumentImpl {
45
46 /** Serial version UID. */
47 private static final long serialVersionUID = 2975558155322847795L;
48
49 /**
50 * Default constructor.
51 *
52 * @param optionArgumentIsMandatory
53 * <code>true</code> if the argument is mandatory, <code>false</code> otherwise.
54 * @since 1.3.0
55 */
56 public ExcludeFilePatternOptionArgumentImpl(final boolean optionArgumentIsMandatory) {
57 super(optionArgumentIsMandatory);
58 }
59
60 /**
61 * Default constructor.
62 *
63 * @param optionArgumentIsMandatory
64 * <code>true</code> if the argument is mandatory, <code>false</code> otherwise.
65 * @param fullArgumentDescription
66 * the full argument usage description, explaining what the argument does (used for
67 * helping message). <i>Note : a new {@link StringBuilder} is created.</i>
68 * @since 1.3.0
69 */
70 public ExcludeFilePatternOptionArgumentImpl(final boolean optionArgumentIsMandatory,
71 final StringBuilder fullArgumentDescription) {
72 super(optionArgumentIsMandatory, fullArgumentDescription);
73 }
74
75 /**
76 * {@inheritDoc}
77 *
78 * @since 1.3.0
79 */
80 @Override
81 public FileSet parseArgument(final String argument) throws CommandLineException {
82 FileSet fileSet = null;
83
84 if (isNotEmpty(argument)) {
85 fileSet = createFileSet(CURRENT_DIRECTORY, "**/*", argument);
86 } else {
87 throw new CommandLineException(EMPTY_OPTION_ARGUMENT_ERROR);
88 }
89
90 return fileSet;
91 }
92 }