// Path: app/src/main/java/com/ubiqlog/vis/utils/JsonEncodeDecode.java
// public class JsonEncodeDecode 
// {
// 	public static String EncodeBluetooth(String deviceName, String deviceAddress, String bindState, Date timeStamp) 
// 	{
// 		StringBuilder encodedString = new StringBuilder("");
// 		encodedString = encodedString.append("{\"Bluetooth\":{\"name\":\""
// 				+ deviceName
// 				+ "\",\"address\":\""
// 				+ deviceAddress
// 				+ "\",\"bond status\":\""
// 				+ bindState
// 				+ "\",\"time\":\""
// 				+ DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(timeStamp) 
// 				+ "\"}}");
// 
// 		return encodedString.toString();
// 	}
// 
// 	public static String[] DecodeBluetooth(String jsonString) 
// 	{
// 		String[] split = jsonString.split("\"");
// 
// 		String[] decodedString = new String[4];
// 
// 		decodedString[0] = split[5];
// 		decodedString[1] = split[9];
// 		decodedString[2] = split[13];
// 		decodedString[3] = split[17];
// 
// 		return decodedString;
// 	}
// 
// 	public static String EncodeMovement(Date timestampStart, Date timestampEnd, Movement movementState) 
// 	{
// 		StringBuilder encodedString = new StringBuilder("");
// 		encodedString = encodedString.append("{\"Movement\":{\"start\":\""
// 				+ DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(timestampStart)
// 				+ "\",\"end\":\""
// 				+  DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(timestampEnd)
// 				+ "\",\"state\":\""
// 				+ movementState
// 				+ "\"}}");
// 
// 		return encodedString.toString();
// 	}
// 	
// 	public static String[] DecodeMovement(String jsonString) 
// 	{
// 		String[] split = jsonString.split("\"");
// 
// 		String[] decodedString = new String[3];
// 
// 		decodedString[0] = split[5];
// 		decodedString[1] = split[9];
// 		decodedString[2] = split[13];
// 
// 		return decodedString;
// 	}
// }
// 
// Path: app/src/main/java/com/ubiqlog/vis/utils/SensorState.java
// public class SensorState 
// {
// 	public static enum Bluetooth 
// 	{
// 		NONE("none"),
// 		BONDING("bonding"),
// 		BONDED("bonded");
// 		
// 		private String state;
// 		
// 		Bluetooth(String state)
// 		{
// 			this.state = state;
// 		}
// 		
// 		public String getState()
// 		{
// 			return state;
// 		}
// 	}
// 	
// 	public static enum Movement 
// 	{
// 		FAST("fast"),
// 		SLOW("slow"),
// 		STEADY("steady");
// 		
// 		private String state;
// 		
// 		Movement(String state)
// 		{
// 			this.state = state;
// 		}
// 		
// 		public String getState()
// 		{
// 			return state;
// 		}
// 	}
// }


