001 /**
002 * Copyright 2004-2012 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 */
016 package org.kuali.common.threads.listener;
017
018 import java.io.PrintStream;
019
020 /**
021 * Listener that prints a dot to System.out whenever progress is made.
022 *
023 * @param <T>
024 */
025 public class ConsoleListener<T> implements ProgressListener<T> {
026
027 PrintStream out = System.out;
028 String startToken = ".";
029 String completeToken = ".";
030 String progressToken = ".";
031
032 public ConsoleListener() {
033 this(".", ".");
034 }
035
036 public ConsoleListener(String startToken, String completeToken) {
037 super();
038 this.startToken = startToken;
039 this.completeToken = completeToken;
040 }
041
042 public void progressCompleted() {
043 out.print(completeToken);
044 }
045
046 public void progressStarted() {
047 out.print(startToken);
048 }
049
050 public void progressOccurred(int count, int total, ProgressEvent<T> event) {
051 out.print(progressToken);
052 }
053
054 public PrintStream getOut() {
055 return out;
056 }
057
058 public void setOut(PrintStream out) {
059 this.out = out;
060 }
061
062 public String getStartToken() {
063 return startToken;
064 }
065
066 public void setStartToken(String startToken) {
067 this.startToken = startToken;
068 }
069
070 public String getCompleteToken() {
071 return completeToken;
072 }
073
074 public void setCompleteToken(String completeToken) {
075 this.completeToken = completeToken;
076 }
077
078 public String getProgressToken() {
079 return progressToken;
080 }
081
082 public void setProgressToken(String progressToken) {
083 this.progressToken = progressToken;
084 }
085
086 }