From b3ce375f0c0571c606c2d76b4797b977cae4fd81 Mon Sep 17 00:00:00 2001 From: mgqmu5wef <3443803220@qq.com> Date: Wed, 13 Dec 2023 15:21:27 +0800 Subject: [PATCH] ADD file via upload --- Node.java | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Node.java diff --git a/Node.java b/Node.java new file mode 100644 index 0000000..d61e860 --- /dev/null +++ b/Node.java @@ -0,0 +1,90 @@ +package net.micode.notes.gtask.data; + +import android.database.Cursor; + +import org.json.JSONObject; + +/** + * 应该是同步操作的基础数据类型,定义了相关指示同步操作的常量 + * 关键字:abstract + */ +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; + } + + 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; + } + + 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; + } + +} \ No newline at end of file