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.
git-xiaomibianqian/lhy/Node.java

102 lines
3.2 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 {//同步操作的基础数据类型,定义了相关指示同步操作的常量
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;//记录最后一次修改时间
private String mName;//记录是否被删除
private long mLastModified;//记录最后一次修改时间
private boolean mDeleted;
public Node() {//构造函数进行初始化界面没有名字为空最后一次修改时间为0没有修改表征是否删除。
mGid = null;
mName = "";
mLastModified = 0;
mDeleted = false;
}
public abstract JSONObject getCreateAction(int actionId);//获取创建信息
public abstract JSONObject getUpdateAction(int actionId);//获取需要更新活动的ID
public abstract void setContentByRemoteJSON(JSONObject js);//创建相应的对象,并且实现远端与本地的同步操作
public abstract void setContentByLocalJSON(JSONObject js);//创建相应对象进行本地操作
public abstract JSONObject getLocalJSONFromContent();//声明JSONObject对象抽象类从目录中获取本地JSON
public abstract int getSyncAction(Cursor c);//声明int抽象类获取同步行为代号
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;
}//函数返回mGid
public String getName() {
return this.mName;
}//获取名称
public long getLastModified() {
return this.mLastModified;
}//获取最近创建时间标识
public boolean getDeleted() {
return this.mDeleted;
}//获取删除标识
}