geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r572538 - /geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/console/IO.java
Date Tue, 04 Sep 2007 06:08:40 GMT
Author: jdillon
Date: Mon Sep  3 23:08:39 2007
New Revision: 572538

URL: http://svn.apache.org/viewvc?rev=572538&view=rev
Log:
Add verbosity field to IO container

Modified:
    geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/console/IO.java

Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/console/IO.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/console/IO.java?rev=572538&r1=572537&r2=572538&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/console/IO.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/console/IO.java
Mon Sep  3 23:08:39 2007
@@ -36,21 +36,21 @@
     /**
      * Raw input stream.
      *
-     * @see #in
+     * @see #in     For general usage, please use the reader.
      */
     public final InputStream inputStream;
 
     /**
      * Raw output stream.
      *
-     * @see #out
+     * @see #out    For general usage, please use the writer.
      */
     public final OutputStream outputStream;
 
     /**
      * Raw error output stream.
      *
-     * @see #err
+     * @see #err    For general usage, please use the writer.
      */
     public final OutputStream errorStream;
 
@@ -70,6 +70,12 @@
     public final PrintWriter err;
 
     /**
+     * The verbosity setting, which commands (and framework) should inspect and respect when
+     * spitting up output to the user.
+     */
+    private Verbosity verbosity = Verbosity.INFO;
+
+    /**
      * Construct a new IO container.
      *
      * @param in    The input steam; must not be null
@@ -108,6 +114,48 @@
     }
 
     /**
+     * Set the verbosity level.
+     *
+     * @param verbosity
+     */
+    public void setVerbosity(final Verbosity verbosity) {
+        assert verbosity != null;
+        
+        this.verbosity = verbosity;
+    }
+
+    /**
+     * Check if the verbosity level is set to {@link Verbosity#QUIET}.
+     */
+    public boolean isQuiet() {
+        return verbosity == Verbosity.QUIET;
+    }
+
+    /**
+     * Check if the verbosity level is set to {@link Verbosity#INFO}.
+     */
+    public boolean isInfo() {
+        return verbosity == Verbosity.INFO;
+    }
+
+    /**
+     * Check if the verbosity level is set to {@link Verbosity#VERBOSE}.
+     */
+    public boolean isVerbose() {
+        return verbosity == Verbosity.VERBOSE;
+    }
+
+    /**
+     * Check if the verbosity level is set to {@link Verbosity#DEBUG}.
+     *
+     * <p>For generaly usage, when debug output is required, it is better
+     * to use the logging facility instead.
+     */
+    public boolean isDebug() {
+        return verbosity == Verbosity.DEBUG;
+    }
+
+    /**
      * Flush both output streams.
      */
     public void flush() {
@@ -119,5 +167,20 @@
         in.close();
         out.close();
         err.close();
+    }
+
+    //
+    // Verbosity
+    //
+
+    /**
+     * Defines the valid values of the {@link IO} containers verbosity settings.
+     */
+    public static enum Verbosity
+    {
+        QUIET,
+        INFO,
+        VERBOSE,
+        DEBUG
     }
 }



Mime
View raw message