// Path: src/edu/mit/mobile/android/locast/data/JsonSyncableItem.java
// public static abstract class SyncItem {
// 
// 	protected final String remoteKey;
// 	public static final int SYNC_BOTH = 0x3,
// 							SYNC_TO   = 0x1,
// 							SYNC_FROM = 0x2,
// 							SYNC_NONE = 0x4,
// 							FLAG_OPTIONAL = 0x10;
// 
// 	private static final int DEFAULT_SYNC_DIRECTION = SYNC_BOTH;
// 
// 	private final int flags;
// 
// 	public SyncItem(String remoteKey) {
// 		this(remoteKey, DEFAULT_SYNC_DIRECTION);
// 	}
// 	public SyncItem(String remoteKey, int flags){
// 		this.remoteKey = remoteKey;
// 		this.flags = flags;
// 	}
// 	public String getRemoteKey(){
// 		return remoteKey;
// 	}
// 	/**
// 	 * @return SYNC_BOTH, SYNC_NONE, SYNC_TO, or SYNC_FROM
// 	 */
// 	public int getDirection() {
// 		final int directionFlags = flags & 0x3;
// 
// 		if ((flags & SYNC_NONE) != 0){
// 			return SYNC_NONE;
// 		}
// 
// 		if (directionFlags == 0){
// 			return DEFAULT_SYNC_DIRECTION;
// 		}
// 
// 		return directionFlags;
// 	}
// 
// 	public boolean isDirection(int syncDirection){
// 		return (getDirection() & syncDirection) != 0;
// 	}
// 
// 	public boolean isOptional() {
// 		return (flags & FLAG_OPTIONAL) != 0;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		final StringBuilder sb = new StringBuilder();
// 		sb.append('"');
// 		sb.append(remoteKey);
// 		sb.append('"');
// 
// 		sb.append("; direction: ");
// 		switch (getDirection()){
// 		case SYNC_BOTH:
// 			sb.append("SYNC_BOTH");
// 			break;
// 		case SYNC_FROM:
// 			sb.append("SYNC_FROM");
// 			break;
// 		case SYNC_TO:
// 			sb.append("SYNC_TO");
// 			break;
// 		case SYNC_NONE:
// 			sb.append("SYNC_NONE");
// 			break;
// 		}
// 		sb.append(isOptional() ? "; optional ": "; not optional ");
// 		sb.append(String.format("(flags %x)", flags));
// 		return sb.toString();
// 	}
// 
// 	/**
// 	 * Translate a local database entry into JSON.
// 	 * @param context Android context
// 	 * @param localItem uri of the local item
// 	 * @param c cursor pointing to the item
// 	 * @param lProp the local property where the data should be stored in the CV
// 	 * @return JSONObject, JSONArray or any other type that JSONObject.put() supports.
// 	 * @throws JSONException
// 	 * @throws NetworkProtocolException
// 	 * @throws IOException
// 	 */
// 	public abstract Object toJSON(Context context, Uri localItem, Cursor c, String lProp) throws JSONException, NetworkProtocolException, IOException;
// 	/**
// 	 * @param context Android context
// 	 * @param localItem uri of the local item or null if it is new
// 	 * @param item the JSONObject of the item. It's your job to pull out the desired field(s) here.
// 	 * @param lProp the local property where the data should be stored in the CV
// 	 * @return a new ContentValues, that will be merged into the new ContentValues object
// 	 * @throws JSONException
// 	 * @throws NetworkProtocolException
// 	 * @throws IOException
// 	 */
// 	public abstract ContentValues fromJSON(Context context, Uri localItem, JSONObject item, String lProp) throws JSONException, NetworkProtocolException, IOException;
// 
// 	public void onPostSyncItem(Context context, Uri uri, JSONObject item, boolean updated)
// 		throws SyncException, IOException {}
// 
// }


import java.io.IOException;
import java.util.HashMap;
import org.json.JSONObject;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import edu.mit.mobile.android.locast.data.JsonSyncableItem.SyncItem;
package edu.mit.mobile.android.locast.data;
/*
 * Copyright (C) 2011  MIT Mobile Experience Lab
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */




public class SyncMap extends HashMap<String, SyncItem> {
	/**
	 *
	 */
	private static final long serialVersionUID = 4817034517893809747L;

	public SyncMap() {

	}

	public SyncMap(SyncMap syncMap) {
		super(syncMap);
	}

	/**
	 * Called just before an item is sync'd.
	 * @param c Cursor pointing to the given item.
	 *
	 * @throws SyncException
	 */
	public void onPreSyncItem(ContentResolver cr, Uri uri, Cursor c) throws SyncException {}

