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.
text123/Node_1.java

127 lines
4.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* 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;
// 存储节点对应的Google任务IDgid
private String mGid;
// 存储节点的名称
private String mName;
// 存储节点最后修改的时间戳
private long mLastModified;
// 标记节点是否被删除
private boolean mDeleted;
// 无参构造函数,用于初始化节点的属性
public Node() {
// 初始化Google任务ID为null
mGid = null;
// 初始化节点名称为空字符串
mName = "";
// 初始化最后修改时间为0
mLastModified = 0;
// 初始化删除标记为false
mDeleted = false;
}
// 抽象方法用于获取创建操作的JSON对象不同的子类根据具体需求实现
// actionId表示操作的ID用于区分不同的创建操作场景
public abstract JSONObject getCreateAction(int actionId);
// 抽象方法用于获取更新操作的JSON对象不同的子类根据具体需求实现
// actionId表示操作的ID用于区分不同的更新操作场景
public abstract JSONObject getUpdateAction(int actionId);
// 抽象方法根据从远程获取的JSON数据设置节点内容不同的子类根据具体需求实现
// js是从远程获取的JSON对象包含了要设置的节点内容信息
public abstract void setContentByRemoteJSON(JSONObject js);
// 抽象方法根据本地的JSON数据设置节点内容不同的子类根据具体需求实现
// js是本地的JSON对象包含了要设置的节点内容信息
public abstract void setContentByLocalJSON(JSONObject js);
// 抽象方法从节点内容中获取本地JSON数据不同的子类根据具体需求实现
public abstract JSONObject getLocalJSONFromContent();
// 抽象方法,根据数据库游标获取同步操作类型,不同的子类根据具体需求实现
// c是数据库游标通过它可以获取数据库中的相关数据来确定同步操作类型
public abstract int getSyncAction(Cursor c);
// 设置节点的Google任务IDgid的方法
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;
}
// 获取节点的Google任务IDgid的方法
public String getGid() {
return this.mGid;
}
// 获取节点名称的方法
public String getName() {
return this.mName;
}
// 获取节点最后修改时间的方法
public long getLastModified() {
return this.mLastModified;
}
// 获取节点删除标记的方法
public boolean getDeleted() {
return this.mDeleted;
}
}