|
|
/*
|
|
|
* 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;
|
|
|
//定义了各种用于表征同步状态的常量,需要操作标识
|
|
|
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;//bool类型,表明表征是否被删除
|
|
|
|
|
|
private long mLastModified;
|
|
|
|
|
|
private boolean mDeleted;
|
|
|
|
|
|
public Node() {//构造函数,进行初始化,界面没有,名字为空,最后一次修改时间为0(没有修改),表征是否删除。
|
|
|
mGid = null;
|
|
|
mName = "";
|
|
|
mLastModified = 0;
|
|
|
mDeleted = false;
|
|
|
}
|
|
|
//函数:定义为一个抽象的函数,在TaskList子类中得到了实现
|
|
|
public abstract JSONObject getCreateAction(int actionId);
|
|
|
//主要功能:声明JSONObject对象抽象类,获取初始行为,参数为GTASK_JSON_ACTION_ID
|
|
|
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;
|
|
|
}
|
|
|
//行到底部,都是一些赋值和返回值函数,即对构造函数中的对象进行赋值或者获取对象的具体内容。
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
public String getName() {
|
|
|
return this.mName;
|
|
|
}
|
|
|
|
|
|
public long getLastModified() {
|
|
|
return this.mLastModified;
|
|
|
}
|
|
|
|
|
|
public boolean getDeleted() {
|
|
|
return this.mDeleted;
|
|
|
}
|
|
|
//获取删除标识
|
|
|
}
|