/* * 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 android.util.Log; import net.micode.notes.tool.GTaskStringUtils; import org.json.JSONException; import org.json.JSONObject; /** *
任务元数据管理类,用于存储Google任务的元数据信息。
*核心职责:
*设计意图:
*关键关联:
*日志标签。
*业务含义:用于在日志中标识MetaData类的相关操作。
*/ private final static String TAG = MetaData.class.getSimpleName(); /** *关联的Google任务ID。
*业务含义:存储与当前元数据相关联的Google任务的唯一标识符。
*约束条件:仅通过{@link #setContentByRemoteJSON(JSONObject)}方法从远程JSON数据中获取。
*/ private String mRelatedGid = null; /** *设置任务元数据信息。
*业务逻辑:
*异常处理:
*获取关联的Google任务ID。
*业务含义:返回与当前元数据相关联的Google任务的唯一标识符。
* * @return 关联的Google任务ID,如果不存在则返回null */ public String getRelatedGid() { return mRelatedGid; } /** *判断元数据是否值得保存。
*业务逻辑:如果元数据的notes字段不为null,则认为值得保存。
* * @return 如果元数据值得保存则返回true,否则返回false */ @Override public boolean isWorthSaving() { return getNotes() != null; } /** *根据远程JSON数据设置元数据内容。
*业务逻辑:
*异常处理:
*根据本地JSON数据设置元数据内容。
*业务逻辑:此方法不应被调用,直接抛出IllegalAccessError异常。
*注意:MetaData类不支持从本地JSON数据设置内容。
* * @param js 本地JSON数据对象 * @throws IllegalAccessError 总是抛出此异常,因为该方法不应被调用 */ @Override public void setContentByLocalJSON(JSONObject js) { // this function should not be called throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called"); } /** *从元数据内容获取本地JSON对象。
*业务逻辑:此方法不应被调用,直接抛出IllegalAccessError异常。
*注意:MetaData类不支持获取本地JSON数据。
* * @return 本地JSON数据对象 * @throws IllegalAccessError 总是抛出此异常,因为该方法不应被调用 */ @Override public JSONObject getLocalJSONFromContent() { throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called"); } /** *获取元数据的同步操作类型。
*业务逻辑:此方法不应被调用,直接抛出IllegalAccessError异常。
*注意:MetaData类不支持获取同步操作类型。
* * @param c 数据库游标对象 * @return 同步操作类型 * @throws IllegalAccessError 总是抛出此异常,因为该方法不应被调用 */ @Override public int getSyncAction(Cursor c) { throw new IllegalAccessError("MetaData:getSyncAction should not be called"); } }