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.

66 lines
2.8 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;
public abstract class Node {
// 同步动作常量定义9种同步操作类型
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 Tasks ID或全局唯一标识
private String mName; // 节点名称
private long mLastModified; // 最后修改时间
private boolean mDeleted; // 删除状态
// 构造函数:初始化属性默认值
public Node() {
mGid = null;
mName = "";
mLastModified = 0;
mDeleted = false;
}
// 抽象方法:由子类实现具体逻辑
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(); // 从内容生成本地JSON
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 mGid; }
public String getName() { return mName; }
public long getLastModified() { return mLastModified; }
public boolean getDeleted() { return mDeleted; }
}