/*
 * 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;//引用cursor，此公用接口提供对数据库查询返回的结果集的随机读写访问

import org.json.JSONObject;//引用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;//记录gid

    private String mName;//记录name

    private long mLastModified;//记录最后行为时间

    private boolean mDeleted;//记录是否被删除

    public Node() {
        mGid = null;
        mName = "";
        mLastModified = 0;
        mDeleted = false;
    }//构造函数

    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();//从内容获取本地JSON对象

    public abstract int getSyncAction(Cursor c);//获取同步行为代号
	//对构造函数中的对象进行赋值或者获取对象的具体内容
    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;
    }

}//抽象类，声明若干基本数据成员，提供给别的类继承使用
