|
|
/*
|
|
|
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
|
|
*
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
* See the License for the specific language governing permissions and
|
|
|
* limitations under the License.
|
|
|
*/
|
|
|
|
|
|
package net.micode.notes.gtask.data;
|
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
/**
|
|
|
* Node定义了相关指示同步操作的常量,代表不同的同步操作
|
|
|
*/
|
|
|
public abstract class Node {
|
|
|
public static final int SYNC_ACTION_NONE = 0; //无同步动作
|
|
|
|
|
|
public static final int SYNC_ACTION_ADD_REMOTE = 1; //远程添加同步
|
|
|
|
|
|
public static final int SYNC_ACTION_ADD_LOCAL = 2; //本地添加同步
|
|
|
|
|
|
public static final int SYNC_ACTION_DEL_REMOTE = 3; //远程删除同步
|
|
|
|
|
|
public static final int SYNC_ACTION_DEL_LOCAL = 4; //本地删除同步
|
|
|
|
|
|
public static final int SYNC_ACTION_UPDATE_REMOTE = 5; //远程跟新同步
|
|
|
|
|
|
public static final int SYNC_ACTION_UPDATE_LOCAL = 6; //本地更新同步
|
|
|
|
|
|
public static final int SYNC_ACTION_UPDATE_CONFLICT = 7; //跟新冲突同步
|
|
|
|
|
|
public static final int SYNC_ACTION_ERROR = 8; //同步错误
|
|
|
|
|
|
private String mGid;
|
|
|
|
|
|
private String mName;
|
|
|
|
|
|
private long mLastModified; //上次修改时间
|
|
|
|
|
|
private boolean mDeleted; //是否删除
|
|
|
|
|
|
public Node() { //初始化node
|
|
|
mGid = null;
|
|
|
mName = "";
|
|
|
mLastModified = 0;
|
|
|
mDeleted = false;
|
|
|
}
|
|
|
//方法jsonobject
|
|
|
public abstract JSONObject getCreateAction(int actionId); //返回创建动作
|
|
|
|
|
|
public abstract JSONObject getUpdateAction(int actionId); //返回更新动作
|
|
|
|
|
|
public abstract void setContentByRemoteJSON(JSONObject js); //远端设置目录
|
|
|
|
|
|
public abstract void setContentByLocalJSON(JSONObject js); //本地json设置目录
|
|
|
|
|
|
public abstract JSONObject getLocalJSONFromContent(); //从目录得到本地json消息
|
|
|
|
|
|
public abstract int getSyncAction(Cursor c); //用cursor得到同步动作
|
|
|
|
|
|
public void setGid(String gid) {
|
|
|
this.mGid = gid;
|
|
|
} //设置Gid
|
|
|
|
|
|
public void setName(String name) {
|
|
|
this.mName = name;
|
|
|
} //设置名字
|
|
|
|
|
|
public void setLastModified(long lastModified) {
|
|
|
this.mLastModified = lastModified; } //设置最后的调整
|
|
|
|
|
|
public void setDeleted(boolean deleted) {
|
|
|
this.mDeleted = deleted;
|
|
|
} //设置删除标志
|
|
|
|
|
|
public String getGid() {
|
|
|
return this.mGid;
|
|
|
} //得到Gid
|
|
|
|
|
|
public String getName() {
|
|
|
return this.mName;
|
|
|
} //得到名字
|
|
|
|
|
|
public long getLastModified() {
|
|
|
return this.mLastModified;
|
|
|
} //得到最后调整时间
|
|
|
|
|
|
public boolean getDeleted() {
|
|
|
return this.mDeleted;
|
|
|
} //得到删除标志
|
|
|
|
|
|
}
|