<commit_before>//----------------------------------------------------------------------------//
//                                                                            //
//                             S h e e t T a s k                              //
//                                                                            //
//  Copyright (C) <NAME> 2000-2007. All rights reserved.               //
//  This software is released under the GNU General Public License.           //
//  Contact author at <EMAIL> to report bugs & suggestions. //
//----------------------------------------------------------------------------//
//
package omr.step;

import omr.sheet.Sheet;

import omr.util.Logger;

/**
 * Class <code>SheetTask</code> defines the task for a step at the whole
 * sheet level. This is meant for steps where the systems have not yet been
 * retrieved.
 *
 * @author <NAME>
 * @version $Id$
 */
public abstract class SheetTask
{
    //~ Static fields/initializers ---------------------------------------------

    /** Usual logger utility */
    private static final Logger logger = Logger.getLogger(SheetTask.class);

    //~ Instance fields --------------------------------------------------------

    /** The related sheet */
    protected final Sheet sheet;

    /** The related step for this task */
    protected final Step step;

    /** Flag to indicate the task has been done (actually launched) */
    protected volatile boolean stepDone;

    //~ Constructors -----------------------------------------------------------

    //-----------//
    // SheetTask //
    //-----------//
    /**
     * Creates a task at sheet level
     * @param sheet the processed sheet
     * @param step the step performed by the task
     */
    protected SheetTask (Sheet sheet,
                         Step  step)
    {
        this.sheet = sheet;
        this.step = step;
    }

    //~ Methods ----------------------------------------------------------------

    //-----------//
    // displayUI //
    //-----------//
    /**
     * Make the related user interface visible for this step
     */
    public void displayUI ()
    {
        // Void by default
    }

    //------//
    // doit //
    //------//
    /**
     * Actually perform the step
     * @throws StepException raised if processing failed
     */
    public abstract void doit ()
        throws StepException;

    //--------//
    // isDone //
    //--------//
    /**
     * Check whether this task has been done
     * @return true if started/done, false otherwise
     */
    public boolean isDone ()
    {
        return stepDone;
    }

    //-----------//
    // getResult //
    //-----------//
    /**
     * Make sure this step has been run (at least started)
     * @throws StepException raised if processing failed
     */
    public void getResult ()
        throws StepException
    {
        if (!isDone()) {
            if (logger.isFineEnabled()) {
                logger.fine(step + " doit ...");
            }

            doit();

            if (logger.isFineEnabled()) {
                logger.fine(step + " doit end");
            }
        }
    }

    //------//
    // done //
    //------//
    /**
     * Flag this step as done
     */
    public void done ()
    {
        if (logger.isFineEnabled()) {
            logger.fine(step + " done");
        }

        stepDone = true;
    }
}<commit_msg>Comments<commit_after>//----------------------------------------------------------------------------//
//                                                                            //
//                             S h e e t T a s k                              //
//                                                                            //
//  Copyright (C) <NAME> 2000-2007. All rights reserved.               //
//  This software is released under the GNU General Public License.           //
//  Contact author at <EMAIL> to report bugs & suggestions. //
//----------------------------------------------------------------------------//
//
package omr.step;

import omr.sheet.Sheet;

import omr.util.Logger;

/**
 * Class <code>SheetTask</code> defines the task for a step at the whole
 * sheet level. This is meant for steps where the systems have not yet been
 * retrieved.
 *
 * @author <NAME>
 * @version $Id$
 */
public abstract class SheetTask
{
    //~ Static fields/initializers ---------------------------------------------

    /** Usual logger utility */
    private static final Logger logger = Logger.getLogger(SheetTask.class);

    //~ Instance fields --------------------------------------------------------

    /** The related sheet */
    protected final Sheet sheet;

    /** The related step for this task */
    protected final Step step;

    /** Flag to indicate the task has been done (actually launched) */
    protected volatile boolean stepDone;

    //~ Constructors -----------------------------------------------------------

    //-----------//
    // SheetTask //
    //-----------//
    /**
     * Creates a task at sheet level
     * @param sheet the processed sheet
     * @param step the step performed by the task
     */
    protected SheetTask (Sheet sheet,
                         Step  step)
    {
        this.sheet = sheet;
        this.step = step;
    }

    //~ Methods ----------------------------------------------------------------

    //-----------//
    // displayUI //
    //-----------//
    /**
     * Make the related user interface visible for this step
     */
    public void displayUI ()
    {
        // Void by default
    }

    //------//
    // doit //
    //------//
    /**
     * Actually perform the step
     * @throws StepException raised if processing failed
     */
    public abstract void doit ()
        throws StepException;

    //--------//
    // isDone //
    //--------//
    /**
     * Check whether this task has been done
     * @return true if started/done, false otherwise
     */
    public boolean isDone ()
    {
        return stepDone;
    }

    //-----------//
    // getResult //
    //-----------//
    /**
     * Make sure this step has been run (at least started)
     * @throws StepException raised if processing failed
     */
    public void getResult ()
        throws StepException
    {
        if (!isDone()) {
            if (logger.isFineEnabled()) {
                logger.fine(step + " doit ...");
            }

            doit();
        }
    }

    //------//
    // done //
    //------//
    /**
     * Flag this step as done
     */
    public void done ()
    {
        if (logger.isFineEnabled()) {
            if (!(this instanceof SystemTask)) {
                logger.fine(step + " done");
            }
        }

        stepDone = true;
    }
}
{'fraction_non_alphanumeric': 0.2403704792708027, 'fraction_numerical': 0.0023522493384298734, 'mean_word_length': 0.9061361725973662, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4989840', 'n_tokens_mistral': 1602, 'n_tokens_neox': 1522, 'n_words': 503}