KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > backup > ImportLogger


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.backup;
6 /**
7  * May 27, 2004
8  * @author: Tuan Nguyen
9  * @email: tuan08@users.sourceforge.net
10  * @version: $ID$
11  **/

12 public class ImportLogger {
13     private int numberOfEntry_ ;
14     private int numberOfFail_ ;
15     private StringBuffer JavaDoc buffer_ ;
16     private StringBuffer JavaDoc errorBuffer_ ;
17     
18     public ImportLogger() {
19         numberOfEntry_ = 0;
20         numberOfFail_ = 0;
21         buffer_ = new StringBuffer JavaDoc(5000) ;
22         errorBuffer_ = new StringBuffer JavaDoc(1000) ;
23     }
24     
25     public void log(String JavaDoc record) {
26         numberOfEntry_++ ;
27         buffer_.append("import record ").append(record).append(" successfully\n");
28     }
29     
30     public void log(String JavaDoc record, Throwable JavaDoc t) {
31         numberOfEntry_++ ;
32         numberOfFail_++ ;
33         errorBuffer_.append("import record ").append(record).append(" fail\n");
34     }
35     
36     public String JavaDoc getTextSummary() {
37         StringBuffer JavaDoc b = new StringBuffer JavaDoc() ;
38         b.append("Number of entry: ").append(numberOfEntry_).append("\n") ;
39         b.append("Number of fail entry: ").append(numberOfFail_).append("\n") ;
40         b.append(buffer_);
41         b.append(errorBuffer_);
42         return b.toString() ;
43     }
44 }
Popular Tags