Revision: 5381 http://jnode.svn.sourceforge.net/jnode/?rev=5381&view=rev Author: fduminy Date: 2009-05-01 21:45:43 +0000 (Fri, 01 May 2009)
Log Message: ----------- added javadoc Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java 2009-05-01 15:30:29 UTC (rev 5380) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/Context.java 2009-05-01 21:45:43 UTC (rev 5381) @@ -25,11 +25,36 @@ import java.io.InputStreamReader; import java.io.PrintStream; +/** + * Represents the context with the shell : input and output streams + * and the error reporter (error stream might eventually be used by some + * {...@link ErrorReporter} implementations). + * + * @author Fabien DUMINY (fdum...@jnode.org) + * + */ public class Context { + /** + * Reader for the input stream. + */ private final BufferedReader in; + + /** + * Output stream. + */ private final PrintStream out; + + /** + * Error reporter. + */ private final ErrorReporter errorReporter; + /** + * Constructor. + * @param in Input stream. + * @param out Output stream. + * @param errorReporter Error reporter. + */ public Context(InputStream in, PrintStream out, ErrorReporter errorReporter) { InputStreamReader r = new InputStreamReader(in); this.in = new BufferedReader(r); @@ -38,14 +63,26 @@ this.errorReporter = errorReporter; } + /** + * Get the reader for the input stream. + * @return Reader for the input stream. + */ public final PrintStream getOut() { return out; } + /** + * Get the output stream. + * @return Output stream. + */ public final BufferedReader getIn() { return in; } + /** + * Get the error reporter. + * @return Error reporter. + */ public final ErrorReporter getErrorReporter() { return errorReporter; } Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java 2009-05-01 15:30:29 UTC (rev 5380) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/ErrorReporter.java 2009-05-01 21:45:43 UTC (rev 5381) @@ -22,19 +22,51 @@ import org.apache.log4j.Logger; +/** + * Base class used to report errors. It's only reporting errors to the logs. + * Sub classes should override {...@link #displayError(Object, String)} to actually + * display errors in the user interface. + * @author Fabien DUMINY (fdum...@jnode.org) + * + */ public class ErrorReporter { + /** + * Report an error from a {...@link Throwable}. + * @param log The logger to which error is reported (user interface might also display it). + * @param source The source object of the error. + * @param t The {...@link Throwable} that is being thrown because of the error. + */ public final void reportError(Logger log, Object source, Throwable t) { reportError(log, source, (Object) t); } + /** + * Display an error from its string representation. + * @param log The logger to which error is reported (user interface might also display it). + * @param source The source object of the error. + * @param message The string representation of the error when no {...@link Throwable} is thrown. + */ public final void reportError(Logger log, Object source, String message) { reportError(log, source, (Object) message); } + /** + * Display errors in the user interface. Do nothing by default. + * User interface implementors should override it for appropriate displaying. + * @param source The source object of the error. + * @param message The message of the error. + */ protected void displayError(Object source, String message) { // by default display nothing } + /** + * Actual implementation of the public methods that trace the error in the logs + * and delegate the user interface reporting to {...@link #displayError(Object, String)}. + * @param log The logger to which error is reported (user interface might also display it). + * @param source The source object of the error. + * @param message The string representation of the error when no {...@link Throwable} is thrown. + */ private final void reportError(Logger log, Object source, Object message) { Throwable t = (message instanceof Throwable) ? (Throwable) message : null; Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2009-05-01 15:30:29 UTC (rev 5380) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2009-05-01 21:45:43 UTC (rev 5381) @@ -22,15 +22,36 @@ import org.jnode.apps.jpartition.model.UserFacade; +/** + * Main class of JPartition application. + * @author Fabien DUMINY (fdum...@jnode.org) + * + */ public class JPartition { + /** + * The view factory used to create the user interface. + */ private final ViewFactory viewFactory; + + /** + * True if we are trying to install jnode, false in other cases. + */ private final boolean install; + /** + * Constructor for a new instance of JPartition application. + * @param viewFactory The view factory used to create the user interface. + * @param install True if we are trying to install jnode, false in other cases. + */ public JPartition(ViewFactory viewFactory, boolean install) { this.viewFactory = viewFactory; this.install = install; } + /** + * Actually show the user interface from parameters given at construction time. + * @throws Exception + */ public final void launch() throws Exception { ErrorReporter errorReporter = viewFactory.createErrorReporter(); UserFacade.getInstance().setErrorReporter(errorReporter); Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2009-05-01 15:30:29 UTC (rev 5380) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2009-05-01 21:45:43 UTC (rev 5381) @@ -29,6 +29,11 @@ import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.FlagArgument; +/** + * Command to launch JPartition from JNode's shell. + * @author Fabien DUMINY (fdum...@jnode.org) + * + */ public class JPartitionCommand extends AbstractCommand { private final FlagArgument FLAG_SWING = new FlagArgument("swing", Argument.OPTIONAL, "if set, use the Swing (graphic) UI"); @@ -39,15 +44,26 @@ private final FlagArgument ARG_INSTALL = new FlagArgument("install", Argument.OPTIONAL, "if set, format the partition(s)"); + /** + * Constructor. + */ public JPartitionCommand() { super("interactive disk partitioning tool"); registerArguments(FLAG_CONSOLE, FLAG_SWING, ARG_INSTALL); } + /** + * Main method to run JPartition outside of JNode. + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { new JPartitionCommand().execute(args); } + /** + * {...@inheritdoc} + */ public void execute() throws Exception { boolean install = ARG_INSTALL.isSet(); @@ -60,6 +76,9 @@ doExecute(install, in, out, err, consoleView, swingView); } + /** + * {...@inheritdoc} + */ public void doExecute(boolean install, InputStream in, PrintStream out, PrintStream err, boolean consoleView, boolean swingView) throws Exception { ViewFactory viewFactory = consoleView ? new ConsoleViewFactory(in, out, err) Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java 2009-05-01 15:30:29 UTC (rev 5380) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/ViewFactory.java 2009-05-01 21:45:43 UTC (rev 5381) @@ -20,11 +20,34 @@ package org.jnode.apps.jpartition; +/** + * Factory used to build a user interface (text mode, graphical mode ...) for JPartition. + * + * @author Fabien DUMINY (fdum...@jnode.org) + * + */ public interface ViewFactory { + /** + * Creates a view for the devices which might or might not (implementor's choice) + * display available devices, their partitions... + * @param errorReporter The error reporter to use (normally created by this factory). + * @param cmdProcessorView The command processor view to use (normally created by this factory). + * @param install True if we are trying to install jnode, false in other cases. + * @return The device view. + * @throws Exception + */ Object createDeviceView(ErrorReporter errorReporter, Object cmdProcessorView, boolean install) throws Exception; + /** + * Creates a command processor view. + * @return A new command processor view. + */ Object createCommandProcessorView(); + /** + * Creates an error reporter. + * @return A new error reporter. + */ ErrorReporter createErrorReporter(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits