|
|
/*
|
|
|
* 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;
|
|
|
|
|
|
public abstract class Node {
|
|
|
public static final int SYNC_ACTION_NONE = 0;//本地和远端都不更新,同步行为代号0//
|
|
|
|
|
|
public static final int SYNC_ACTION_ADD_REMOTE = 1;//=1时在远端接口增加内容//
|
|
|
|
|
|
public static final int SYNC_ACTION_ADD_LOCAL = 2;//=2时需要在本地增加内容//
|
|
|
|
|
|
public static final int SYNC_ACTION_DEL_REMOTE = 3;//=3时需要在远程云端删除内容//
|
|
|
|
|
|
public static final int SYNC_ACTION_DEL_LOCAL = 4;//=4时需要在本地删除内容//
|
|
|
public static final int SYNC_ACTION_UPDATE_REMOTE = 5;//=5时需要将本地内容更新到远程云端//
|
|
|
|
|
|
public static final int SYNC_ACTION_UPDATE_LOCAL = 6;//=6时需要将远程云端内容更新到本地//
|
|
|
|
|
|
public static final int SYNC_ACTION_UPDATE_CONFLICT = 7;//同步出现冲突//
|
|
|
|
|
|
public static final int SYNC_ACTION_ERROR = 8;//同步出现错误//
|
|
|
|
|
|
private String mGid;//记录最后一次修改时间//
|
|
|
|
|
|
private String mName;//bool类型,表明表征是否被删除//
|
|
|
|
|
|
private long mLastModified;//声明long类型,表示记录最后行为时间//
|
|
|
|
|
|
private boolean mDeleted;//判断 表征是否被删除//
|
|
|
|
|
|
public Node() {
|
|
|
mGid = null;
|
|
|
mName = "";
|
|
|
mLastModified = 0;
|
|
|
mDeleted = false;
|
|
|
}/*构造函数,进行初始化,界面没有,名字为空,最后一次修改时间为0(没有修改),表征是否删除。*/
|
|
|
|
|
|
public abstract JSONObject getCreateAction(int actionId);//引用一个抽象的类,下同不再注释//
|
|
|
|
|
|
public abstract JSONObject getUpdateAction(int actionId);
|
|
|
|
|
|
public abstract void setContentByRemoteJSON(JSONObject js);
|
|
|
|
|
|
public abstract void setContentByLocalJSON(JSONObject js);
|
|
|
|
|
|
public abstract JSONObject getLocalJSONFromContent();
|
|
|
|
|
|
public abstract int getSyncAction(Cursor c);
|
|
|
|
|
|
public void setGid(String gid) {
|
|
|
this.mGid = gid;
|
|
|
}//以下几个函数都是对于上面的公共类Node的里的变量进行赋值和修改。//
|
|
|
|
|
|
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;
|
|
|
}//获取删除标识//
|
|
|
|
|
|
}//这里是一个类,用于建立node类来提供模板,设置各种参数及定义各种函数,会在别的地方用到,定义了各种同步活动的标识码。//
|