public String toString (String separator) { if (size == 0) return ""; T[] items = this.items; StringBuilder buffer = new StringBuilder(32); buffer.append(items[0]); for (int i = 1; i < size; i++) { buffer.append(separator); buffer.append(items[i]); } return buffer.toString(); }
/** @param newText May be null, "" will be used. */ public void setText (CharSequence newText) { if (newText == null) newText = ""; if (newText instanceof StringBuilder) { if (text.equals(newText)) return; text.setLength(0); text.append((StringBuilder)newText); } else { if (textEquals(newText)) return; text.setLength(0); text.append(newText); } intValue = Integer.MIN_VALUE; invalidateHierarchy(); }
public void actionPerformed (ActionEvent evt) { StringBuilder buffer = new StringBuilder(); buffer.append(NEHE_CHARS); buffer.append('\n'); int count = 0; for (int i = 33; i <= 255; i++) { if (buffer.indexOf(Character.toString((char)i)) != -1) continue; buffer.append((char)i); if (++count % 30 == 0) buffer.append('\n'); } sampleTextPane.setText(buffer.toString()); resetCacheButton.doClick(); } });
/** Adds information to the exception message about where in the the object graph serialization failure occurred. Serializers * can catch {@link SerializationException}, add trace information, and rethrow the exception. */ public void addTrace (String info) { if (info == null) throw new IllegalArgumentException("info cannot be null."); if (trace == null) trace = new StringBuilder(512); trace.append('\n'); trace.append(info); } }
private String replaceEscapeChars (String pattern) { buffer.setLength(0); boolean changed = false; int len = pattern.length(); for (int i = 0; i < len; i++) { char ch = pattern.charAt(i); if (ch == '\'') { changed = true; buffer.append("''"); } else if (ch == '{') { int j = i + 1; while (j < len && pattern.charAt(j) == '{') j++; int escaped = (j - i) / 2; if (escaped > 0) { changed = true; buffer.append('\''); do { buffer.append('{'); } while ((--escaped) > 0); buffer.append('\''); } if ((j - i) % 2 != 0) buffer.append('{'); i = j - 1; } else { buffer.append(ch); } } return changed ? buffer.toString() : pattern; }
private static void storeImpl (ObjectMap<String, String> properties, Writer writer, String comment, boolean escapeUnicode) throws IOException { if (comment != null) { writeComment(writer, comment); } writer.write("#"); writer.write(new Date().toString()); writer.write(LINE_SEPARATOR); StringBuilder sb = new StringBuilder(200); for (Entry<String, String> entry : properties.entries()) { dumpString(sb, entry.key, true, escapeUnicode); sb.append('='); dumpString(sb, entry.value, false, escapeUnicode); writer.write(LINE_SEPARATOR); writer.write(sb.toString()); sb.setLength(0); } writer.flush(); }
public String prettyPrint (PrettyPrintSettings settings) { StringBuilder buffer = new StringBuilder(512); prettyPrint(this, buffer, 0, settings); return buffer.toString(); }
if (object.isObject()) { if (object.child == null) buffer.append("{}"); else { boolean newLines = !isFlat(object); int start = buffer.length(); outer: while (true) { buffer.append(newLines ? "{\n" : "{ "); int i = 0; for (JsonValue child = object.child; child != null; child = child.next) { if (newLines) indent(indent, buffer); buffer.append(outputType.quoteName(child.name)); buffer.append(": "); prettyPrint(child, buffer, indent + 1, settings); if ((!newLines || outputType != OutputType.minimal) && child.next != null) buffer.append(','); buffer.append(newLines ? '\n' : ' '); if (!newLines && buffer.length() - start > settings.singleLineColumns) { buffer.setLength(start); newLines = true; continue outer; buffer.append('}'); buffer.append("[]"); else { boolean newLines = !isFlat(object); boolean wrap = settings.wrapNumericArrays || !isNumeric(object); int start = buffer.length();
/** Searches for the first index of the specified character. The search for the character starts at the beginning and moves * towards the end. * * @param string the string to find. * @return the index of the specified character, -1 if the character isn't found. * @see #lastIndexOf(String) * @since 1.4 */ public int indexOf (String string) { return indexOf(string, 0); }
/** Replaces all instances of {@code find} with {@code replace}. */ public StringBuilder replace (String find, String replace) { int findLength = find.length(), replaceLength = replace.length(); int index = 0; while (true) { index = indexOf(find, index); if (index == -1) break; replace0(index, index + findLength, replace); index += replaceLength; } return this; }
@Override public void render () { transform.idt(); if (rotateCheckBox.isChecked()) transform.rotate(Vector3.Y, rotation = (rotation + rotationSpeed * Gdx.graphics.getRawDeltaTime()) % 360); if (moveCheckBox.isChecked()) { movement = (movement + moveSpeed * Gdx.graphics.getRawDeltaTime()) % 1f; final float sm = MathUtils.sin(movement * MathUtils.PI2); final float cm = MathUtils.cos(movement * MathUtils.PI2); transform.trn(0, moveRadius * cm, moveRadius * sm); } super.render(); stringBuilder.setLength(0); getStatus(stringBuilder); fpsLabel.setText(stringBuilder); hud.act(Gdx.graphics.getDeltaTime()); hud.draw(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Level other = (Level) obj; if (title == null) { if (other.title.getText() != null) return false; } else if (!title.getText().equals(other.title.getText())) return false; return true; }
private String replaceEscapeChars (String pattern) { buffer.setLength(0); boolean changed = false; int len = pattern.length(); for (int i = 0; i < len; i++) { char ch = pattern.charAt(i); if (ch == '\'') { changed = true; buffer.append("''"); } else if (ch == '{') { int j = i + 1; while (j < len && pattern.charAt(j) == '{') j++; int escaped = (j - i) / 2; if (escaped > 0) { changed = true; buffer.append('\''); do { buffer.append('{'); } while ((--escaped) > 0); buffer.append('\''); } if ((j - i) % 2 != 0) buffer.append('{'); i = j - 1; } else { buffer.append(ch); } } return changed ? buffer.toString() : pattern; }
private static void storeImpl (ObjectMap<String, String> properties, Writer writer, String comment, boolean escapeUnicode) throws IOException { if (comment != null) { writeComment(writer, comment); } writer.write("#"); writer.write(new Date().toString()); writer.write(LINE_SEPARATOR); StringBuilder sb = new StringBuilder(200); for (Entry<String, String> entry : properties.entries()) { dumpString(sb, entry.key, true, escapeUnicode); sb.append('='); dumpString(sb, entry.value, false, escapeUnicode); writer.write(LINE_SEPARATOR); writer.write(sb.toString()); sb.setLength(0); } writer.flush(); }
/** {@inheritDoc} */ @Override public String toString () { final StringBuilder sb = new StringBuilder(); return toString(sb).toString(); }