net.sf.cpsolver.ifs.util
Class Progress

java.lang.Object
  extended by net.sf.cpsolver.ifs.util.Progress

public class Progress
extends Object

Progress bar.

Single instance class for recording the current state. It also allows recursive storing/restoring of the progress.

Use:

Version:
IFS 1.1 (Iterative Forward Search)
Copyright (C) 2006 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

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

Nested Class Summary
static class Progress.Message
          Log nessage
 
Field Summary
static int MSGLEVEL_DEBUG
           
static int MSGLEVEL_ERROR
           
static int MSGLEVEL_FATAL
           
static int MSGLEVEL_INFO
           
static int MSGLEVEL_PROGRESS
           
static int MSGLEVEL_STAGE
           
static int MSGLEVEL_TRACE
           
static int MSGLEVEL_WARN
           
static SimpleDateFormat sDF
           
static boolean sTraceEnabled
           
 
Method Summary
 void addProgressListener(ProgressListener listener)
          Adds progress listener
static void changeInstance(Object oldKey, Object newKey)
          Change progress instance for the given key
 void clear()
          Clear the log
 void clearProgressListeners()
          Remove all progress listeners
 void debug(String message)
          Prints a debug message
 void debug(String message, Throwable e)
          Prints a debug message
 void error(String message)
          Prints an error message
 void error(String message, Throwable e)
          Prints an error message
 void fatal(String message)
          Prints a fatal message
 void fatal(String message, Throwable e)
          Prints a fatal message
 String getHtmlLog(int level, boolean includeDate)
          Returns log in HTML format
 String getHtmlLog(int level, boolean includeDate, String fromStage)
          Returns log in HTML format (only messages with the given level or higher are included)
static Progress getInstance()
          Progress default instance
static Progress getInstance(Object key)
          Progress instance
 Vector getLog()
          Returns log (list of messages)
 String getLog(int level)
          Returns log (list of messages).
 String getPhase()
          Current phase
 long getProgress()
          Current progress
 long getProgressMax()
          Maximum of current progress
 String getStatus()
          Current status
 void incProgress()
          Increment current progress
 void info(String message)
          Prints an info message
 void info(String message, Throwable e)
          Prints an info message
 void load(org.dom4j.Element root, boolean clear)
          Restores the message log from the given XML element
 void message(int level, String message)
          Prints a message
 void message(int level, String message, Throwable t)
          Prints a message
static void removeInstance(Object key)
          Remove progress instance for the given key
 void removeProgressListener(ProgressListener listener)
          Remove progress listener
 void restore()
          Resore the progress from the heap memory
 void save()
          Save current progress to the heap memory
 void save(org.dom4j.Element root)
          Saves the message log into the given XML element
 void setPhase(String phase)
          Sets current phase.
 void setPhase(String phase, long progressMax)
          Sets current phase
 void setProgress(long progress)
          Update progress bar.
 void setStatus(String status)
          Sets current status
 void trace(String message)
          Prints a trace message
 void trace(String message, Throwable e)
          Prints a trace message
 void warn(String message)
          Prints a warning message
 void warn(String message, Throwable e)
          Prints a warning message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sTraceEnabled

public static boolean sTraceEnabled

sDF

public static SimpleDateFormat sDF

MSGLEVEL_TRACE

public static final int MSGLEVEL_TRACE
See Also:
Constant Field Values

MSGLEVEL_DEBUG

public static final int MSGLEVEL_DEBUG
See Also:
Constant Field Values

MSGLEVEL_PROGRESS

public static final int MSGLEVEL_PROGRESS
See Also:
Constant Field Values

MSGLEVEL_INFO

public static final int MSGLEVEL_INFO
See Also:
Constant Field Values

MSGLEVEL_STAGE

public static final int MSGLEVEL_STAGE
See Also:
Constant Field Values

MSGLEVEL_WARN

public static final int MSGLEVEL_WARN
See Also:
Constant Field Values

MSGLEVEL_ERROR

public static final int MSGLEVEL_ERROR
See Also:
Constant Field Values

MSGLEVEL_FATAL

public static final int MSGLEVEL_FATAL
See Also:
Constant Field Values
Method Detail

getInstance

public static Progress getInstance()
Progress default instance


getInstance

public static Progress getInstance(Object key)
Progress instance


changeInstance

public static void changeInstance(Object oldKey,
                                  Object newKey)
Change progress instance for the given key


removeInstance

public static void removeInstance(Object key)
Remove progress instance for the given key


getStatus

public String getStatus()
Current status


setStatus

public void setStatus(String status)
Sets current status


getPhase

public String getPhase()
Current phase


setPhase

public void setPhase(String phase,
                     long progressMax)
Sets current phase

Parameters:
phase - phase name
progressMax - maximum of progress bar

setPhase

public void setPhase(String phase)
Sets current phase. Maximum of progress bar is set to 100.

Parameters:
phase - phase name

setProgress

public void setProgress(long progress)
Update progress bar.

Parameters:
progress - progress between 0 and progressMax

getProgress

public long getProgress()
Current progress


getProgressMax

public long getProgressMax()
Maximum of current progress


incProgress

public void incProgress()
Increment current progress


addProgressListener

public void addProgressListener(ProgressListener listener)
Adds progress listener


removeProgressListener

public void removeProgressListener(ProgressListener listener)
Remove progress listener


clearProgressListeners

public void clearProgressListeners()
Remove all progress listeners


save

public void save()
Save current progress to the heap memory


restore

public void restore()
Resore the progress from the heap memory


message

public void message(int level,
                    String message,
                    Throwable t)
Prints a message


message

public void message(int level,
                    String message)
Prints a message


trace

public void trace(String message)
Prints a trace message


debug

public void debug(String message)
Prints a debug message


info

public void info(String message)
Prints an info message


warn

public void warn(String message)
Prints a warning message


error

public void error(String message)
Prints an error message


fatal

public void fatal(String message)
Prints a fatal message


trace

public void trace(String message,
                  Throwable e)
Prints a trace message


debug

public void debug(String message,
                  Throwable e)
Prints a debug message


info

public void info(String message,
                 Throwable e)
Prints an info message


warn

public void warn(String message,
                 Throwable e)
Prints a warning message


error

public void error(String message,
                  Throwable e)
Prints an error message


fatal

public void fatal(String message,
                  Throwable e)
Prints a fatal message


getLog

public Vector getLog()
Returns log (list of messages)


getLog

public String getLog(int level)
Returns log (list of messages). Only messages with the given level or higher are included.


getHtmlLog

public String getHtmlLog(int level,
                         boolean includeDate)
Returns log in HTML format


getHtmlLog

public String getHtmlLog(int level,
                         boolean includeDate,
                         String fromStage)
Returns log in HTML format (only messages with the given level or higher are included)


clear

public void clear()
Clear the log


save

public void save(org.dom4j.Element root)
Saves the message log into the given XML element


load

public void load(org.dom4j.Element root,
                 boolean clear)
Restores the message log from the given XML element