private void testCSV(final String data) { this.testXSVAbc(StrTokenizer.getCSVInstance(data)); this.testXSVAbc(StrTokenizer.getCSVInstance(data.toCharArray())); }
@Test public void testCSVEmpty() { this.testEmpty(StrTokenizer.getCSVInstance()); this.testEmpty(StrTokenizer.getCSVInstance("")); }
private void checkClone(final StrTokenizer tokenizer) { assertFalse(StrTokenizer.getCSVInstance() == tokenizer); assertFalse(StrTokenizer.getTSVInstance() == tokenizer); }
@Override public List<T> convertFromString(Class<? extends List<T>> cls, String str) { assert cls != null && cls.isAssignableFrom(List.class); List<T> list = new ArrayList<>(); StrTokenizer tok = StrTokenizer.getCSVInstance(str); while (tok.hasNext()) { String next = tok.next(); list.add(elementConverter.convertFromString(elementType, next)); } return list; } }
private ListMultimap<ProcessKey, LoadProfileEvent> readLoadProfileEvents(final Element testplan) throws IOException { ListMultimap<ProcessKey, LoadProfileEvent> eventsByProcess = ArrayListMultimap.create(); String loadProfile = testplan.elementTextTrim("loadProfile"); // relative to testplan File loadProfileConfigFile = new File(new File(testplanFile.getParentFile(), "loadprofiles"), loadProfile); try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(loadProfileConfigFile), "UTF-8"))) { StrTokenizer st = StrTokenizer.getCSVInstance(); st.setDelimiterChar(';'); for (String line = null; (line = br.readLine()) != null;) { // ignore line that are blank, commented out, or represent markers if (isBlank(line) || startsWith(line, "#") || MARKER_PATTERN.matcher(line).matches()) { continue; } st.reset(line); String[] tokens = st.getTokenArray(); long startTime = Long.parseLong(tokens[0]); String operation = tokens[1]; String target = tokens[2]; int daemonId = Integer.parseInt(tokens[3]); int processId = Integer.parseInt(tokens[4]); eventsByProcess.put(new ProcessKey(daemonId, processId), new LoadProfileEvent(startTime, operation, target, daemonId, processId)); } } return eventsByProcess; }
/** * Note that because it is user input, the rendered heading must be escaped * * @param headingsString the user input heading string * @return a list of DetailsHeadings in order provided by the headingString */ private static List<DetailsHeading> buildHeadingsFromParameter(String headingsString) { final Set<DetailsHeading> headings = newLinkedHashSet(); final StrTokenizer tokenizer = StrTokenizer.getCSVInstance(headingsString); while (tokenizer.hasNext()) { final String heading = tokenizer.nextToken(); if (isNotBlank(heading)) { String escapedHeading = escapeHtml4(heading); headings.add(new DetailsHeading(escapedHeading, escapedHeading)); } } return new ArrayList<>(headings); }
private ListMultimap<ProcessKey, LoadProfileEvent> readLoadProfileEvents(final Element testplan) throws IOException { ListMultimap<ProcessKey, LoadProfileEvent> eventsByProcess = ArrayListMultimap.create(); String loadProfile = testplan.elementTextTrim("loadProfile"); // relative to testplan File loadProfileConfigFile = new File(new File(testplanFile.getParentFile(), "loadprofiles"), loadProfile); try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(loadProfileConfigFile), "UTF-8"))) { StrTokenizer st = StrTokenizer.getCSVInstance(); st.setDelimiterChar(';'); for (String line = null; (line = br.readLine()) != null;) { // ignore line that are blank, commented out, or represent markers if (isBlank(line) || startsWith(line, "#") || MARKER_PATTERN.matcher(line).matches()) { continue; } st.reset(line); String[] tokens = st.getTokenArray(); long startTime = Long.parseLong(tokens[0]); String operation = tokens[1]; String target = tokens[2]; int daemonId = Integer.parseInt(tokens[3]); int processId = Integer.parseInt(tokens[4]); eventsByProcess.put(new ProcessKey(daemonId, processId), new LoadProfileEvent(startTime, operation, target, daemonId, processId)); } } return eventsByProcess; }
List<String> inputLines = CharStreams.readLines(reader); StrTokenizer st = StrTokenizer.getCSVInstance(); st.setDelimiterString(delimiter); if (quoteChar != '\0') {