|
|
/*
|
|
|
* 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.
|
|
|
*/
|
|
|
|
|
|
// 声明一个名为Node的抽象类,位于net.micode.notes.gtask.data包中
|
|
|
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; // 是否已删除
|
|
|
|
|
|
// Node类的构造方法
|
|
|
public Node() {
|
|
|
mGid = null; // 初始化mGid为null
|
|
|
mName = ""; // 初始化mName为空字符串
|
|
|
mLastModified = 0; // 初始化mLastModified为0
|
|
|
mDeleted = false; // 初始化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();
|
|
|
|
|
|
// 抽象方法,用于根据Cursor对象获取同步操作类型
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
} |