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()); }
@Test public void testCapacity() { final StrBuilder sb = new StrBuilder(); assertEquals(sb.buffer.length, sb.capacity()); sb.append("HelloWorldHelloWorldHelloWorldHelloWorld"); assertEquals(sb.buffer.length, sb.capacity()); }
@Test public void testAppendSeparator_char() { final StrBuilder sb = new StrBuilder(); sb.appendSeparator(','); // no effect assertEquals("", sb.toString()); sb.append("foo"); assertEquals("foo", sb.toString()); sb.appendSeparator(','); assertEquals("foo,", sb.toString()); } @Test
@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 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 testAppendNewLine() { StrBuilder sb = new StrBuilder("---"); sb.appendNewLine().append("+++"); assertEquals("---" + SEP + "+++", sb.toString()); sb = new StrBuilder("---"); sb.setNewLineText("#").appendNewLine().setNewLineText(null).appendNewLine(); assertEquals("---#" + SEP, sb.toString()); }
@Test public void testToStringBuffer() { final StrBuilder sb = new StrBuilder(); assertEquals(new StringBuffer().toString(), sb.toStringBuffer().toString()); sb.append("junit"); assertEquals(new StringBuffer("junit").toString(), sb.toStringBuffer().toString()); }
@Test public void testToStringBuilder() { final StrBuilder sb = new StrBuilder(); assertEquals(new StringBuilder().toString(), sb.toStringBuilder().toString()); sb.append("junit"); assertEquals(new StringBuilder("junit").toString(), sb.toStringBuilder().toString()); }
/** * complete node literal * * @param t * @return A node literal. */ public static String tokenLiteral(final Token t) { // Look at kind of token and return "" when it's a multiline comment if (t.kind == VmParserConstants.MULTI_LINE_COMMENT) { return ""; } else if (t.specialToken == null || t.specialToken.image.startsWith("##")) { return t.image; } else { final StrBuilder special = getSpecialText(t); if (special.length() > 0) { return special.append(t.image).toString(); } return t.image; } }
/** * 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 new StrBuilder() .appendln("Computes metrics on a directed or undirected graph.") .appendNewLine() .appendln("Vertex metrics:") .appendln("- number of vertices") .appendln("- number of edges") .appendln("- number of unidirectional edges (directed only)") .appendln("- number of bidirectional edges (directed only)") .appendln("- average degree") .appendln("- number of triplets") .appendln("- maximum degree") .appendln("- maximum out degree (directed only)") .appendln("- maximum in degree (directed only)") .appendln("- maximum number of triplets") .appendNewLine() .appendln("Edge metrics:") .appendln("- number of triangle triplets") .appendln("- number of rectangle triplets") .appendln("- maximum number of triangle triplets") .append("- maximum number of rectangle triplets") .toString(); }
@Test public void testLength() { final StrBuilder sb = new StrBuilder(); assertEquals(0, sb.length()); sb.append("Hello"); assertEquals(5, sb.length()); }
@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 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()); }
@Override public String getUsage() { StrBuilder strBuilder = new StrBuilder(); // print parameters as ordered list for (Parameter<?> parameter : parameters) { if (!parameter.isHidden()) { strBuilder .append(parameter.getUsage()) .append(" "); } } return strBuilder.toString(); }
@Override public String getLongDescription() { return WordUtils.wrap(new StrBuilder() .appendln("Adamic-Adar measures the similarity between vertex neighborhoods and is " + "computed as the sum of the inverse logarithm of centerpoint degree over shared " + "neighbors.") .appendNewLine() .append("The algorithm result contains two vertex IDs and the similarity score.") .toString(), 80); }
@Test public void testSize() { final StrBuilder sb = new StrBuilder(); assertEquals(0, sb.size()); sb.append("Hello"); assertEquals(5, sb.size()); }
@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()); }