001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util;
017
018import java.io.PrintStream;
019
020import org.slf4j.Logger;
021import org.slf4j.LoggerFactory;
022
023/**
024 * Print a dot to the console each time we make progress
025 * 
026 * @deprecated
027 */
028@Deprecated
029public abstract class AbstractProgressInformer {
030
031        private static final Logger logger = LoggerFactory.getLogger(AbstractProgressInformer.class);
032
033        protected long progress;
034
035        PrintStream printStream = System.out;
036        String startToken = "[INFO] Progress: ";
037        String progressToken = ".";
038        String completeToken = "\n";
039        LogMsg startMessage;
040        LogMsg stopMessage;
041
042        /**
043         * Thread safe method exposing the current progress
044         */
045        public synchronized long getProgress() {
046                return progress;
047        }
048
049        /**
050         * Print the start token
051         */
052        public void start() {
053                if (startMessage != null) {
054                        LoggerUtils.log(startMessage, logger);
055                }
056
057                Assert.notNull(printStream, "printStream is null");
058                this.progress = 0;
059
060                printStream.print(startToken);
061        }
062
063        /**
064         * Print the stop token
065         */
066        public void stop() {
067                printStream.print(completeToken);
068
069                if (stopMessage != null) {
070                        LoggerUtils.log(stopMessage, logger);
071                }
072        }
073
074        public PrintStream getPrintStream() {
075                return printStream;
076        }
077
078        public void setPrintStream(PrintStream printStream) {
079                this.printStream = printStream;
080        }
081
082        public String getStartToken() {
083                return startToken;
084        }
085
086        public void setStartToken(String startToken) {
087                this.startToken = startToken;
088        }
089
090        public String getCompleteToken() {
091                return completeToken;
092        }
093
094        public void setCompleteToken(String completeToken) {
095                this.completeToken = completeToken;
096        }
097
098        public String getProgressToken() {
099                return progressToken;
100        }
101
102        public void setProgressToken(String progressToken) {
103                this.progressToken = progressToken;
104        }
105
106        public LogMsg getStartMessage() {
107                return startMessage;
108        }
109
110        public void setStartMessage(LogMsg startMessage) {
111                this.startMessage = startMessage;
112        }
113
114        public LogMsg getStopMessage() {
115                return stopMessage;
116        }
117
118        public void setStopMessage(LogMsg stopMessage) {
119                this.stopMessage = stopMessage;
120        }
121
122}