Thread: [Japi-cvs] SF.net SVN: japi: [167] libs/argparser/trunk/src/net/sf/japi/io/args
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-09-24 11:43:57
|
Revision: 167 http://svn.sourceforge.net/japi/?rev=167&view=rev Author: christianhujer Date: 2006-09-24 04:43:34 -0700 (Sun, 24 Sep 2006) Log Message: ----------- Cosmetic rework of argument parser library. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/net/sf/japi/io/args/Command.java libs/argparser/trunk/src/net/sf/japi/io/args/Option.java libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/StringJoiner.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-09-24 10:28:58 UTC (rev 166) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-09-24 11:43:34 UTC (rev 167) @@ -25,7 +25,8 @@ import java.lang.reflect.Method; import java.util.*; -/** Parser for command line arguments. +/** + * Parser for command line arguments. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * TODO: arguments for options, argument conversion for the method invokation. */ @@ -54,6 +55,8 @@ * This ArgParser uses {@link System#in}, {@link System#out} and {@link System#err}. * @param command Command to initialize and run * @param args Arguments to parse + * @throws RequiredOptionsMissingException in case an option is missing + * @throws TerminalException in case argument parsing was stopped */ private ArgParser(final Command command, final String... args) throws TerminalException, RequiredOptionsMissingException { this.command = command; @@ -73,6 +76,7 @@ /** * Checks that all required methods have been invoked. + * @throws RequiredOptionsMissingException in case a required command line argument was missing */ private void checkRequiredMethods() throws RequiredOptionsMissingException { if (requiredMethods.size() > 0) { @@ -112,6 +116,7 @@ /** * Parses arguments into an arguments container and invokes the Command's {@link Command#run(List<String>)} method. + * @throws TerminalException in case argument parsing was stopped */ private void parse() throws TerminalException { try { Modified: libs/argparser/trunk/src/net/sf/japi/io/args/Command.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2006-09-24 10:28:58 UTC (rev 166) +++ libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2006-09-24 11:43:34 UTC (rev 167) @@ -23,12 +23,14 @@ import java.util.List; -/** Shell commands can implement this interface and make use of ArgParser. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> +/** + * Shell commands can implement this interface and make use of ArgParser. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public interface Command { - /** Run the command. + /** + * Run the command. * This method is invoked by {@link ArgParser} once it is finnished with parsing the arguments. * @param args the argument strings that were not parsed away by {@link ArgParser}. */ Modified: libs/argparser/trunk/src/net/sf/japi/io/args/Option.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/Option.java 2006-09-24 10:28:58 UTC (rev 166) +++ libs/argparser/trunk/src/net/sf/japi/io/args/Option.java 2006-09-24 11:43:34 UTC (rev 167) @@ -26,8 +26,9 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Target; -/** Annotation to mark a method as command argument method. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> +/** + * Annotation to mark a method as command argument method. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @Retention(RUNTIME) @Target(METHOD) @@ -43,7 +44,8 @@ /** * The option names. * Usually this is two Strings, a single letter and a descriptive String. - * @note the supplied string values should contain neither spaces nor non-ascii characters. + * Multiple descriptive Strings as well as no single letter String are allowed. + * @note the supplied string values MUST consist of ASCII-letters only (match regex <code>[a-zA-Z]+</code>). * @return option names */ String[] value(); Modified: libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java 2006-09-24 10:28:58 UTC (rev 166) +++ libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java 2006-09-24 11:43:34 UTC (rev 167) @@ -24,6 +24,7 @@ /** * This exception is thrown in case required options are missing. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class RequiredOptionsMissingException extends Exception { @@ -33,23 +34,32 @@ /** * Create a RequiredOptionsMissingException. * @param missingOptions options that were missing. + * @throws IllegalArgumentException in case <var>missingOptions</var> was null or of zero length */ public RequiredOptionsMissingException(@NotNull final String[] missingOptions) { + super(createMessage(missingOptions)); + this.missingOptions = missingOptions.clone(); + } + + /** + * Creates the message. + * @param missingOptions options that were missing + * @return message string + * @throws IllegalArgumentException in case <var>missingOptions</var> was null or of zero length + */ + private static String createMessage(final String[] missingOptions) { if (missingOptions == null || missingOptions.length < 1) { throw new IllegalArgumentException("RequiredOptionsMissingException created but no missing options given."); } - this.missingOptions = missingOptions.clone(); + return StringJoiner.join(new StringBuilder("required options missing: "), ", ", missingOptions).toString(); } - /** {@inheritDoc} */ - public String toString() { - final StringBuilder msg = new StringBuilder("required options missing: "); - for (final String missingOption : missingOptions) { - msg.append(missingOption); - msg.append(", "); - } - msg.setLength(msg.length() - 2); - return msg.toString(); + /** + * Get the options that were missing. + * @return options that were missing + */ + public String[] getMissingOptions() { + return missingOptions.clone(); } } // class RequiredOptionsMissingException Added: libs/argparser/trunk/src/net/sf/japi/io/args/StringJoiner.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/StringJoiner.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/StringJoiner.java 2006-09-24 11:43:34 UTC (rev 167) @@ -0,0 +1,192 @@ +package net.sf.japi.io.args; + +import java.io.IOException; +import java.util.Iterator; + +/** + * Class with utility methods for joining strings. + * The class is intended to be as flexible and convenient as possible. + * Therefore it mostly operates on {@link CharSequence} instead of {@link String}, so you're free to use other kinds of "Strings" as well, not only {@link String} itself. + * Apart from methods that create a new {@link String}, you will also find methods that work on {@link Appendable}s so you can use these methods to append on implementations of {@link Appendable}. + * <p /> + * Because {@link Appendable#append(CharSequence)} throws {@link IOException}, methods that work on {@link Appendable} have been overloaded to work on certain known {@link Appendable}-implementations that do not throw an {@link IOException} when appending. + * Currently this is namely {@link StringBuilder} and {@link StringBuffer}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class StringJoiner { + + /** + * Utility class - do not instanciate. + */ + private StringJoiner() { + } + + /** + * Join Strings. + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return joined string + */ + public static String join(final CharSequence delim, final CharSequence... strings) { + return join(new StringBuilder(), delim, strings).toString(); + } + + /** + * Join Strings. + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return joined string + */ + public static String join(final CharSequence delim, final Iterable<? extends CharSequence> strings) { + return join(new StringBuilder(), delim, strings).toString(); + } + + /** + * Join Strings. + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return joined string + */ + public static String join(final CharSequence delim, final Iterator<? extends CharSequence> strings) { + return join(new StringBuilder(), delim, strings).toString(); + } + + /** + * Join Strings to an Appendable. + * @param dest Appendable to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return Appendable + */ + public static Appendable join(final Appendable dest, final CharSequence delim, final CharSequence... strings) throws IOException { + for (int i = 0; i < strings.length; i++) { + if (i > 0) { + dest.append(delim); + } + dest.append(strings[i]); + } + return dest; + } + + /** + * Join Strings to an Appendable. + * @param dest Appendable to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return Appendable + */ + public static Appendable join(final Appendable dest, final CharSequence delim, final Iterable<? extends CharSequence> strings) throws IOException { + return join(dest, delim, strings.iterator()); + } + + /** + * Join Strings to an Appendable. + * @param dest Appendable to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return Appendable + */ + public static Appendable join(final Appendable dest, final CharSequence delim, final Iterator<? extends CharSequence> strings) throws IOException { + if (strings.hasNext()) { + dest.append(strings.next()); + } + while (strings.hasNext()) { + dest.append(delim); + dest.append(strings.next()); + } + return dest; + } + + /** + * Join Strings to a StringBuilder. + * @param dest StringBuilder to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return supplied StringBuilder (<var>dest</var>) + */ + public static StringBuilder join(final StringBuilder dest, final CharSequence delim, final CharSequence... strings) { + for (int i = 0; i < strings.length; i++) { + if (i > 0) { + dest.append(delim); + } + dest.append(strings[i]); + } + return dest; + } + + /** + * Join Strings to a StringBuilder. + * @param dest StringBuilder to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return supplied StringBuilder (<var>dest</var>) + */ + public static StringBuilder join(final StringBuilder dest, final CharSequence delim, final Iterable<? extends CharSequence> strings) { + return join(dest, delim, strings.iterator()); + } + + /** + * Join Strings to a StringBuilder. + * @param dest StringBuilder to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return supplied StringBuilder (<var>dest</var>) + */ + public static StringBuilder join(final StringBuilder dest, final CharSequence delim, final Iterator<? extends CharSequence> strings) { + if (strings.hasNext()) { + dest.append(strings.next()); + } + while (strings.hasNext()) { + dest.append(delim); + dest.append(strings.next()); + } + return dest; + } + + /** + * Join Strings to a StringBuffer. + * @param dest StringBuffer to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return supplied StringBuffer (<var>dest</var>) + */ + public static StringBuffer join(final StringBuffer dest, final CharSequence delim, final CharSequence... strings) { + for (int i = 0; i < strings.length; i++) { + if (i > 0) { + dest.append(delim); + } + dest.append(strings[i]); + } + return dest; + } + + /** + * Join Strings to a StringBuffer. + * @param dest StringBuffer to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return supplied StringBuffer (<var>dest</var>) + */ + public static StringBuffer join(final StringBuffer dest, final CharSequence delim, final Iterable<? extends CharSequence> strings) { + return join(dest, delim, strings.iterator()); + } + + /** + * Join Strings to a StringBuffer. + * @param dest StringBuffer to join Strings to + * @param delim delimiter to use for joining the strings + * @param strings Strings to join + * @return supplied StringBuffer (<var>dest</var>) + */ + public static StringBuffer join(final StringBuffer dest, final CharSequence delim, final Iterator<? extends CharSequence> strings) { + if (strings.hasNext()) { + dest.append(strings.next()); + } + while (strings.hasNext()) { + dest.append(delim); + dest.append(strings.next()); + } + return dest; + } + +} // class StringJoiner Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/StringJoiner.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java 2006-09-24 10:28:58 UTC (rev 166) +++ libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java 2006-09-24 11:43:34 UTC (rev 167) @@ -22,6 +22,7 @@ /** * This exception is thrown when an argument method is terminal, i.e. stops further command processing. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class TerminalException extends Exception { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-25 14:20:53
|
Revision: 209 http://svn.sourceforge.net/japi/?rev=209&view=rev Author: christianhujer Date: 2006-11-25 06:20:52 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Added Converter package. Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/converter/ libs/argparser/trunk/src/net/sf/japi/io/args/converter/BooleanConverter.java libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.java libs/argparser/trunk/src/net/sf/japi/io/args/converter/InputStreamConverter.java libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/BooleanConverter.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/BooleanConverter.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/BooleanConverter.java 2006-11-25 14:20:52 UTC (rev 209) @@ -0,0 +1,14 @@ +package net.sf.japi.io.args.converter; + +/** + * Converter which converts a String into a Boolean. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class BooleanConverter implements Converter<Boolean> { + + /** {@inheritDoc} */ + public Boolean convert(final String arg) throws Exception { + return Boolean.valueOf(arg); + } + +} // class BooleanConverter Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/BooleanConverter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.java 2006-11-25 14:20:52 UTC (rev 209) @@ -0,0 +1,17 @@ +package net.sf.japi.io.args.converter; + +/** + * The Converter interface is used for converters that convert Strings into other types. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface Converter<T> { + + /** + * Convert the given argument to the desired return type. + * @param arg Argument to convert + * @return Argument converted to T. + * @throws Exception In case of conversion failure. + */ + T convert(final String arg) throws Exception; + +} // interface Convert Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/InputStreamConverter.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/InputStreamConverter.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/InputStreamConverter.java 2006-11-25 14:20:52 UTC (rev 209) @@ -0,0 +1,24 @@ +package net.sf.japi.io.args.converter; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +/** + * Converter that converts a String into an InputStream. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class InputStreamConverter implements Converter<InputStream> { + + /** {@inheritDoc} */ + public InputStream convert(final String arg) throws FileNotFoundException { + try { + return new URL(arg).openStream(); + } catch (final IOException ignore) { + return new FileInputStream(arg); + } + } + +} // class InputStreamConverter Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/InputStreamConverter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html 2006-11-25 14:20:52 UTC (rev 209) @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JAPI - (Yet another (hopefully) useful) Java API + - + - Copyright (C) 2004-2006 Christian Hujer + - + - This program is free software; you can redistribute it and/or + - modify it under the terms of the GNU General Public License as + - published by the Free Software Foundation; either version 2 of the + - License, or (at your option) any later version. + - + - This program 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 + - General Public License for more details. + - + - You should have received a copy of the GNU General Public License + - along with this program; if not, write to the Free Software + - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + - 02111-1307, USA. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> + <title>net.sf.japi.io.args.converter</title> + </head> + <body> + <p> + The Converter package contains classes for automatic argument conversion. + For instance, a Command might simply want to read bytes from an InputStream. + The Converter package makes will convert the String into an InputStream then. + </p> + </body> +</html> Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-26 15:40:26
|
Revision: 211 http://svn.sourceforge.net/japi/?rev=211&view=rev Author: christianhujer Date: 2006-11-26 07:40:25 -0800 (Sun, 26 Nov 2006) Log Message: ----------- Started with converter registry, added string converter. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/converter/ConverterRegistry.java libs/argparser/trunk/src/net/sf/japi/io/args/converter/StringConverter.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-11-26 15:38:11 UTC (rev 210) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-11-26 15:40:25 UTC (rev 211) @@ -24,6 +24,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; +import java.io.Closeable; /** * Parser for command line arguments. @@ -52,6 +53,9 @@ /** The currently used option. */ private String currentOption; + /** The list of opened streams. */ + private final List<Closeable> openedStreams = new ArrayList<Closeable>(); + /** * Create a new ArgParser. * This ArgParser uses {@link System#in}, {@link System#out} and {@link System#err}. Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/ConverterRegistry.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/ConverterRegistry.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/ConverterRegistry.java 2006-11-26 15:40:25 UTC (rev 211) @@ -0,0 +1,83 @@ +package net.sf.japi.io.args.converter; + +import java.util.Map; +import java.util.HashMap; +import java.util.Enumeration; +import java.net.URL; +import java.io.IOException; + +/** + * Registry for Converters. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ConverterRegistry { + + /** Singleton instance. */ + private static final ConverterRegistry instance = createSingletonInstance(); + + /** Map for converters. */ + private final Map<Class<?>, Converter<?>> converters = new HashMap<Class<?>, Converter<?>>(); + + /** + * Creates a ConverterRegistry. + * Usually you want a shared global ConverterRegistry and use {@link #getInstance()} instead of creating your own ConverterRegistry instance. + * @see #getInstance() + */ + public ConverterRegistry() { + } + + /** + * Creates the global shared instance of ConverterRegistry. + * @return The global shared instance of ConverterRegistry. + */ + private static ConverterRegistry createSingletonInstance() { + final ConverterRegistry instance = new ConverterRegistry(); + try { + for (final Enumeration<URL> urls = ConverterRegistry.class.getClassLoader().getResources("META-INF/services/net.sf.japi.io.args.ConverterRegistry"); urls.hasMoreElements() ; ) { + final URL url = urls.nextElement(); + // TODO + } + } catch (final IOException e) { + // TODO + e.printStackTrace(); + } + return instance; + } + + /** + * Returns the global shared instance of ConverterRegistry. + * @return The global shared instance of ConverterRegistry. + */ + public static ConverterRegistry getInstance() { + return instance; + } + + /** + * Get the Converter for a specific class. + * @param clazz Class to get Converter for. + * @return <code>null</code> if no suited converter was found. + */ + public <T> Converter<T> getConverter(final Class<T> clazz) { + return (Converter<T>) converters.get(clazz); + } + + /** + * Register a Converter for a specific class. + * @param clazz Class Class to register converter for + * @param converter Converter to register + */ + public <T> void register(final Class<T> clazz, final Converter<T> converter) { + converters.put(clazz, converter); + for (Class<?> superClass = clazz; (superClass = superClass.getSuperclass()) != null;) { + if (!converters.containsKey(superClass)) { + converters.put(superClass, converter); + } + } + for (final Class<?> interf : clazz.getInterfaces()) { + if (!converters.containsKey(interf)) { + converters.put(interf, converter); + } + } + } + +} // class ConverterRegistry Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/ConverterRegistry.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/StringConverter.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/StringConverter.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/StringConverter.java 2006-11-26 15:40:25 UTC (rev 211) @@ -0,0 +1,14 @@ +package net.sf.japi.io.args.converter; + +/** + * Dummy Converter which "converts" a String into a String by simply returning it. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class StringConverter implements Converter<String> { + + /** {@inheritDoc} */ + public String convert(final String arg) throws Exception { + return arg; + } + +} // class StringConverter Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/StringConverter.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. |
From: <chr...@us...> - 2006-11-26 22:45:15
|
Revision: 225 http://svn.sourceforge.net/japi/?rev=225&view=rev Author: christianhujer Date: 2006-11-26 14:45:14 -0800 (Sun, 26 Nov 2006) Log Message: ----------- Improvements on option type description and --help output. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-11-26 22:44:34 UTC (rev 224) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-11-26 22:45:14 UTC (rev 225) @@ -75,7 +75,7 @@ parameterTypes.add(parameterType); } } - final String formatString = "%-" + maxShort + "s%s%-" + maxLong + "s: (%-" + maxOptionTypeWidth + "s) %s%n"; + final String formatString = "%-" + maxShort + "s%s%-" + maxLong + "s: %s%s%n"; final Formatter format = new Formatter(System.err); for (final Method optionMethod : optionMethods) { final Option option = optionMethod.getAnnotation(Option.class); @@ -98,7 +98,7 @@ } catch (final MissingResourceException ignore) { description = ""; } - format.format(formatString, StringJoiner.join(", ", shortNames), delim, StringJoiner.join(", ", longNames), optionType.toString(), description); + format.format(formatString, StringJoiner.join(", ", shortNames), delim, StringJoiner.join(", ", longNames), description, optionType.getDescription()); } format.flush(); } Modified: libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java 2006-11-26 22:44:34 UTC (rev 224) +++ libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java 2006-11-26 22:45:14 UTC (rev 225) @@ -30,13 +30,24 @@ */ public enum OptionType { - /** Required options must always be specified prior to command execution. */ + /** + * Required options must always be specified prior to command execution. + * Please use required options sparingly - if possible none at all. + * Instead provide your program with reasonable defaults. + */ REQUIRED, - /** Optional options may be omitted. */ + /** + * Optional options may be omitted. + * This is the default and usually doesn't need to be changed. + */ OPTIONAL, - /** Terminal options terminate argument parsing, no matter what happens. */ + /** + * Terminal options terminate argument parsing, no matter what happens. + * This is only for special options like --help. + * Normally there should be no need for you to declare your own terminal options. + */ TERMINAL; /** @@ -76,4 +87,18 @@ return getName(); } + /** + * Returns the command line description of this option type. + * @return The command line description of this option type. + */ + public String getDescription() { + String description; + try { + description = ResourceBundle.getBundle("net.sf.japi.io.args.messages").getString(getClass().getName() + "." + name() + ".description"); + } catch (final MissingResourceException e) { + description = name(); + } + return description.length() == 0 ? description : " (" + description + ")"; + } + } // OptionType Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2006-11-26 22:44:34 UTC (rev 224) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2006-11-26 22:45:14 UTC (rev 225) @@ -1,6 +1,9 @@ net.sf.japi.io.args.OptionType.REQUIRED=required +net.sf.japi.io.args.OptionType.REQUIRED.description=required net.sf.japi.io.args.OptionType.OPTIONAL=optional +net.sf.japi.io.args.OptionType.OPTIONAL.description= net.sf.japi.io.args.OptionType.TERMINAL=terminal +net.sf.japi.io.args.OptionType.TERMINAL.description=terminal help=Display this help and exit. setExiting=Quit Java VM with error code. setNotExiting=Don't quit Java VM (default). Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2006-11-26 22:44:34 UTC (rev 224) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2006-11-26 22:45:14 UTC (rev 225) @@ -1,6 +1,9 @@ net.sf.japi.io.args.OptionType.REQUIRED=erforderlich +net.sf.japi.io.args.OptionType.REQUIRED.description=erforderlich net.sf.japi.io.args.OptionType.OPTIONAL=optional +net.sf.japi.io.args.OptionType.OPTIONAL.description= net.sf.japi.io.args.OptionType.TERMINAL=abbrechend +net.sf.japi.io.args.OptionType.TERMINAL.description=abbrechend help=Diese Hilfe anzeigen und beenden. setExiting=Java VM mit Fehlercode beenden setNotExiting=Java VM nicht beenden (Voreinstellung). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-14 23:09:12
|
Revision: 258 http://svn.sourceforge.net/japi/?rev=258&view=rev Author: christianhujer Date: 2006-12-14 15:09:06 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Improvements on BasicCommand. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java libs/argparser/trunk/src/net/sf/japi/io/args/Command.java libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-12-14 23:05:41 UTC (rev 257) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-12-14 23:09:06 UTC (rev 258) @@ -19,34 +19,37 @@ /** The ResourceBundle for locale-specific output. */ private final ResourceBundle resourceBundle = ResourceBundle.getBundle("net.sf.japi.io.args.messages"); - /** The maximum width of the option type field. */ - private final int maxOptionTypeWidth; - /** * Whether to exit or not. - * @see Command#isExiting() + * @see Command#isExiting() */ private boolean exiting; /** Create a BasicCommand. */ protected BasicCommand() { - int tmpMaxOptionTypeWidth = 0; - for (final OptionType optionType : OptionType.values()) { - tmpMaxOptionTypeWidth = Math.max(tmpMaxOptionTypeWidth, optionType.toString().length()); - } - maxOptionTypeWidth = tmpMaxOptionTypeWidth; } /** * Exit Option. + * Normally you wouldn't override this method. + * The default behaviour is to not exit. + * This prevents {@link System#exit(int)} from being invoked when BasicCommand resp. ArgParser is invoked from a running VM. + * If you invoke a command from a batch, setting the <code>exiting</code> property to <code>true</code> makes sense. + * This usually should always be determined by the user of a program, not the programmer. * @param exiting <code>true</code> if {@link System#exit(int)} should be invoked, otherwise <code>false</code>. + * @see System#exit(int) + * @see #isExiting() */ @Option(value = {"exit"}) public void setExiting(@NotNull final Boolean exiting) { this.exiting = exiting; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @see System#exit(int) + * @see #setExiting(Boolean) + */ public Boolean isExiting() { return exiting; } @@ -106,11 +109,50 @@ /** * Get the ResourceBundle for the default locale. - * If you override this method be sure to declare the bundle returned by the overridden method as parent of your bundle. + * If you override this method, the methods of BasicCommand will still use BasicCommand's own ResourceBundle as a backup. + * That means overriding this method will not break any default behaviour of BasicCommand. * @return ResourceBundle for default locale. */ public ResourceBundle getBundle() { return resourceBundle; } + /** + * Get the help header. + * The default implementation returns a bundle String (see {@link #getBundle()}) for the key "helpHeader". + * The default String for "helpHeader" is the empty String. + * @return Help header. + */ + public String getHelpHeader() { + return getString("helpHeader"); + } + + /** + * Get the help footer. + * The default implementation returns a bundle String (see {@link #getBundle()}) for the key "helpFooter". + * The default String for "helpFooter" is the empty String. + * @return Help footer. + */ + public String getHelpFooter() { + return getString("helpFooter"); + } + + /** + * Returns a String from the ResourceBundles. + * This method first tries the subclass's ResourceBundle. + * If that fails, the String is returned from BasicCommand's own resource bundle. + * If that fails too, a MissingResourceException is thrown. + * If that fails, the String is returned from the subclass's ResourceBundle. + * @param key Name of the key to look up + * @return String from the ResourceBundles. + * @throws MissingResourceException In case all tries for retrieving a value for <var>key</var> failed. + */ + private String getString(final String key) throws MissingResourceException { + try { + return getBundle().getString(key); + } catch (MissingResourceException e) { + return resourceBundle.getString(key); + } + } + } // class BasicCommand Modified: libs/argparser/trunk/src/net/sf/japi/io/args/Command.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2006-12-14 23:05:41 UTC (rev 257) +++ libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2006-12-14 23:09:06 UTC (rev 258) @@ -27,7 +27,7 @@ /** * Shell commands can implement this interface and make use of ArgParser. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @see BasicCommand BasicCommand for a convenient implementation of this interface + * @see BasicCommand BasicCommand for a very convenient implementation of this interface */ public interface Command { Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2006-12-14 23:05:41 UTC (rev 257) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2006-12-14 23:09:06 UTC (rev 258) @@ -7,3 +7,5 @@ help=Display this help and exit. setExiting=Quit Java VM with error code. setNotExiting=Don't quit Java VM (default). +helpHeader= +helpFooter= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-18 20:36:51
|
Revision: 313 http://svn.sourceforge.net/japi/?rev=313&view=rev Author: christianhujer Date: 2007-01-18 12:36:41 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Changed package.html to package-info.java Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java Removed Paths: ------------- libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html libs/argparser/trunk/src/net/sf/japi/io/args/package.html Copied: libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java (from rev 306, libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html) =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java 2007-01-18 20:36:41 UTC (rev 313) @@ -0,0 +1,25 @@ +/* + * 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 + */ + +/** + * The Converter package contains classes for automatic argument conversion. + * For instance, a Command might simply want to read bytes from an InputStream. + * The Converter package makes will convert the String into an InputStream then. + */ +package net.sf.japi.io.args.conveter; Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Deleted: libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html 2007-01-18 18:44:02 UTC (rev 312) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/package.html 2007-01-18 20:36:41 UTC (rev 313) @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- JAPI - (Yet another (hopefully) useful) Java API - - - - Copyright (C) 2004-2006 Christian Hujer - - - - This program is free software; you can redistribute it and/or - - modify it under the terms of the GNU General Public License as - - published by the Free Software Foundation; either version 2 of the - - License, or (at your option) any later version. - - - - This program 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 - - General Public License for more details. - - - - You should have received a copy of the GNU General Public License - - along with this program; if not, write to the Free Software - - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - - 02111-1307, USA. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> - <head> - <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> - <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> - <title>net.sf.japi.io.args.converter</title> - </head> - <body> - <p> - The Converter package contains classes for automatic argument conversion. - For instance, a Command might simply want to read bytes from an InputStream. - The Converter package makes will convert the String into an InputStream then. - </p> - </body> -</html> Copied: libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java (from rev 306, libs/argparser/trunk/src/net/sf/japi/io/args/package.html) =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java 2007-01-18 20:36:41 UTC (rev 313) @@ -0,0 +1,46 @@ +/* + * 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 + */ + +/** + * ArgParser is a library for parsing command line arguments. + * <p/> + * It supports short options (e.g. <samp>-h</samp>) and long options (e.g. <samp>--help</samp>). + * <p/> + * If an option takes a parameter, the argument value may follow the option as separate argument. + * If the option is a long option, the value may alternatively be included in the argument string using the <code>'='</code>-character. + * For instance, if an option has short name <samp>i</samp> and long name <samp>in</samp> and the option takes a String argument, the following variants are possible: + * <samp>-i foo</samp>, <samp>--in foo</samp> and <samp>--in=foo</samp>. + * <p/> + * Short options may be given in the same String. + * For instance, if there are the short options <samp>v</samp>, <samp>i</samp> and <samp>s</samp>, all of them may be given together in a single String. + * That means the following variants are possible: + * <samp>-vis</samp>, <samp>-v -i -s</samp> and any combination of separated and concatenated versions like <samp>-v -is</samp>. + * If short options take argument values and they are concatenated, the argument values are separate strings following the concatenated option in exactly the order of the concatenated options. + * In <samp>-io foo bar</samp>, given that both, <samp>i</samp> and <samp>o</samp> take an argument value, <samp>foo</samp> is value for <samp>i</samp>, while <samp>bar</samp> is value for <samp>o</samp>. + * <p/> + * The special option <code>--</code> will stop argument parsing. + * All strings that follow the <code>--</code>-option are treated as command arguments, not options, even if they start with <code>-</code>. + * <p/> + * The ArgParser library is built upon the JavaBeans concept. + * A command is a JavaBean, the command's options are bean properties. + * Currently, the corresponding setter method needs to be marked as {@link Option}. + * In future it will be the underlying field. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +package net.sf.japi.io.args; Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF Deleted: libs/argparser/trunk/src/net/sf/japi/io/args/package.html =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/package.html 2007-01-18 18:44:02 UTC (rev 312) +++ libs/argparser/trunk/src/net/sf/japi/io/args/package.html 2007-01-18 20:36:41 UTC (rev 313) @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- JAPI - (Yet another (hopefully) useful) Java API - - - - Copyright (C) 2004-2006 Christian Hujer - - - - This program is free software; you can redistribute it and/or - - modify it under the terms of the GNU General Public License as - - published by the Free Software Foundation; either version 2 of the - - License, or (at your option) any later version. - - - - This program 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 - - General Public License for more details. - - - - You should have received a copy of the GNU General Public License - - along with this program; if not, write to the Free Software - - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - - 02111-1307, USA. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> - <head> - <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> - <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> - <title>net.sf.japi.io.args</title> - </head> - <body> - <p> - ArgParser is a library for parsing command line arguments. - </p> - <p> - It supports short options (e.g. <samp>-h</samp>) and long options (e.g. <samp>--help</samp>). - </p> - <p> - If an option takes a parameter, the argument value may follow the option as separate argument. - If the option is a long option, the value may alternatively be included in the argument string using the <code>'='</code>-character. - For instance, if an option has short name <samp>i</samp> and long name <samp>in</samp> and the option takes a String argument, the following variants are possible: - <samp>-i foo</samp>, <samp>--in foo</samp> and <samp>--in=foo</samp>. - </p> - <p> - Short options may be given in the same String. - For instance, if there are the short options <samp>v</samp>, <samp>i</samp> and <samp>s</samp>, all of them may be given together in a single String. - That means the following variants are possible: - <samp>-vis</samp>, <samp>-v -i -s</samp> and any combination of separated and concatenated versions like <samp>-v -is</samp>. - If short options take argument values and they are concatenated, the argument values are separate strings following the concatenated option in exactly the order of the concatenated options. - In <samp>-io foo bar</samp>, given that both, <samp>i</samp> and <samp>o</samp> take an argument value, <samp>foo</samp> is value for <samp>i</samp>, while <samp>bar</samp> is value for <samp>o</samp>. - </p> - <p> - The special option <code>--</code> will stop argument parsing. - All strings that follow the <code>--</code>-option are treated as command arguments, not options, even if they start with <code>-</code>. - </p> - <p> - The ArgParser library is built upon the JavaBeans concept. - A command is a JavaBean, the command's options are bean properties. - Currently, the corresponding setter method needs to be marked as {@link Option}. - In future it will be the underlying field. - </p> - </body> -</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-18 21:08:09
|
Revision: 314 http://svn.sourceforge.net/japi/?rev=314&view=rev Author: christianhujer Date: 2007-01-18 13:08:07 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Fixed wrong mime-type property. Property Changed: ---------------- libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/package-info.java ___________________________________________________________________ Name: svn:mime-type - text/html + text/plain Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java ___________________________________________________________________ Name: svn:mime-type - text/xml + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-06-13 19:32:42
|
Revision: 396 http://svn.sourceforge.net/japi/?rev=396&view=rev Author: christianhujer Date: 2007-06-13 12:32:38 -0700 (Wed, 13 Jun 2007) Log Message: ----------- Minor: Fixed javadoc issues. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java libs/argparser/trunk/src/net/sf/japi/io/args/converter/NoConverterFoundException.java libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java 2007-06-10 09:31:21 UTC (rev 395) +++ libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java 2007-06-13 19:32:38 UTC (rev 396) @@ -27,7 +27,9 @@ */ public class MissingArgumentException extends Exception { - /** The option that was missing its argument. */ + /** The option that was missing its argument. + * @serial include + */ @NotNull private final String option; /** Modified: libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java 2007-06-10 09:31:21 UTC (rev 395) +++ libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java 2007-06-13 19:32:38 UTC (rev 396) @@ -26,7 +26,9 @@ */ public class RequiredOptionsMissingException extends Exception { - /** The list of options that were missing. */ + /** The list of options that were missing. + * @serial include + */ @NotNull private final String[] missingOptions; /** Modified: libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java 2007-06-10 09:31:21 UTC (rev 395) +++ libs/argparser/trunk/src/net/sf/japi/io/args/TerminalException.java 2007-06-13 19:32:38 UTC (rev 396) @@ -24,7 +24,9 @@ */ public class TerminalException extends Exception { - /** The return code (eventually reported to the operating system in {@link System#exit(int)}). */ + /** The return code (eventually reported to the operating system in {@link System#exit(int)}). + * @serial include + */ private final int returnCode; /** Modified: libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java 2007-06-10 09:31:21 UTC (rev 395) +++ libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java 2007-06-13 19:32:38 UTC (rev 396) @@ -26,9 +26,10 @@ */ public class UnknownOptionException extends Exception { - /** The list of options that were unknown. */ - @NotNull - private final String[] unknownOptions; + /** The list of options that were unknown. + * @serial include + */ + @NotNull private final String[] unknownOptions; /** * Create a RequiredOptionsMissingException. Modified: libs/argparser/trunk/src/net/sf/japi/io/args/converter/NoConverterFoundException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/NoConverterFoundException.java 2007-06-10 09:31:21 UTC (rev 395) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/NoConverterFoundException.java 2007-06-13 19:32:38 UTC (rev 396) @@ -27,6 +27,7 @@ /** * The type for that no Converter was found. + * @serial include */ private final Class<?> targetType; Modified: libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java 2007-06-10 09:31:21 UTC (rev 395) +++ libs/argparser/trunk/src/net/sf/japi/io/args/package-info.java 2007-06-13 19:32:38 UTC (rev 396) @@ -39,7 +39,7 @@ * <p/> * The ArgParser library is built upon the JavaBeans concept. * A command is a JavaBean, the command's options are bean properties. - * Currently, the corresponding setter method needs to be marked as {@link Option}. + * Currently, the corresponding setter method needs to be marked as {@link net.sf.japi.io.args.Option}. * In future it will be the underlying field. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-06-13 19:34:29
|
Revision: 397 http://svn.sourceforge.net/japi/?rev=397&view=rev Author: christianhujer Date: 2007-06-13 12:33:57 -0700 (Wed, 13 Jun 2007) Log Message: ----------- Minor: Added missing @NotNull annotations. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java 2007-06-13 19:32:38 UTC (rev 396) +++ libs/argparser/trunk/src/net/sf/japi/io/args/MissingArgumentException.java 2007-06-13 19:33:57 UTC (rev 397) @@ -45,7 +45,7 @@ * Get the option that is missing its argument. * @return option that is missing its argument. */ - public String getOption() { + @NotNull public String getOption() { return option; } Modified: libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java 2007-06-13 19:32:38 UTC (rev 396) +++ libs/argparser/trunk/src/net/sf/japi/io/args/RequiredOptionsMissingException.java 2007-06-13 19:33:57 UTC (rev 397) @@ -58,7 +58,7 @@ * Get the options that were missing. * @return options that were missing */ - public String[] getMissingOptions() { + @NotNull public String[] getMissingOptions() { return missingOptions.clone(); } Modified: libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java 2007-06-13 19:32:38 UTC (rev 396) +++ libs/argparser/trunk/src/net/sf/japi/io/args/UnknownOptionException.java 2007-06-13 19:33:57 UTC (rev 397) @@ -58,7 +58,7 @@ * Get the options that were missing. * @return options that were missing */ - public String[] getUnknownOptions() { + @NotNull public String[] getUnknownOptions() { return unknownOptions.clone(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-06-25 11:48:18
|
Revision: 422 http://svn.sourceforge.net/japi/?rev=422&view=rev Author: christianhujer Date: 2007-06-25 04:48:17 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Some code cleanup for the release of 0.1. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.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-06-18 21:51:01 UTC (rev 421) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-06-25 11:48:17 UTC (rev 422) @@ -21,8 +21,15 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; -import java.io.Closeable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; import net.sf.japi.io.args.converter.ConverterRegistry; /** @@ -52,9 +59,6 @@ /** The currently used option. */ private String currentOption; - /** The list of opened streams. */ - private final List<Closeable> openedStreams = new ArrayList<Closeable>(); - /** * Create a new ArgParser. * This ArgParser uses {@link System#in}, {@link System#out} and {@link System#err}. @@ -156,7 +160,7 @@ */ private void parse() throws TerminalException, UnknownOptionException, MissingArgumentException { try { - for (; argIterator.hasNext(); ) { + while (argIterator.hasNext()) { final String arg = argIterator.next(); if (arg.length() > 1 && arg.charAt(0) == '-') { argIterator.remove(); Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2007-06-18 21:51:01 UTC (rev 421) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2007-06-25 11:48:17 UTC (rev 422) @@ -22,7 +22,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Formatter; -import java.util.HashSet; import java.util.List; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -77,7 +76,6 @@ @Option(type = OptionType.TERMINAL, value = {"h", "help"}) public void help() { final Set<Method> optionMethods = ArgParser.getOptionMethods(this); - final Set<Class<?>> parameterTypes = new HashSet<Class<?>>(); int maxLong = 0; int maxShort = 0; for (final Method optionMethod : optionMethods) { @@ -94,9 +92,6 @@ } maxLong = Math.max(maxLong, currentLong - ", ".length()); maxShort = Math.max(maxShort, currentShort - ", ".length()); - for (final Class<?> parameterType : optionMethod.getParameterTypes()) { - parameterTypes.add(parameterType); - } } final String formatString = "%-" + maxShort + "s%s%-" + maxLong + "s: %s%s%n"; final Formatter format = new Formatter(System.err); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-06-25 12:30:51
|
Revision: 426 http://svn.sourceforge.net/japi/?rev=426&view=rev Author: christianhujer Date: 2007-06-25 05:30:50 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Added missing property keys. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties Modified: libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties 2007-06-25 12:21:40 UTC (rev 425) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties 2007-06-25 12:30:50 UTC (rev 426) @@ -17,10 +17,15 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # +java.io.InputStream.displayName=uri|filename|- java.io.InputStream.description=Eingabedatei (als URI, Dateiname oder - f\xFCr STDIN). +java.io.OutputStream.displayName=filename|- java.io.OutputStream.description=Ausgabedatei (Dateiname oder - f\xFCr STDOUT). +java.lang.Boolean.displayName=boolean java.lang.Boolean.description=G\xFCltige Werte: {0} f\xFCr wahr und {1} f\xFCr falsch. java.lang.Boolean.true=wahr ja an java.lang.Boolean.false=falsch nein aus +java.lang.Integer.displayName=integer java.lang.Integer.description=Ganzzahl (dezimal, 0... oktal, 0x... 0X... #... hexadezimal) +java.lang.String.displayName=string java.lang.String.description=Einfacher Text. Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2007-06-25 12:21:40 UTC (rev 425) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2007-06-25 12:30:50 UTC (rev 426) @@ -26,3 +26,5 @@ help=Diese Hilfe anzeigen und beenden. setExiting=Java VM mit Fehlercode beenden setNotExiting=Java VM nicht beenden (Voreinstellung). +helpHeader= +helpFooter= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-06-29 20:08:22
|
Revision: 459 http://svn.sourceforge.net/japi/?rev=459&view=rev Author: christianhujer Date: 2007-06-29 13:08:21 -0700 (Fri, 29 Jun 2007) Log Message: ----------- Improved fix for #1745284 --help options list is not sorted Now the short and long options are mixed when sorting. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/MethodOptionComparator.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2007-06-29 19:56:52 UTC (rev 458) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2007-06-29 20:08:21 UTC (rev 459) @@ -26,8 +26,7 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.Set; -import java.util.Map; -import java.util.HashMap; +import java.util.SortedSet; import java.util.TreeSet; import org.jetbrains.annotations.NotNull; @@ -96,12 +95,14 @@ maxLong = Math.max(maxLong, currentLong - ", ".length()); maxShort = Math.max(maxShort, currentShort - ", ".length()); } - final String formatString = "%s: %s%s%n"; + final String formatString = "%-" + maxShort + "s%s%-" + maxLong + "s: %s%s%n"; final Formatter format = new Formatter(System.err); format.format(getHelpHeader()); - final Map<String, Method> methodMap = new HashMap<String, Method>(); - for (final Method optionMethod : optionMethods) { + final SortedSet<Method> sortedMethods = new TreeSet<Method>(MethodOptionComparator.INSTANCE); + sortedMethods.addAll(optionMethods); + for (final Method optionMethod : sortedMethods) { final Option option = optionMethod.getAnnotation(Option.class); + final OptionType optionType = option.type(); final String[] names = option.value(); final List<String> shortNames = new ArrayList<String>(); final List<String> longNames = new ArrayList<String>(); @@ -113,13 +114,6 @@ } } final String delim = shortNames.size() > 0 && longNames.size() > 0 ? ", " : " "; - final String options = String.format("%-" + maxShort + "s%s%-" + maxLong + "s", StringJoiner.join(", ", shortNames), delim, StringJoiner.join(", ", longNames)); - methodMap.put(options, optionMethod); - } - for (final String options : new TreeSet<String>(methodMap.keySet())) { - final Method optionMethod = methodMap.get(options); - final Option option = optionMethod.getAnnotation(Option.class); - final OptionType optionType = option.type(); String description; try { final String optionKey = option.key().equals("") ? optionMethod.getName() : option.key(); @@ -127,8 +121,7 @@ } catch (final MissingResourceException ignore) { description = ""; } - format.format(formatString, options, description, optionType.getDescription()); - + format.format(formatString, StringJoiner.join(", ", shortNames), delim, StringJoiner.join(", ", longNames), description, optionType.getDescription()); } format.format(getHelpFooter()); format.flush(); Added: libs/argparser/trunk/src/net/sf/japi/io/args/MethodOptionComparator.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/MethodOptionComparator.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/MethodOptionComparator.java 2007-06-29 20:08:21 UTC (rev 459) @@ -0,0 +1,46 @@ +/* + * 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.lang.reflect.Method; +import java.util.Comparator; +import java.util.Arrays; +import org.jetbrains.annotations.NotNull; + +/** Compares methods by their options. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MethodOptionComparator implements Comparator<Method> { + + /** Global instance. */ + @NotNull public static final Comparator<Method> INSTANCE = new MethodOptionComparator(); + + /** {@inheritDoc} */ + public int compare(@NotNull final Method o1, @NotNull final Method o2) { + final Option option1 = o1.getAnnotation(Option.class); + final Option option2 = o2.getAnnotation(Option.class); + final String[] names1 = option1.value(); + final String[] names2 = option2.value(); + Arrays.sort(names1); + Arrays.sort(names2); + return names1[0].compareTo(names2[0]); + } + +} // class MethodOptionComparator Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/MethodOptionComparator.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. |
From: <chr...@us...> - 2007-07-09 21:28:05
|
Revision: 527 http://svn.sourceforge.net/japi/?rev=527&view=rev Author: christianhujer Date: 2007-07-09 14:28:03 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Fixed javadoc issues with new code. (I really should always use IntelliJ IDEA to commit, ouch) Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.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-07-09 21:16:49 UTC (rev 526) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 21:28:03 UTC (rev 527) @@ -19,6 +19,8 @@ package net.sf.japi.io.args; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -30,8 +32,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import net.sf.japi.io.args.converter.ConverterRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -95,6 +95,8 @@ /** * Returns a list of all arguments after parsing arguments files. + * @param args arguments before parsing argument files. + * @return all arguments after parsing argument files. */ public List<String> getAllArguments(@NotNull final List<String> args) { final List<String> argList = new ArrayList<String>(args); @@ -115,13 +117,15 @@ /** * Returns a tokenized unparsed list of arguments from an arguments file. + * @param filename Argument file to read. + * @return all arguments from that argument file. */ public List<String> readFromFile(@NotNull final String filename) { final List<String> args = new ArrayList<String>(); final TokenReader in; try { in = new TokenReader(new FileInputStream(filename)); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { // TODO TODO TODO TODO TODO return args; } Modified: libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java 2007-07-09 21:16:49 UTC (rev 526) +++ libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java 2007-07-09 21:28:03 UTC (rev 527) @@ -40,7 +40,7 @@ @NotNull private Reader in; /** The next token. */ - @Nullable String next; + @Nullable private String next; /** Creates a TokenReader. * @param in InputStream to read from. @@ -95,6 +95,7 @@ switch (mode) { case WHITESPACE: if (Character.isWhitespace(c)) { + // nothing to do - still whitespace. } else if (c == '"') { mode = Mode.STRING; tokenValid = true; @@ -128,6 +129,8 @@ nextToken.append(c); mode = Mode.STRING; break; + default: + assert false; } } } catch (final IOException ignore) { @@ -138,9 +141,17 @@ /** The mode of the tokenizer. */ private enum Mode { + + /** White space. Also starting mode. */ WHITESPACE, + + /** Normal - not whitespace and not inside a String. */ NORMAL, + + /** String - inside "". */ STRING, + + /** String Escape - \ inside "". */ STRING_ESCAPE } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |