📄 client.java
字号:
/*
* @(#)$RCSfile: Client.java,v $ $Revision: 1.2 $
*
* ====================================================================
* Copyright 2001, Reaxion Corp.,
* 11418 105th PL NE, Kirkland, WA, 98033, USA
* All rights reserved.
* ====================================================================
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Tequila SyncML.
*
* The Initial Developer of the Original Code is Reaxion Corp.
* All Rights Reserved.
*/
package com.reaxion.tequila.client.syncml;
import java.util.*;
import com.reaxion.tequila.syncml.sync.*;
import com.reaxion.tequila.syncml.util.*;
import com.reaxion.tequila.client.syncml.sync.*;
/**
* SyncML client main class
*
* @version $1.0$
* @author Oleg A. Oksyuk
*/
public class Client implements IClient {
//The list of all documents on the client that could be syncronized with server
// key - String (sync document DB name)
// value - XMLSyncClientDocumentImpl (XML document to Sync)
private Hashtable dbs = new Hashtable();
private ISyncServer syncServer;
private String serverUri;
private String clientUri;
private SyncIterator syncIterator;
/**
* @param dbNames the list of database names where XML docs that could be
* synchronized are stored
* @param aSyncServer the instance client.comm.CommSyncmlClient
* @param aServerUri a server URI
* @param aClientUri a client URI
* @param aDocPath root path where XML docs on the client are stored
*/
public Client(Enumeration dbNames, ISyncServer aSyncServer,
String aServerUri, String aClientUri) {
String dbName;
XMLSyncClientDocument document;
syncServer = aSyncServer;
serverUri = aServerUri;
clientUri = aClientUri;
syncIterator = new SyncIterator();
while (dbNames.hasMoreElements()) {
dbName = (String) dbNames.nextElement();
document = new XMLSyncClientDocument(dbName);
dbs.put(dbName, document);
}
}
public IXMLSyncDocument getDocument(String dbName) {
return (IXMLSyncDocument) dbs.get(dbName);
}
public Enumeration getDocNames() {
return dbs.keys();
}
public void performSync() {
Log.println("Client.performSync()");
performSync(dbs.keys());
}
public void performSync(String dbName) {
Log.println("Client.performSync("+dbName+")");
Vector dbNames = new Vector();
dbNames.addElement(dbName);
performSync(dbNames.elements());
}
public void performSync(Enumeration dbNames) {
Log.println("Client.performSync:");
String dbName;
Vector docsToSync = new Vector();
IXMLSyncDocument doc;
while (dbNames.hasMoreElements()) {
dbName = (String) dbNames.nextElement();
Log.println(" dbName:"+dbName);
doc = getDocument(dbName);
if (null == doc) {
doc = new XMLSyncClientDocument(dbName);
dbs.put(dbName, doc);
}
docsToSync.addElement(doc);
}
ClientSession session = new ClientSession(syncIterator.generateNewId(),
syncServer, serverUri, clientUri);
session.performSync(docsToSync.elements());
}
}
/* -----------------------------------------------------------------------------
* Change log:
* -----------------------------------------------------------------------------
* $Log: Client.java,v $
* Revision 1.2 2001/10/17 15:27:41 OlegO
* changed comments for better javadoc
*
* Revision 1.1.1.1 2001/10/11 13:13:32 OlegO
* no message
*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -