diff --git a/Node.txt b/Node.txt new file mode 100644 index 0000000..4a2683b --- /dev/null +++ b/Node.txt @@ -0,0 +1,158 @@ +/* + * 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 类是一个抽象类,用于表示 Google Task 中的节点。 + * 该类定义了节点的基本属性和操作,并提供了抽象方法供子类实现。 + */ +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; // Google Task 的 ID + + private String mName; // 节点名称 + + private long mLastModified; // 最后修改时间 + + private boolean mDeleted; // 是否已删除 +/* + * 构造函数,初始化节点属性。 + */ + public Node() { + mGid = null; + mName = ""; + mLastModified = 0; + mDeleted = false; + } +/* + * 获取创建操作的 JSON 对象。 + * 该方法用于生成创建操作的 JSON 对象。 + * @param actionId 操作 ID。 + * @return 返回创建操作的 JSON 对象。 + */ + public abstract JSONObject getCreateAction(int actionId); +/* + * 获取更新操作的 JSON 对象。 + * 该方法用于生成更新操作的 JSON 对象。 + * @param actionId 操作 ID。 + * @return 返回更新操作的 JSON 对象。 + */ + public abstract JSONObject getUpdateAction(int actionId); +/* + * 根据远程 JSON 对象设置节点内容。 + * 该方法用于从远程 JSON 对象中提取节点内容。 + * @param js 远程 JSON 对象。 + */ + public abstract void setContentByRemoteJSON(JSONObject js); +/* + * 根据本地 JSON 对象设置节点内容。 + * 该方法用于从本地 JSON 对象中提取节点内容。 + * @param js 本地 JSON 对象。 + */ + public abstract void setContentByLocalJSON(JSONObject js); +/* + *从节点内容中获取本地 JSON 对象。 + * 该方法用于将节点内容转换为本地 JSON 对象。 + * @return 返回本地 JSON 对象。 + */ + public abstract JSONObject getLocalJSONFromContent(); +/* + * 获取同步操作。 + * 该方法用于根据数据库游标获取同步操作。 + * @param c 数据库游标。 + * @return 返回同步操作。 + */ + public abstract int getSyncAction(Cursor c); +/* + * 设置 Google Task 的 ID。 + * @param gid Google Task 的 ID。 + */ + public void setGid(String gid) { + this.mGid = gid; + } +/* + * 设置节点名称。 + * @param name 节点名称。 + */ + public void setName(String name) { + this.mName = name; + } +/* + * 设置最后修改时间。 + * @param lastModified 最后修改时间。 + */ + public void setLastModified(long lastModified) { + this.mLastModified = lastModified; + } +/* + * 设置节点是否已删除。 + * @param deleted 是否已删除。 + */ + public void setDeleted(boolean deleted) { + this.mDeleted = deleted; + } +/* + * 获取 Google Task 的 ID + * @return 返回 Google Task 的 ID。 + */ + public String getGid() { + return this.mGid; + } +/* + * 获取节点名称。 + * @return 返回节点名称。 + */ + public String getName() { + return this.mName; + } +/* + * 获取最后修改时间。 + * @return 返回最后修改时间。 + */ + public long getLastModified() { + return this.mLastModified; + } +/* + * 获取节点是否已删除。 + * @return 返回节点是否已删除。 + */ + public boolean getDeleted() { + return this.mDeleted; + } + +}