/** * Parse a single string containing one or more string forms of rule definitions, and return the rules. The string contains * each rule on a separate line. * * @param context the environment in which this method is being executed; may not be null * @param definitions the definitions of the rules that are to be parsed, each definition separated by a newline character. * @return the rule, or null if the definition could not be parsed */ public Rule[] rulesFromString( ExecutionContext context, String definitions ) { List<String> lines = StringUtil.splitLines(definitions); List<Rule> rules = new LinkedList<Rule>(); for (String definition : lines) { Rule rule = ruleFromString(definition, context); if (rule != null) rules.add(rule); } return rules.toArray(new Rule[rules.size()]); } }
protected Map<Name, Property> load( String id, File propertiesFile ) { if (!propertiesFile.exists() || !propertiesFile.canRead()) return NO_PROPERTIES; try { String content = IoUtil.read(propertiesFile); Map<Name, Property> result = new HashMap<Name, Property>(); for (String line : StringUtil.splitLines(content)) { // Parse each line ... Property property = parse(line, result); if (property != null) { result.put(property.getName(), property); } } return result; } catch (Throwable e) { throw new DocumentStoreException(id, e); } }
protected Map<Name, Property> load( String id, File propertiesFile ) { if (!propertiesFile.exists() || !propertiesFile.canRead()) return NO_PROPERTIES; try { String content = IoUtil.read(propertiesFile); Map<Name, Property> result = new HashMap<Name, Property>(); for (String line : StringUtil.splitLines(content)) { // Parse each line ... Property property = parse(line, result); if (property != null) { result.put(property.getName(), property); } } return result; } catch (Throwable e) { throw new DocumentStoreException(id, e); } }
public void compareSeparatedLines( Object... lines ) { ByteArrayOutputStream content = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(content); for (Object line : lines) { stream.println(line); } List<String> actualLines = StringUtil.splitLines(content.toString()); assertArrayEquals(lines, actualLines.toArray()); }
String[] workspaceNames = null; if (combinedWorkspaceNames != null) { List<String> paths = StringUtil.splitLines(combinedWorkspaceNames); workspaceNames = paths.toArray(new String[paths.size()]);
@Test public void shouldPrintToStringBuilderAllResultsWhenMaxRowParameterIsLargerThanNumberOfTuples() { tuples.clear(); results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb, 3); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim } }
@Test public void shouldPrintToStringBuilderAllResults() { results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim }
@Test public void shouldPrintToStringBuilderAllResultsEvenWhenNoTuples() { tuples.clear(); results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(4)); // = delim + header + delim + (...lines...) + delim }
@Test public void shouldPrintToStringBuilderOnlyFirstLinesOfResultsEvenWhenNoTuples() { tuples.clear(); results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb, 3); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(4)); // = delim + header + delim + (...lines...) + delim }
@Test public void shouldPrintToStringBuilderOnlyFirstLinesOfResults() { results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb, 1); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(1 + 4)); // = delim + header + delim + (...lines...) + delim }
@Test public void shouldPrintToStringAllResults() { results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); List<String> lines = StringUtil.splitLines(results.toString()); assertThat(lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim }
boolean foundUsed = false; if (!allIndexNames.isEmpty()) { for (String line : StringUtil.splitLines(plan)) { Matcher matcher = INDEX_NAME_PATTERN.matcher(line); if (matcher.find()) {