001    /* Copyright 2000, 2001, Compaq Computer Corporation */
002    
003    package javafe.util;
004    
005    /**
006     * The <code>Info</code> class is responsible for displaying verbose
007     * and debugging information to the user.
008     *
009     * <p> Information is displayed only if the <code>on</code> flag is set
010     * (via the <code>-v</code> option, defaults to unset).
011     *
012     * <p> Currently, information is displayed by printing it to
013     * <code>System.out</code>.
014     *
015     * <p> Future versions of this class may support identifying
016     * information with the section it comes from; verbose control could
017     * then be allowed on a section-by-section basis.
018     */
019    
020    public class Info
021    {
022      // Prevent javadoc from displaying a public constructor
023      private Info() {}
024    
025      // Class Variables
026    
027      /**
028       * Verbose and debugging information is displayed iff this is true.
029       * Defaults to false.
030       */
031      public static boolean on = false;
032    
033      // Reporting information
034    
035      /**
036       * Report verbose or debugging information if <code>on</code> is
037       * set.
038       * 
039       * <p> Precondition: <code>msg</code> is not null.
040       *
041       * <p> The message is displayed directly, without any indication
042       * that it is verbose or debugging information.
043       *
044       * <p> Clients of this routine may wish to place calls to it
045       * within a conditional on <code>on</code>.  For example,
046       *
047       * <code>
048       *    if (Info.on) Info.out("[total count = " + countNodes() + "]");
049       * </code><p>
050       *
051       * <p> This may be especially useful if <code>countNodes()</code>
052       * is an expensive operation.
053       */
054      //@ requires msg != null;
055      public static void out(String msg) {
056        if (on) {
057          System.out.println(msg);
058          System.out.flush();
059        }
060      }
061    }