JournalEntry.java

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

Generated on Mon Jan 11 21:19:15 2010 for OpenMobileIS by  doxygen 1.5.4