From 3bec210895b3c304395e4c7a2a25112fa99d643b Mon Sep 17 00:00:00 2001 From: FXH <230007021@qq.com> Date: Tue, 8 Oct 2024 12:39:25 +0800 Subject: [PATCH] =?UTF-8?q?Node=E7=B1=BB=E6=98=AF=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E7=9A=84=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E7=94=A8=E4=BA=8E=E8=A1=A8=E7=A4=BA=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=88=96=E8=8A=82=E7=82=B9=EF=BC=8C=E5=B9=B6=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E7=B3=BB=E5=88=97=E5=90=8C=E6=AD=A5=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=92=8C=E6=88=90=E5=91=98=E5=8F=98=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=BA=94=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=92=8C=E8=8E=B7=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Node.java | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Node.java diff --git a/Node.java b/Node.java new file mode 100644 index 0000000..d172ec6 --- /dev/null +++ b/Node.java @@ -0,0 +1,110 @@ +// 多行注释,说明版权信息和许可证 +/* + * 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; // 初始时,最后修改时间为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; + } + +} \ No newline at end of file