[Japi-cvs] SF.net SVN: japi: [594] libs/argparser/trunk/src/net/sf/japi/io/args
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2007-08-23 21:44:45
|
Revision: 594
http://japi.svn.sourceforge.net/japi/?rev=594&view=rev
Author: christianhujer
Date: 2007-08-23 14:44:36 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
Introduced ArgumentFileNotFoundException in case an argument file was not found.
Modified Paths:
--------------
libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java
Added Paths:
-----------
libs/argparser/trunk/src/net/sf/japi/io/args/ArgumentFileNotFoundException.java
Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java
===================================================================
--- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-08-23 11:25:42 UTC (rev 593)
+++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-08-23 21:44:36 UTC (rev 594)
@@ -73,8 +73,9 @@
* @throws TerminalException in case argument parsing was stopped
* @throws MissingArgumentException in the required argument for an option was missing
* @throws UnknownOptionException In case an option was specified that's not supported.
+ * @throws ArgumentFileNotFoundException in case an argument file was not found.
*/
- private ArgParser(@NotNull final Command command, @NotNull final String... args) throws TerminalException, RequiredOptionsMissingException, UnknownOptionException, MissingArgumentException {
+ private ArgParser(@NotNull final Command command, @NotNull final String... args) throws TerminalException, RequiredOptionsMissingException, UnknownOptionException, MissingArgumentException, ArgumentFileNotFoundException {
this.command = command;
commandClass = command.getClass();
initMethods();
@@ -99,8 +100,9 @@
* @param context File relative to which @-inclusions have to be resolved.
* @param args arguments before parsing argument files.
* @return all arguments after parsing argument files.
+ * @throws ArgumentFileNotFoundException in case an argument file was not found.
*/
- public List<String> getAllArguments(@NotNull final File context, @NotNull final List<String> args) {
+ public List<String> getAllArguments(@NotNull final File context, @NotNull final List<String> args) throws ArgumentFileNotFoundException {
final List<String> argList = new ArrayList<String>(args);
for (final ListIterator<String> iterator = argList.listIterator(); iterator.hasNext();) {
final String arg = iterator.next();
@@ -123,16 +125,16 @@
* Returns a tokenized unparsed list of arguments from an arguments file.
* @param file Argument file to read.
* @return all arguments from that argument file.
+ * @throws ArgumentFileNotFoundException in case an argument file was not found.
*/
- public List<String> readFromFile(@NotNull final File file) {
- final List<String> args = new ArrayList<String>();
+ @NotNull public List<String> readFromFile(@NotNull final File file) throws ArgumentFileNotFoundException {
final TokenReader in;
try {
in = new TokenReader(new FileInputStream(file));
} catch (final FileNotFoundException e) {
- // TODO TODO TODO TODO TODO
- return args;
+ throw new ArgumentFileNotFoundException(e);
}
+ final List<String> args = new ArrayList<String>();
for (final String token : in) {
args.add(token);
}
@@ -306,6 +308,8 @@
System.err.println(e);
} catch (final MissingArgumentException e) {
System.err.println(e);
+ } catch (final ArgumentFileNotFoundException e) {
+ System.err.println(e);
}
}
@@ -317,8 +321,9 @@
* @throws TerminalException in case a terminal option was encountered.
* @throws UnknownOptionException in case an option given was not known.
* @throws MissingArgumentException in case an option was missing its argument
+ * @throws ArgumentFileNotFoundException in case an argument file was not found.
*/
- public static void parseAndRun(@NotNull final Command command, @NotNull final String... args) throws RequiredOptionsMissingException, TerminalException, UnknownOptionException, MissingArgumentException {
+ public static void parseAndRun(@NotNull final Command command, @NotNull final String... args) throws RequiredOptionsMissingException, TerminalException, UnknownOptionException, MissingArgumentException, ArgumentFileNotFoundException {
new ArgParser(command, args);
}
Added: libs/argparser/trunk/src/net/sf/japi/io/args/ArgumentFileNotFoundException.java
===================================================================
--- libs/argparser/trunk/src/net/sf/japi/io/args/ArgumentFileNotFoundException.java (rev 0)
+++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgumentFileNotFoundException.java 2007-08-23 21:44:36 UTC (rev 594)
@@ -0,0 +1,39 @@
+/*
+ * JAPI libs-argparser is a library for parsing command line arguments.
+ * Copyright (C) 2007 Christian Hujer.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package net.sf.japi.io.args;
+
+import java.io.FileNotFoundException;
+import org.jetbrains.annotations.NotNull;
+
+/** This type of exception is thrown when an argument file was not found.
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class ArgumentFileNotFoundException extends FileNotFoundException {
+
+ /** Create an ArgumentFileNotFoundException.
+ * @param cause The FileNotFoundException that caused this ArgumentFileNotFoundException.
+ */
+ public ArgumentFileNotFoundException(@NotNull final FileNotFoundException cause) {
+ super("Argument file not found: " + cause.getMessage());
+ initCause(cause);
+ }
+
+} // class ArgumentFileNotFoundException
Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/ArgumentFileNotFoundException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|