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

JournalEntry.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 
00028 import org.openmobileis.common.util.OpenMISSerializable;
00029 
00030 
00031 
00041  public class JournalEntry implements OpenMISSerializable {
00042    static final long serialVersionUID = 5521257935120563452L;
00043 
00044   // contants for entryID :
00045     // general error on server for a sync PDA command(SERVER -> PDA)
00046     public static short ERROR_SYNC = 0;
00047     // error on PDA (add, replace or delete action)
00048     public static short ERROR_OP_MOBILE = 1;
00049     // map error
00050     public static short ERROR_MAP = 2;
00051     // general error for server sync command (PDA -> SERVER)
00052     public static short ERROR_SYNC_SERVER = 3;
00053     // error Add operation
00054     public static short ERROR_ADD = 4;
00055     // error Replace operation
00056     public static short ERROR_REPLACE = 5;
00057     // error Delete operation
00058     public static short ERROR_DELETE = 6;
00059     // error during sync command request on PDA side
00060     public static short ERROR_SYNC_MOBILE = 7;
00061 
00062     private String serviceName;
00063     private short entryID;
00064     private String entryData;
00065     private long date;
00066     private int status;
00067 
00068  public JournalEntry() { }
00069 
00070   public JournalEntry(String service, short id, String data, int status, long date) {
00071     serviceName = service;
00072     entryID = id;
00073     entryData = data;
00074     this.date = date;
00075     this.status = status;
00076   }
00077 
00078         public String getServiceName()  {
00079                 return serviceName;
00080         }
00081   
00085 /*  public static String convertServiceNameToCollectionEntry (String name)      {
00086         return "FWKJ"+name;
00087   }*/
00088 
00089   public void setDate(long date)  {
00090     this.date = date;
00091   }
00092 
00093   public void setServiceName(String service)  {
00094     serviceName = service;
00095   }
00096 
00097   public short getServiceEntryID()  {
00098     return entryID;
00099   }
00100 
00101   public void setServiceEntryID(short id)  {
00102     entryID = id;
00103   }
00104 
00105   public String getEntryData()  {
00106     return entryData;
00107   }
00108 
00109   public void setEntryData(String data)  {
00110     entryData = data;
00111   }
00112 
00113   public void setStatus (int status) {
00114     this.status = status;
00115   }
00116 
00117   public int getStatus() {
00118     return status;
00119   }
00120 
00121   public long getDate() {
00122     return date;
00123   }
00124 
00125   public String getFormatedDate() {
00126     java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat("'le' dd/MM/yy 'à' HH'h'mm'.'", java.util.Locale.FRANCE);
00127     return formater.format(new java.util.Date(date));
00128   }
00129 
00130   public int hashCode() {
00131     return (serviceName+"%"+Short.toString(entryID)).hashCode();
00132   }
00133 
00134   public boolean equals(Object obj) {
00135     if (obj instanceof JournalEntry)  {
00136       return ((((JournalEntry)obj).getServiceName().equals(this.getServiceName()))
00137              && (((JournalEntry)obj).entryID == this.getServiceEntryID()));
00138     }
00139     return false;
00140   }
00141   
00142   public String getEntryID()    {
00143         return this.serviceName+Short.toString(this.entryID);
00144   }
00145 
00146 }

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