SyncNumberManager.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  *  Modifications :
00025  *  2004 Creation P.Delrieu
00026  * 
00027  */
00028 
00029 package org.openmobileis.synchro.algo.syncnumber;
00030 
00031 import org.openmobileis.common.util.exception.DatabaseException;
00032 import org.openmobileis.synchro.algo.syncnumber.impl.DefaultSyncNumberManagerDelegate;
00033 
00041 public class SyncNumberManager {
00042   private static SyncNumberManager manager;
00043   private SyncNumberManagerDelegate delegate;
00044 
00045   private SyncNumberManager() {
00046   }
00047 
00048   public static SyncNumberManager getManager() {
00049      if (manager == null)  {
00050         synchronized(SyncNumberManager.class) {
00051         if (manager == null)  {
00052           manager = new SyncNumberManager();
00053         }
00054       }
00055     }
00056     return manager;
00057   }
00058   
00059   public void registerDelegate(SyncNumberManagerDelegate delegate) {
00060         this.delegate = delegate;
00061         this.delegate.initDelegate();
00062   }
00063   
00064   public SyncNumberManagerDelegate getDelegate() {
00065         if (this.delegate == null) {
00066                 this.delegate = new DefaultSyncNumberManagerDelegate();
00067         }
00068         return this.delegate;
00069   }
00070 
00071   public SynchroNumber getSynchroNumber(long ns) throws SyncNumberNotFoundException {
00072         return this.getDelegate().getSynchroNumber(ns);
00073   }
00074 
00075   public SynchroNumber getNextSynchroNumber() throws DatabaseException {
00076     return this.getDelegate().getNextSynchroNumber();
00077   }
00078 
00084   public long getCurrentSynchroNumber()  throws DatabaseException {
00085     return this.getDelegate().getCurrentSynchroNumber();
00086   } 
00087 
00088   public void deleteSyncNumber(SynchroNumber ns) throws DatabaseException {
00089         this.getDelegate().deleteSyncNumber(ns);
00090   }
00091 
00092   public void createSynchroNumber(long ns, long timestamp)  throws DatabaseException  {
00093         this.getDelegate().createSynchroNumber(ns, timestamp);
00094   }
00095   
00099   public void setTimeStampForSynchroNumber(long syncNumber)      throws SyncNumberNotFoundException {
00100         this.getDelegate().setTimeStampForSynchroNumber(syncNumber);
00101   }
00102   
00106   public long getTimeStampForSynchroNumber(long syncNumber)  throws SyncNumberNotFoundException {
00107         return this.getDelegate().getTimeStampForSynchroNumber(syncNumber);
00108   }
00109 
00110 }

Generated on Mon Dec 4 11:03:30 2006 for OpenMobileIS by  doxygen 1.5.1-p1