Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2008-2013 LimeTri. All rights reserved. AgroSense 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 3 of the License, or (at your option) any later version. There are special exceptions to the terms and conditions of the GPLv3 as it is applied to this software, see the FLOSS License Exception <>. AgroSense 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 AgroSense. If not, see <>.
package eu.agrosense.api.observations;
import static eu.agrosense.api.observations.MeasurementCollection.NO_VALUE;
import static eu.agrosense.api.observations.MeasurementCollection.VALUE_SEPARATOR;
Converter for MeasurementCollection.PROP_MEASUREMENTS.

public class MeasurementsConverter implements StringConverter<double[]> {
    public Class<double[]> getObjectClass() {
        return double[].class;
    public String toString(double[] obj) {
        if (obj == null || obj.length == 0) return null;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < obj.lengthi++) {
            if (i > 0) sb.append();
            if (obj[i] != sb.append(obj[i]);
        return sb.toString();
    public double[] toObject(String s) {
        if (s == null || s.isEmpty()) return null;
        String[] strings = s.split(, -1); // include trailing blanks
        double[] doubles = new double[strings.length];
        for (int i = 0; i < strings.lengthi++) {
            if (!strings[i].isEmpty()) doubles[i] = Double.valueOf(strings[i]);
        return doubles;
New to GrepCode? Check out our FAQ X