|
|
/*
|
|
|
* 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() {
|
|
|
mGid = null;
|
|
|
mName = "";
|
|
|
mLastModified = 0;
|
|
|
mDeleted = false;
|
|
|
}
|
|
|
|
|
|
// 抽象方法,用于获取创建节点的操作信息,以JSON对象形式返回,具体实现由子类提供
|
|
|
public abstract JSONObject getCreateAction(int actionId);
|
|
|
|
|
|
// 抽象方法,用于获取更新节点的操作信息,以JSON对象形式返回,具体实现由子类提供
|
|
|
public abstract JSONObject getUpdateAction(int actionId);
|
|
|
|
|
|
// 抽象方法,根据远程JSON数据设置节点的内容,具体实现由子类提供
|
|
|
public abstract void setContentByRemoteJSON(JSONObject js);
|
|
|
|
|
|
// 抽象方法,根据本地JSON数据设置节点的内容,具体实现由子类提供
|
|
|
public abstract void setContentByLocalJSON(JSONObject js);
|
|
|
|
|
|
// 抽象方法,从节点内容获取本地JSON数据,具体实现由子类提供
|
|
|
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;
|
|
|
}
|
|
|
} |