	/**
	 * Hook called after an item has been synchronized on the server. Called each time the sync request is made.
	 * Make sure to call through when subclassing.
	 * @param uri Local URI pointing to the item.
	 * @param updated true if the item was updated during the sync.
	 * @throws SyncException
	 * @throws IOException
	 */
	public void onPostSyncItem(Context context, Uri uri, JSONObject item, boolean updated) throws SyncException, IOException {
// Path: src/edu/mit/mobile/android/locast/data/JsonSyncableItem.java
// public static abstract class SyncItem {
// 
// 	protected final String remoteKey;
// 	public static final int SYNC_BOTH = 0x3,
// 							SYNC_TO   = 0x1,
// 							SYNC_FROM = 0x2,
// 							SYNC_NONE = 0x4,
// 							FLAG_OPTIONAL = 0x10;
// 
// 	private static final int DEFAULT_SYNC_DIRECTION = SYNC_BOTH;
// 
// 	private final int flags;
// 
// 	public SyncItem(String remoteKey) {
// 		this(remoteKey, DEFAULT_SYNC_DIRECTION);
// 	}
// 	public SyncItem(String remoteKey, int flags){
// 		this.remoteKey = remoteKey;
// 		this.flags = flags;
// 	}
// 	public String getRemoteKey(){
// 		return remoteKey;
// 	}
// 	/**
// 	 * @return SYNC_BOTH, SYNC_NONE, SYNC_TO, or SYNC_FROM
// 	 */
// 	public int getDirection() {
// 		final int directionFlags = flags & 0x3;
// 
// 		if ((flags & SYNC_NONE) != 0){
// 			return SYNC_NONE;
// 		}
// 
// 		if (directionFlags == 0){
// 			return DEFAULT_SYNC_DIRECTION;
// 		}
// 
// 		return directionFlags;
// 	}
// 
// 	public boolean isDirection(int syncDirection){
// 		return (getDirection() & syncDirection) != 0;
// 	}
// 
// 	public boolean isOptional() {
// 		return (flags & FLAG_OPTIONAL) != 0;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		final StringBuilder sb = new StringBuilder();
// 		sb.append('"');
// 		sb.append(remoteKey);
// 		sb.append('"');
// 
// 		sb.append("; direction: ");
// 		switch (getDirection()){
// 		case SYNC_BOTH:
// 			sb.append("SYNC_BOTH");
// 			break;
// 		case SYNC_FROM:
// 			sb.append("SYNC_FROM");
// 			break;
// 		case SYNC_TO:
// 			sb.append("SYNC_TO");
// 			break;
// 		case SYNC_NONE:
// 			sb.append("SYNC_NONE");
// 			break;
// 		}
// 		sb.append(isOptional() ? "; optional ": "; not optional ");
// 		sb.append(String.format("(flags %x)", flags));
// 		return sb.toString();
// 	}
// 
// 	/**
// 	 * Translate a local database entry into JSON.
// 	 * @param context Android context
// 	 * @param localItem uri of the local item
// 	 * @param c cursor pointing to the item
// 	 * @param lProp the local property where the data should be stored in the CV
// 	 * @return JSONObject, JSONArray or any other type that JSONObject.put() supports.
// 	 * @throws JSONException
// 	 * @throws NetworkProtocolException
// 	 * @throws IOException
// 	 */
// 	public abstract Object toJSON(Context context, Uri localItem, Cursor c, String lProp) throws JSONException, NetworkProtocolException, IOException;
// 	/**
// 	 * @param context Android context
// 	 * @param localItem uri of the local item or null if it is new
// 	 * @param item the JSONObject of the item. It's your job to pull out the desired field(s) here.
// 	 * @param lProp the local property where the data should be stored in the CV
// 	 * @return a new ContentValues, that will be merged into the new ContentValues object
// 	 * @throws JSONException
// 	 * @throws NetworkProtocolException
// 	 * @throws IOException
// 	 */
// 	public abstract ContentValues fromJSON(Context context, Uri localItem, JSONObject item, String lProp) throws JSONException, NetworkProtocolException, IOException;
// 
// 	public void onPostSyncItem(Context context, Uri uri, JSONObject item, boolean updated)
// 		throws SyncException, IOException {}
// 
// }


// Path: src/edu/mit/mobile/android/locast/data/SyncMap.java
import java.io.IOException;
import java.util.HashMap;
import org.json.JSONObject;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import edu.mit.mobile.android.locast.data.JsonSyncableItem.SyncItem;

package edu.mit.mobile.android.locast.data;
/*
 * Copyright (C) 2011  MIT Mobile Experience Lab
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */




public class SyncMap extends HashMap<String, SyncItem> {
	/**
	 *
	 */
	private static final long serialVersionUID = 4817034517893809747L;

	public SyncMap() {

	}

	public SyncMap(SyncMap syncMap) {
		super(syncMap);
	}

	/**
	 * Called just before an item is sync'd.
	 * @param c Cursor pointing to the given item.
	 *
	 * @throws SyncException
	 */
	public void onPreSyncItem(ContentResolver cr, Uri uri, Cursor c) throws SyncException {}

	/**
	 * Hook called after an item has been synchronized on the server. Called each time the sync request is made.
	 * Make sure to call through when subclassing.
	 * @param uri Local URI pointing to the item.
	 * @param updated true if the item was updated during the sync.
	 * @throws SyncException
	 * @throws IOException
	 */
	public void onPostSyncItem(Context context, Uri uri, JSONObject item, boolean updated) throws SyncException, IOException {
		for (final SyncItem childItem: this.values()){