/** * Creates a new string that contains the provided string a number of times. */ public static String repeat(String source, int count) { StringBand result = new StringBand(count); while (count > 0) { result.append(source); count--; } return result.toString(); }
/** * Specifies the new index. */ public void setIndex(int newIndex) { if (newIndex < 0) { throw new ArrayIndexOutOfBoundsException(newIndex); } if (newIndex > array.length) { String[] newArray = new String[newIndex]; System.arraycopy(array, 0, newArray, 0, index); array = newArray; } if (newIndex > index) { for (int i = index; i < newIndex; i++) { array[i] = StringPool.EMPTY; } } else if (newIndex < index) { for (int i = newIndex; i < index; i++) { array[i] = null; } } index = newIndex; length = calculateLength(); }
/** * Appends a string. */ public StringBand append(String s) { if (s == null) { s = StringPool.NULL; } if (index >= array.length) { expandCapacity(); } array[index++] = s; length += s.length(); return this; }
/** * Appends boolean value. */ public StringBand append(boolean b) { return append(b ? StringPool.TRUE : StringPool.FALSE); }
StringBand sb = new StringBand(sources.size() * 2); for (String src : sources) { if (sb.length() != 0) { sb.append(StringPool.NEWLINE); sb.append(content); FileUtil.writeString(bundleFile, sb.toString());
@Test void testSbands() { StringBand sb = new StringBand(5); assertEquals("", sb.toString()); assertEquals(5, sb.capacity()); assertEquals(0, sb.index()); assertEquals(0, sb.length()); sb.append("xxx"); assertEquals(5, sb.capacity()); assertEquals(1, sb.index()); assertEquals(3, sb.length()); assertEquals('x', sb.charAt(0)); assertEquals('x', sb.charAt(1)); assertEquals('x', sb.charAt(2)); sb.append("zzz"); assertEquals(5, sb.capacity()); assertEquals(2, sb.index()); assertEquals(6, sb.length()); assertEquals("xxxzzz", sb.toString()); assertEquals("zzz", sb.stringAt(1)); assertEquals('x', sb.charAt(0)); assertEquals('x', sb.charAt(1)); assertEquals('x', sb.charAt(2)); assertEquals('z', sb.charAt(3)); assertEquals('z', sb.charAt(4));
/** * Appends boolean value. */ public StringBand append(final boolean b) { return append(b ? StringPool.TRUE : StringPool.FALSE); }
StringBand sb = new StringBand(sources.size() * 2); for (String src : sources) { if (sb.length() != 0) { sb.append(StringPool.NEWLINE); sb.append(content); FileUtil.writeString(bundleFile, sb.toString());
/** * Creates a new string that contains the provided string a number of times. */ public static String repeat(final String source, int count) { StringBand result = new StringBand(count); while (count > 0) { result.append(source); count--; } return result.toString(); }
/** * Appends double value. */ public StringBand append(double d) { return append(Double.toString(d)); }
StringBand sb = new StringBand(sources.size() * 2); for (String src : sources) { if (sb.length() != 0) { sb.append(StringPool.NEWLINE); sb.append(content); FileUtil.writeString(bundleFile, sb.toString());
/** * Appends a string. */ public StringBand append(String s) { if (s == null) { s = StringPool.NULL; } if (index >= array.length) { expandCapacity(); } array[index++] = s; length += s.length(); return this; }
/** * Specifies the new index. */ public void setIndex(final int newIndex) { if (newIndex < 0) { throw new ArrayIndexOutOfBoundsException(newIndex); } if (newIndex > array.length) { String[] newArray = new String[newIndex]; System.arraycopy(array, 0, newArray, 0, index); array = newArray; } if (newIndex > index) { for (int i = index; i < newIndex; i++) { array[i] = StringPool.EMPTY; } } else if (newIndex < index) { for (int i = newIndex; i < index; i++) { array[i] = null; } } index = newIndex; length = calculateLength(); }
/** * Creates unique key for method signatures map. */ public static String createMethodSignaturesKey(final int access, final String methodName, final String description, final String className) { return new StringBand(7) .append(access) .append(COLON) .append(description) .append(StringPool.UNDERSCORE) .append(className) .append(StringPool.HASH) .append(methodName) .toString(); }
/** * Appends long value. */ public StringBand append(long l) { return append(Long.toString(l)); }
/** * Appends a string. */ public StringBand append(String s) { if (s == null) { s = StringPool.NULL; } if (index >= array.length) { expandCapacity(); } array[index++] = s; length += s.length(); return this; }
/** * Specifies the new index. */ public void setIndex(final int newIndex) { if (newIndex < 0) { throw new ArrayIndexOutOfBoundsException(newIndex); } if (newIndex > array.length) { String[] newArray = new String[newIndex]; System.arraycopy(array, 0, newArray, 0, index); array = newArray; } if (newIndex > index) { for (int i = index; i < newIndex; i++) { array[i] = StringPool.EMPTY; } } else if (newIndex < index) { for (int i = newIndex; i < index; i++) { array[i] = null; } } index = newIndex; length = calculateLength(); }
/** * Returns just host url, without path and query. */ public String hostUrl() { StringBand url = new StringBand(8); if (protocol != null) { url.append(protocol); url.append("://"); } if (host != null) { url.append(host); } if (port != Defaults.DEFAULT_PORT) { url.append(':'); url.append(port); } return url.toString(); }
/** * Appends float value. */ public StringBand append(float f) { return append(Float.toString(f)); }
/** * Appends a string. */ public StringBand append(String s) { if (s == null) { s = StringPool.NULL; } if (index >= array.length) { expandCapacity(); } array[index++] = s; length += s.length(); return this; }