@@ -0,0 +1,2225 @@
+/**%0A * Copyright (C) 2010-14 pvmanager developers. See COPYRIGHT.TXT%0A * All rights reserved. Use is subject to license terms. See LICENSE.TXT%0A */%0A%0Apackage org.epics.vtype.io;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.Reader;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0Aimport org.epics.util.array.ArrayDouble;%0Aimport org.epics.util.array.ListDouble;%0Aimport static org.epics.util.text.StringUtil.DOUBLE_REGEX_WITH_NAN;%0Aimport org.epics.vtype.VType;%0Aimport org.epics.vtype.ValueFactory;%0A%0A/**%0A * Utility class to serialize/de-serialize VTypes to text files.%0A *%0A * @author carcassi%0A */%0Apublic class TextIO %7B%0A    private static final Pattern pDouble = Pattern.compile(DOUBLE_REGEX_WITH_NAN);%0A%0A    /**%0A     * Reader a file where each line represents a value.%0A     * If all lines are numbers the result is a VNumberArray, otherwise%0A     * is a VStringArray.%0A     * %0A     * @param reader the stream to read%0A     * @return a type%0A     */%0A    public static VType readList(Reader reader) %7B%0A        try %7B%0A            Matcher doubleMatcher = pDouble.matcher(%22%22);%0A            List%3CString%3E lines = new ArrayList%3C%3E();%0A            BufferedReader br = new BufferedReader(reader);%0A            String line;%0A            boolean numbers = true;%0A            while ((line = br.readLine()) != null) %7B%0A                lines.add(line);%0A                if (!doubleMatcher.reset(line).matches()) %7B%0A                    numbers = false;%0A                %7D%0A            %7D%0A            %0A            if (numbers) %7B%0A                ListDouble numberList = convertToListDouble(lines);%0A                return ValueFactory.toVType(numberList);%0A            %7D else %7B%0A                return ValueFactory.toVType(lines);%0A            %7D%0A        %7D catch (Exception exception) %7B%0A            throw new RuntimeException(%22Can't read list%22, exception);%0A        %7D%0A    %7D%0A    %0A    // TODO: copied from CsvParser%0A    private static ListDouble convertToListDouble(List%3CString%3E tokens) %7B%0A        double%5B%5D values = new double%5Btokens.size()%5D;%0A        for (int i = 0; i %3C values.length; i++) %7B%0A            values%5Bi%5D = Double.parseDouble(tokens.get(i));%0A        %7D%0A        return new ArrayDouble(values);%0A    %7D%0A%7D%0A

update to current SNAPSHOT