001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Portions Copyright 2013-2014 ForgeRock AS
025 */
026package org.opends.server.tools.upgrade;
027
028import javax.security.auth.callback.TextOutputCallback;
029
030import org.forgerock.i18n.LocalizableMessage;
031
032/**
033 * A progress notification callback.
034 */
035public class ProgressNotificationCallback extends TextOutputCallback
036{
037  /**
038   * The serial version uid.
039   */
040  private static final long serialVersionUID = 55L;
041
042  /**
043   * An integer representing the percentage of the task's process.
044   */
045  private int progress;
046
047  /**
048   * A progress notification constructor.
049   *
050   * @param messageType
051   *          The type of the message, usually INFORMATION.
052   * @param message
053   *          The message to display
054   * @param progress
055   *          An integer representing the percentage of the task's progress.
056   */
057  ProgressNotificationCallback(final int messageType,
058      final LocalizableMessage message, final int progress)
059  {
060    super(messageType, message.toString());
061    this.progress = progress;
062  }
063
064  /**
065   * Returns an integer which represents the task's progress percentage.
066   *
067   * @return An integer which represents the task's progress percentage.
068   */
069  public int getProgress()
070  {
071    return progress;
072  }
073
074  /**
075   * Change the progress on an existing progress notification callback.
076   *
077   * @param progress
078   *          The new value of the progress.
079   * @return A progress Notification Callback
080   */
081  ProgressNotificationCallback setProgress(int progress)
082  {
083    this.progress = progress;
084    return this;
085  }
086
087}