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.
sjb_gitpractice/src/net/micode/notes/gtask/data/Node.java

115 lines
3.3 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)
*
* 根据Apache License 2.0授权 (http://www.apache.org/licenses/LICENSE-2.0)
*/
package net.micode.notes.gtask.data;
import android.database.Cursor;
import org.json.JSONObject;
/**
* 抽象节点类用于表示GTask中的基础数据节点
* 提供同步操作类型定义和基础节点属性管理
*/
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; // 节点全局IDGoogle Task ID
private String mName; // 节点名称
private long mLastModified; // 最后修改时间戳
private boolean mDeleted; // 删除标记
/**
* 构造函数,初始化节点属性
*/
public Node() {
mGid = null;
mName = "";
mLastModified = 0;
mDeleted = false;
}
/**
* 抽象方法 - 获取创建操作的JSON对象
* @param actionId 操作ID
* @return 包含创建操作的JSON对象
*/
public abstract JSONObject getCreateAction(int actionId);
/**
* 抽象方法 - 获取更新操作的JSON对象
* @param actionId 操作ID
* @return 包含更新操作的JSON对象
*/
public abstract JSONObject getUpdateAction(int actionId);
/**
* 抽象方法 - 从远程JSON数据设置节点内容
* @param js 远程JSON数据
*/
public abstract void setContentByRemoteJSON(JSONObject js);
/**
* 抽象方法 - 从本地JSON数据设置节点内容
* @param js 本地JSON数据
*/
public abstract void setContentByLocalJSON(JSONObject js);
/**
* 抽象方法 - 从节点内容生成本地JSON对象
* @return 包含节点内容的JSON对象
*/
public abstract JSONObject getLocalJSONFromContent();
/**
* 抽象方法 - 根据数据库游标获取同步操作类型
* @param c 数据库游标
* @return 同步操作类型
*/
public abstract int getSyncAction(Cursor c);
// 以下是基础属性的getter和setter方法
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;
}
}