Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

DefaultLogRenderer.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  * 
00024  */
00025 
00026 package org.openmobileis.synchro.journal;
00027 
00036 import freemarker.template.*;
00037 
00038 public abstract class DefaultLogRenderer implements JournalLogRenderer {
00039 
00040   protected String syncName;
00041 
00042   public DefaultLogRenderer() {}
00043 
00044   public DefaultLogRenderer(String syncName) {
00045       this.syncName = syncName;
00046   }
00047 
00048   public void render(SimpleList templatelist, JournalEntry[] entryList) {
00049     SimpleHash hash = new SimpleHash();
00050     SimpleList loglist = new SimpleList();
00051     for (int i=0; i<entryList.length; i++)  {
00052           // By default, the index 0 is used for the main entry (listener entry)
00053           if (entryList[i].getServiceEntryID() == 0)  {
00054             hash.put("serviceName", this.getSyncLabel());
00055             hash.put("synchroMessage", new SimpleScalar(entryList[i].getEntryData()));
00056             hash.put("synchroDate", entryList[i].getFormatedDate());
00057           } else  {
00058             SimpleHash hashlog = new SimpleHash();
00059             hashlog.put("detailMessage", entryList[i].getEntryData());
00060             if (entryList[i].getStatus() != -1)  {
00061               hashlog.put("status", String.valueOf(entryList[i].getStatus()));
00062             }
00063             loglist.add(hashlog);
00064           }
00065         }
00066     hash.put("detailLogList", loglist);
00067     hash.put("hasEntries", new SimpleScalar(entryList.length > 1));
00068     templatelist.add(hash);
00069   }
00070 
00071   public String getSyncName() {
00072     return syncName;
00073   }
00074         
00078   public abstract String getSyncLabel();
00079 
00080 
00081 }

Generated on Wed Dec 14 21:05:32 2005 for OpenMobileIS by  doxygen 1.4.4