You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
java/data/Node.java

105 lines
3.2 KiB

/*
* 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 org.json.JSONObject;
import android.database.Cursor;
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;// 同步出现错误
// 定义了Node类中的私有字段
private String mGid; // 唯一标识符
private String mName; // 名称
private long mLastModified; // 最后一次修改时间
private boolean mDeleted; // 是否删除
public Node() {
mGid = null;
mName = "";
mLastModified = 0;
mDeleted = false;
}// 初始化
public abstract JSONObject getCreateAction(int actionId); // 根据给定的 actionId 返回一个 JSON 对象,表示创建操作
public abstract JSONObject getUpdateAction(int actionId); // 根据给定的 actionId 返回一个 JSON 对象,表示更新操作
public abstract void setContentByRemoteJSON(JSONObject js); // 根据远程的 JSON 对象设置内容
public abstract void setContentByLocalJSON(JSONObject js); // 根据本地的 JSON 对象设置内容
public abstract JSONObject getLocalJSONFromContent(); // 返回一个 JSON 对象,表示从当前内容中获取本地 JSON 数据
public abstract int getSyncAction(Cursor c); // 根据给定的 Cursor 返回一个 JSON 对象,表示同步操作
// 设置相关信息
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;
}
}