Refine search
@Override public String getLongDescription() { return new StrBuilder() .appendln("PageRank computes a per-vertex score which is the sum of PageRank scores " + "transmitted over in-edges. Each vertex's score is divided evenly among " + "out-edges. High-scoring vertices are linked to by other high-scoring vertices.") .appendNewLine() .append("The result contains the vertex ID and PageRank score.") .toString(); }
/** * Checks if the specified variable is already in the stack (list) of variables. * * @param varName the variable name to check * @param priorVariables the list of prior variables */ private void checkCyclicSubstitution(final String varName, final List<String> priorVariables) { if (priorVariables.contains(varName) == false) { return; } final StrBuilder buf = new StrBuilder(256); buf.append("Infinite loop in property interpolation of "); buf.append(priorVariables.remove(0)); buf.append(": "); buf.appendWithSeparators(priorVariables, "->"); throw new IllegalStateException(buf.toString()); }
/** * Replaces all the occurrences of variables with their matching values * from the resolver using the given source string as a template. * * @param source the string to replace in, null returns null * @return the result of the replace operation */ public String replace(final String source) { if (source == null) { return null; } final StrBuilder buf = new StrBuilder(source); if (substitute(buf, 0, source.length()) == false) { return source; } return buf.toString(); }
@Test public void testAppendSeparator_char_int() { final StrBuilder sb = new StrBuilder(); sb.appendSeparator(',', 0); // no effect assertEquals("", sb.toString()); sb.append("foo"); assertEquals("foo", sb.toString()); sb.appendSeparator(',', 1); assertEquals("foo,", sb.toString()); sb.appendSeparator(',', -1); // no effect assertEquals("foo,", sb.toString()); }
@Test public void testAppendWithSeparatorsWithNullText() { final StrBuilder sb = new StrBuilder(); sb.setNullText("null"); sb.appendWithSeparators(new Object[]{"foo", null, "baz"}, ","); assertEquals("foo,null,baz", sb.toString()); sb.clear(); sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", null, "baz"}), ","); assertEquals("foo,null,baz", sb.toString()); }
@Test public void testAppend_Object() { final StrBuilder sb = new StrBuilder(); sb.appendNull(); assertEquals("", sb.toString()); sb.append((Object) null); assertEquals("", sb.toString()); sb.append(FOO); assertEquals("foo", sb.toString()); sb.append((StringBuffer) null); assertEquals("foo", sb.toString()); sb.append(new StringBuffer("baz")); assertEquals("foobaz", sb.toString()); sb.append(new StrBuilder("yes")); assertEquals("foobazyes", sb.toString()); sb.append((CharSequence) "Seq"); assertEquals("foobazyesSeq", sb.toString()); sb.append(new StringBuilder("bld")); // Check it supports StringBuilder assertEquals("foobazyesSeqbld", sb.toString()); }
@Test public void testAppendAll_Iterator() { final StrBuilder sb = new StrBuilder(); sb.appendAll((Iterator<?>) null); assertEquals("", sb.toString()); sb.clear(); sb.appendAll(Collections.EMPTY_LIST.iterator()); assertEquals("", sb.toString()); sb.clear(); sb.appendAll(Arrays.asList(new Object[]{"foo", "bar", "baz"}).iterator()); assertEquals("foobarbaz", sb.toString()); }
@Test public void testAppendPadding() { final StrBuilder sb = new StrBuilder(); sb.append("foo"); assertEquals("foo", sb.toString()); sb.appendPadding(-1, '-'); assertEquals("foo", sb.toString()); sb.appendPadding(0, '-'); assertEquals("foo", sb.toString()); sb.appendPadding(1, '-'); assertEquals("foo-", sb.toString()); sb.appendPadding(16, '-'); assertEquals(20, sb.length()); // 12345678901234567890 assertEquals("foo-----------------", sb.toString()); }
@Test public void testLang299() { final StrBuilder sb = new StrBuilder(1); sb.appendFixedWidthPadRight("foo", 1, '-'); assertEquals("f", sb.toString()); }
@Test public void testLang412Left() { final StrBuilder sb = new StrBuilder(); sb.appendFixedWidthPadLeft(null, 10, '*'); assertEquals( "Failed to invoke appendFixedWidthPadLeft correctly", "**********", sb.toString()); }
/** * Replaces all the occurrences of variables with their matching values * from the resolver using the given source array as a template. * The array is not altered by this method. * * @param source the character array to replace in, not altered, null returns null * @return the result of the replace operation */ public String replace(final char[] source) { if (source == null) { return null; } final StrBuilder buf = new StrBuilder(source.length).append(source); substitute(buf, 0, source.length); return buf.toString(); }
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("List all triangles graph.") .appendNewLine() .append("The algorithm result contains three vertex IDs. For the directed algorithm " + "the result contains an additional bitmask indicating the presence of the six " + "potential connecting edges.") .toString(), 80); }
@Test public void testToString() { final StrBuilder sb = new StrBuilder("abc"); assertEquals("abc", sb.toString()); }
@Test public void testAppendSeparator_String_int() { final StrBuilder sb = new StrBuilder(); sb.appendSeparator(",", 0); // no effect assertEquals("", sb.toString()); sb.append("foo"); assertEquals("foo", sb.toString()); sb.appendSeparator(",", 1); assertEquals("foo,", sb.toString()); sb.appendSeparator(",", -1); // no effect assertEquals("foo,", sb.toString()); }
@Test public void testAppendWithSeparators_Iterator() { final StrBuilder sb = new StrBuilder(); sb.appendWithSeparators((Iterator<?>) null, ","); assertEquals("", sb.toString()); sb.clear(); sb.appendWithSeparators(Collections.EMPTY_LIST.iterator(), ","); assertEquals("", sb.toString()); sb.clear(); sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", "bar", "baz"}).iterator(), ","); assertEquals("foo,bar,baz", sb.toString()); sb.clear(); sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", "bar", "baz"}).iterator(), null); assertEquals("foobarbaz", sb.toString()); sb.clear(); sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", null, "baz"}).iterator(), ","); assertEquals("foo,,baz", sb.toString()); }
@Test public void testAppendWithNullText() { final StrBuilder sb = new StrBuilder(); sb.setNullText("NULL"); assertEquals("", sb.toString()); sb.appendNull(); assertEquals("NULL", sb.toString()); sb.append((Object) null); assertEquals("NULLNULL", sb.toString()); sb.append(FOO); assertEquals("NULLNULLfoo", sb.toString()); sb.append((String) null); assertEquals("NULLNULLfooNULL", sb.toString()); sb.append(""); assertEquals("NULLNULLfooNULL", sb.toString()); sb.append("bar"); assertEquals("NULLNULLfooNULLbar", sb.toString()); sb.append((StringBuffer) null); assertEquals("NULLNULLfooNULLbarNULL", sb.toString()); sb.append(new StringBuffer("baz")); assertEquals("NULLNULLfooNULLbarNULLbaz", sb.toString()); }
@Test public void testAppendAll_Collection() { final StrBuilder sb = new StrBuilder(); sb.appendAll((Collection<?>) null); assertEquals("", sb.toString()); sb.clear(); sb.appendAll(Collections.EMPTY_LIST); assertEquals("", sb.toString()); sb.clear(); sb.appendAll(Arrays.asList(new Object[]{"foo", "bar", "baz"})); assertEquals("foobarbaz", sb.toString()); }
@Test public void testLang412Right() { final StrBuilder sb = new StrBuilder(); sb.appendFixedWidthPadRight(null, 10, '*'); assertEquals( "Failed to invoke appendFixedWidthPadRight correctly", "**********", sb.toString()); }
/** * Replaces all the occurrences of variables with their matching values * from the resolver using the given source builder as a template. * The builder is not altered by this method. * <p> * Only the specified portion of the builder will be processed. * The rest of the builder is not processed, and is not returned. * * @param source the builder to use as a template, not changed, null returns null * @param offset the start offset within the array, must be valid * @param length the length within the array to be processed, must be valid * @return the result of the replace operation */ public String replace(final StrBuilder source, final int offset, final int length) { if (source == null) { return null; } final StrBuilder buf = new StrBuilder(length).append(source, offset, length); substitute(buf, 0, length); return buf.toString(); }