/*
 * 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.
 */

//Node类是一个抽象类，用于记录笔记的基本信息
package net.micode.notes.gtask.data;

import android.database.Cursor;

import org.json.JSONObject;

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任务ID

    private String mName;//笔记名称

    private long mLastModified;//上次修改时间

    private boolean mDeleted;//是否已删除

    //构造函数，初始化笔记的基本信息
    public Node() {
        mGid = null;
        mName = "";
        mLastModified = 0;
        mDeleted = false;
    }

    //抽象方法，子类需要实现以下方法
    //获取创建操作的JSON对象
    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();

    //获取同步操作
    public abstract int getSyncAction(Cursor c);

    //设置Google任务ID
    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任务ID
    public String getGid() {
        return this.mGid;
    }

    //获取笔记名称
    public String getName() {
        return this.mName;
    }

    //获取上次修改时间
    public long getLastModified() {
        return this.mLastModified;
    }

    //判断是否已删除
    public boolean getDeleted() {
        return this.mDeleted;
    }

}
