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