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.
xiaomi-Notes/Node.java

138 lines
5.1 KiB

3 months ago
/*
* 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;
public abstract class Node {
//// 定义同步操作常量,表示不同的同步动作
//这段代码定义了不同的常量,表示不同的同步操作类型。这些常量用于表示与远程和本地数据同步的动作。每个动作都用一个整数值标识,
// 例如SYNC_ACTION_ADD_REMOTE 表示添加远程任务,
// SYNC_ACTION_UPDATE_LOCAL 表示更新本地任务,
// SYNC_ACTION_ERROR 表示同步错误等。
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;
//mGid一个字符串存储任务的唯一标识符Google ID用于区分不同的任务。
//mName任务的名称存储任务的标题或名称。
//mLastModified任务的最后修改时间使用 long 类型(通常是 Unix 时间戳表示自1970年1月1日以来的毫秒数
//mDeleted布尔值表示该任务是否被删除。
// 任务的唯一标识符
private String mGid;
// 任务的名称
private String mName;
// 最后修改时间
private long mLastModified;
// 任务是否已删除
private boolean mDeleted;
public Node() {
// 默认构造函数,初始化 mGid 为 null
mGid = null;
// 默认构造函数,初始化 mName 为空字符串
mName = "";
// 默认构造函数,初始化 mLastModified 为 0
mLastModified = 0;
// 默认构造函数,初始化 mDeleted 为 false表示任务未删除
mDeleted = false;
}
//getCreateAction(int actionId):根据给定的 actionId返回一个 JSONObject表示创建操作的同步动作。具体内容依赖子类实现。
//getUpdateAction(int actionId):根据给定的 actionId返回一个 JSONObject表示更新操作的同步动作。具体内容依赖子类实现。
//setContentByRemoteJSON(JSONObject js):从远程的 JSON 数据中设置内容。js 是传入的 JSONObject该方法的具体实现依赖子类。
//setContentByLocalJSON(JSONObject js):从本地的 JSON 数据中设置内容。js 是传入的 JSONObject该方法的具体实现依赖子类。
//getLocalJSONFromContent():将本地内容转换为 JSONObject返回一个 JSON 对象。
//getSyncAction(Cursor c):从 Cursor 对象中获取同步操作的动作,返回一个整数,表示当前同步操作的类型。
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);
//这些是 Node 类的 setter 方法,用于设置成员变量的值:
//setGid(String gid):设置任务的 GidGoogle ID
//setName(String name):设置任务的名称。
//setLastModified(long lastModified):设置任务的最后修改时间。
//setDeleted(boolean deleted):设置任务是否被删除。
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;
}
//这些是 Node 类的 getter 方法,用于获取成员变量的值:
//getGid():返回任务的 GidGoogle ID
//getName():返回任务的名称。
//getLastModified():返回任务的最后修改时间。
//getDeleted():返回任务是否已删除的布尔值。
public String getGid() {
return this.mGid;
}
public String getName() {
return this.mName;
}
public long getLastModified() {
return this.mLastModified;
}
public boolean getDeleted() {
return this.mDeleted;
}
}