// Path: sense-android-library/src/nl/sense_os/service/constants/SensorData.java
// public static class DataPoint implements BaseColumns {
// 
//     public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE
//             + "/vnd.sense_os.data_point";
//     public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE
//             + "/vnd.sense_os.data_point";
//     public static final String CONTENT_URI_PATH = "/recent_values";
//     @Deprecated
//     public static final String CONTENT_PERSISTED_URI_PATH = "/persisted_values";
//     public static final String CONTENT_REMOTE_URI_PATH = "/remote_values";
// 
//     /**
//      * The name of the sensor that generated the data point. <br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String SENSOR_NAME = "sensor_name";
//     /**
//      * Description of the sensor that generated the data point. Can either be the hardware name,
//      * or any other useful description. <br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String SENSOR_DESCRIPTION = "sensor_description";
//     /**
//      * The data type of the data point. <br>
//      * <br>
//      * TYPE: String
//      * 
//      * @see SenseDataTypes
//      */
//     public static final String DATA_TYPE = "data_type";
//     /**
//      * The human readable display name of the sensor that generated the data point. <br>
//      * <br>
//      * TYPE: String
//      * 
//      * @see SenseDataTypes
//      */
//     public static final String DISPLAY_NAME = "display_name";
//     /**
//      * Time stamp for the data point, in milliseconds. <br>
//      * <br>
//      * TYPE: long
//      */
//     public static final String TIMESTAMP = "timestamp";
//     /**
//      * Data point value. <br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String VALUE = "value";
//     /**
//      * Transmit state of the data point, signalling whether the point has been sent to
//      * CommonSense already.<br>
//      * <br>
//      * TYPE: integer status code: 0 (not sent), or 1 (sent)
//      */
//     public static final String TRANSMIT_STATE = "transmit_state";
//     /**
//      * Device UUID of the sensor. Use this for sensors that are originated from
//      * "external sensors", or leave <code>null</code> to use the phone as default device.<br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String DEVICE_UUID = "device_uuid";
// 
//     private DataPoint() {
//         // class should not be instantiated
//     }
// }


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import nl.sense_os.service.constants.SensorData.DataPoint;
    private static List<String> getSensorNameMatches(Set<String> allSensors, String selection) {

        List<String> result = new ArrayList<String>();

        if (selection != null && selection.contains(DataPoint.SENSOR_NAME)) {

            // preprocess the selection string a bit
            selection = fixCompareSigns(selection);

            int eqKeyStart = selection.indexOf(DataPoint.SENSOR_NAME + "='");
            int neqKeyStart = selection.indexOf(DataPoint.SENSOR_NAME + "!='")
                    + (DataPoint.SENSOR_NAME + "!='").length();

            if (-1 != eqKeyStart) {
                // selection contains "sensor_name='"
                int sensorNameStart = eqKeyStart + (DataPoint.SENSOR_NAME + "='").length();
                int sensorNameEnd = selection.indexOf("'", sensorNameStart);
                sensorNameEnd = sensorNameEnd == -1 ? selection.length() - 1 : sensorNameEnd;
                String sensorName = selection.substring(sensorNameStart, sensorNameEnd);
                if (sensorName.equals("?")) {
                    throw new IllegalArgumentException(
                            "LocalStorage cannot handle queries with arguments array, sorry...");
                }
                // Log.v(TAG, "Query contains: " + DataPoint.SENSOR_NAME + " = '" + sensorName +
                // "'");

                boolean inStorage = false;
                for (String key : allSensors) {
                    if (key.startsWith(sensorName)) {
                        result.add(key);
// Path: sense-android-library/src/nl/sense_os/service/constants/SensorData.java
// public static class DataPoint implements BaseColumns {
// 
//     public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE
//             + "/vnd.sense_os.data_point";
//     public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE
//             + "/vnd.sense_os.data_point";
//     public static final String CONTENT_URI_PATH = "/recent_values";
//     @Deprecated
//     public static final String CONTENT_PERSISTED_URI_PATH = "/persisted_values";
//     public static final String CONTENT_REMOTE_URI_PATH = "/remote_values";
// 
//     /**
//      * The name of the sensor that generated the data point. <br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String SENSOR_NAME = "sensor_name";
//     /**
//      * Description of the sensor that generated the data point. Can either be the hardware name,
//      * or any other useful description. <br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String SENSOR_DESCRIPTION = "sensor_description";
//     /**
//      * The data type of the data point. <br>
//      * <br>
//      * TYPE: String
//      * 
//      * @see SenseDataTypes
//      */
//     public static final String DATA_TYPE = "data_type";
//     /**
//      * The human readable display name of the sensor that generated the data point. <br>
//      * <br>
//      * TYPE: String
//      * 
//      * @see SenseDataTypes
//      */
//     public static final String DISPLAY_NAME = "display_name";
//     /**
//      * Time stamp for the data point, in milliseconds. <br>
//      * <br>
//      * TYPE: long
//      */
//     public static final String TIMESTAMP = "timestamp";
//     /**
//      * Data point value. <br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String VALUE = "value";
//     /**
//      * Transmit state of the data point, signalling whether the point has been sent to
//      * CommonSense already.<br>
//      * <br>
//      * TYPE: integer status code: 0 (not sent), or 1 (sent)
//      */
//     public static final String TRANSMIT_STATE = "transmit_state";
//     /**
//      * Device UUID of the sensor. Use this for sensors that are originated from
//      * "external sensors", or leave <code>null</code> to use the phone as default device.<br>
//      * <br>
//      * TYPE: String
//      */
//     public static final String DEVICE_UUID = "device_uuid";
// 
//     private DataPoint() {
//         // class should not be instantiated
//     }
// }


// Path: sense-android-library/src/nl/sense_os/service/storage/ParserUtils.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import nl.sense_os.service.constants.SensorData.DataPoint;

    private static List<String> getSensorNameMatches(Set<String> allSensors, String selection) {

        List<String> result = new ArrayList<String>();

        if (selection != null && selection.contains(DataPoint.SENSOR_NAME)) {

            // preprocess the selection string a bit
            selection = fixCompareSigns(selection);

            int eqKeyStart = selection.indexOf(DataPoint.SENSOR_NAME + "='");
            int neqKeyStart = selection.indexOf(DataPoint.SENSOR_NAME + "!='")
                    + (DataPoint.SENSOR_NAME + "!='").length();

            if (-1 != eqKeyStart) {
                // selection contains "sensor_name='"
                int sensorNameStart = eqKeyStart + (DataPoint.SENSOR_NAME + "='").length();
                int sensorNameEnd = selection.indexOf("'", sensorNameStart);
                sensorNameEnd = sensorNameEnd == -1 ? selection.length() - 1 : sensorNameEnd;
                String sensorName = selection.substring(sensorNameStart, sensorNameEnd);
                if (sensorName.equals("?")) {
                    throw new IllegalArgumentException(
                            "LocalStorage cannot handle queries with arguments array, sorry...");
                }
                // Log.v(TAG, "Query contains: " + DataPoint.SENSOR_NAME + " = '" + sensorName +
                // "'");

                boolean inStorage = false;
                for (String key : allSensors) {
                    if (key.startsWith(sensorName)) {
                        result.add(key);
                        inStorage = true;