import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;
import com.ubiqlog.vis.utils.JsonEncodeDecode;
import com.ubiqlog.vis.utils.SensorState;
				endEventCalendar.setTime(df.parse(timestampEnd));
				
				if (startEventCalendar.before(dateLow) && endEventCalendar.after(dateLow))
				{
					startEventCalendar.setTime(dateLow.getTime());
				}
				
				if (startEventCalendar.before(dateHigh) && endEventCalendar.after(dateHigh))
				{
					endEventCalendar.setTime(dateHigh.getTime());
				}

				if ((startEventCalendar.compareTo(dateLow) >=0) && (endEventCalendar.compareTo(dateHigh) <= 0))
				{
					Calendar currentEventCalendar = (Calendar)startEventCalendar.clone();
					
					currentEventCalendar.set(Calendar.HOUR, 0);
					currentEventCalendar.set(Calendar.MINUTE, 0);
					currentEventCalendar.set(Calendar.SECOND, 0);
					currentEventCalendar.set(Calendar.MILLISECOND, 0);

					dateTimeCurrent = currentEventCalendar.getTime().getTime();

					if ((currentState = hashMovementStates.get(dateTimeCurrent)) == null)
					{
						hashMovementStates.put(dateTimeCurrent, new MovementState());
					}

					currentState = hashMovementStates.get(dateTimeCurrent);

// Path: app/src/main/java/com/ubiqlog/vis/utils/JsonEncodeDecode.java
// public class JsonEncodeDecode 
// {
// 	public static String EncodeBluetooth(String deviceName, String deviceAddress, String bindState, Date timeStamp) 
// 	{
// 		StringBuilder encodedString = new StringBuilder("");
// 		encodedString = encodedString.append("{\"Bluetooth\":{\"name\":\""
// 				+ deviceName
// 				+ "\",\"address\":\""
// 				+ deviceAddress
// 				+ "\",\"bond status\":\""
// 				+ bindState
// 				+ "\",\"time\":\""
// 				+ DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(timeStamp) 
// 				+ "\"}}");
// 
// 		return encodedString.toString();
// 	}
// 
// 	public static String[] DecodeBluetooth(String jsonString) 
// 	{
// 		String[] split = jsonString.split("\"");
// 
// 		String[] decodedString = new String[4];
// 
// 		decodedString[0] = split[5];
// 		decodedString[1] = split[9];
// 		decodedString[2] = split[13];
// 		decodedString[3] = split[17];
// 
// 		return decodedString;
// 	}
// 
// 	public static String EncodeMovement(Date timestampStart, Date timestampEnd, Movement movementState) 
// 	{
// 		StringBuilder encodedString = new StringBuilder("");
// 		encodedString = encodedString.append("{\"Movement\":{\"start\":\""
// 				+ DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(timestampStart)
// 				+ "\",\"end\":\""
// 				+  DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(timestampEnd)
// 				+ "\",\"state\":\""
// 				+ movementState
// 				+ "\"}}");
// 
// 		return encodedString.toString();
// 	}
// 	
// 	public static String[] DecodeMovement(String jsonString) 
// 	{
// 		String[] split = jsonString.split("\"");
// 
// 		String[] decodedString = new String[3];
// 
// 		decodedString[0] = split[5];
// 		decodedString[1] = split[9];
// 		decodedString[2] = split[13];
// 
// 		return decodedString;
// 	}
// }
// 
// Path: app/src/main/java/com/ubiqlog/vis/utils/SensorState.java
// public class SensorState 
// {
// 	public static enum Bluetooth 
// 	{
// 		NONE("none"),
// 		BONDING("bonding"),
// 		BONDED("bonded");
// 		
// 		private String state;
// 		
// 		Bluetooth(String state)
// 		{
// 			this.state = state;
// 		}
// 		
// 		public String getState()
// 		{
// 			return state;
// 		}
// 	}
// 	
// 	public static enum Movement 
// 	{
// 		FAST("fast"),
// 		SLOW("slow"),
// 		STEADY("steady");
// 		
// 		private String state;
// 		
// 		Movement(String state)
// 		{
// 			this.state = state;
// 		}
// 		
// 		public String getState()
// 		{
// 			return state;
// 		}
// 	}
// }


// Path: app/src/main/java/com/ubiqlog/vis/extras/movement/MovementStateContainer.java
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;
import com.ubiqlog.vis.utils.JsonEncodeDecode;
import com.ubiqlog.vis.utils.SensorState;

				endEventCalendar.setTime(df.parse(timestampEnd));
				
				if (startEventCalendar.before(dateLow) && endEventCalendar.after(dateLow))
				{
					startEventCalendar.setTime(dateLow.getTime());
				}
				
				if (startEventCalendar.before(dateHigh) && endEventCalendar.after(dateHigh))
				{
					endEventCalendar.setTime(dateHigh.getTime());
				}

				if ((startEventCalendar.compareTo(dateLow) >=0) && (endEventCalendar.compareTo(dateHigh) <= 0))
				{
					Calendar currentEventCalendar = (Calendar)startEventCalendar.clone();
					
					currentEventCalendar.set(Calendar.HOUR, 0);
					currentEventCalendar.set(Calendar.MINUTE, 0);
					currentEventCalendar.set(Calendar.SECOND, 0);
					currentEventCalendar.set(Calendar.MILLISECOND, 0);

					dateTimeCurrent = currentEventCalendar.getTime().getTime();

					if ((currentState = hashMovementStates.get(dateTimeCurrent)) == null)
					{
						hashMovementStates.put(dateTimeCurrent, new MovementState());
					}

					currentState = hashMovementStates.get(dateTimeCurrent);

					currentState.InsertState(startEventCalendar.getTime(), endEventCalendar.getTime(), dateLow.getTime(), SensorState.Movement.valueOf(movementState));