/** Converts this CharWrapVector to a String for debugging purposes. Word boundaries * are represented with the character |. * @return The data in this CharWrapVector as a String for debugging purposes. */ public String toDebugString() { CharWrap togo = new CharWrap(); for (int i = 0; i < filled; ++ i) { togo.append('|').append(storage[i]).append('|'); } return togo.toString(); } }
public final void writeSlow(char[] towrite, int start, int length) { // AMAZINGLY, in 1.5 it is quicker to create this here than economise it. CharWrap svb = new CharWrap(length + 10); int limit = start + length; for (int i = length; i > 0; --i) { char c = towrite[limit - i]; switch (c) { case '"': case '\\': case '/': svb.append('\\'); svb.append(c); svb.ensureCapacity(svb.size + i); break; default: svb.appendFast(c); } } internalwriter.write(svb.storage, svb.offset, svb.size); } }
/** * Converts a character to a String holding a hexadecimal representation. The * form of the representation is the HTML entity encoding the character as * Unicode. * * @param tohex * The character to be represented as hexadecimal. * @return A string holding the character in HTML Unicode-entity form. */ public static final String charToHex(char tohex) { CharWrap build = new CharWrap("&#x"); build.appendHexChar(tohex); build.append(';'); return build.toString(); } }
public String render(Object torendero) { int[] torender = (int[]) torendero; CharWrap renderinto = new CharWrap(torender.length * 5); renderinto.append(Integer.toString(torender.length) + ": "); for (int i = 0; i < torender.length; ++i) { renderinto.append(Integer.toString(torender[i]) + " "); } return renderinto.toString(); }
private void setLumpChars(XMLLump lump, char[] chars, int start, int length) { lump.start = buffer.size; lump.length = length; if (length > 0) { buffer.append(chars, start, length); } }
public static String getPending(ReadInputStream ris) { CharWrap unexpected = new CharWrap(); // TODO: this is rubbish! We cannot expect EOF until we actually read the // char. while (!ris.EOF()) { char c = ris.get(); if (unexpected.size() < 32) { unexpected.append(c); } } return unexpected.toString(); }
if (limit > 0 && rows * cols > limit) return "<"+rows+"x"+cols+" matrix too big for string representation>"; CharWrap res = new CharWrap(); res.appendPad(Integer.toString(i + 1), 3, CharWrap.PAD_LEFT).append(": "); res.append(fieldSeparator).appendPad(decFormat.format(getMval(i, j)), 7, CharWrap.PAD_RIGHT); res.append(decFormat.format(getMval(i, j))); res.append("\n"); return res.toString();
/** JDK String.split is EXTREMELY slow and also has somewhat unclear semantics. * * @param tosplit string to split * @param delim the delimitter * @param trim whether to trim * @return an array of parts */ public static String[] split (String tosplit, char delim, boolean trim) { StringList togo = new StringList(); CharWrap buffer = new CharWrap(); for (int i = 0; i < tosplit.length(); ++ i) { char c = tosplit.charAt(i); if (c == delim) { togo.add(trim? buffer.toString().trim() : buffer.toString()); buffer.clear(); } else buffer.append(c); } if (trim) { String trimmed = buffer.toString().trim(); if (trimmed.length() > 0) { togo.add(trimmed); } } else { togo.add(buffer.toString()); } return togo.toStringArray(); }
/** * Parses a path into an array of decoded EL segments * * @param path path to split * @return array */ public static String[] splitPath(String path) { StringList togo = new StringList(); CharWrap build = new CharWrap(); int index = 0; while (index < path.length()) { index = PathUtil.getPathSegment(build, path, index) + 1; togo.add(build.toString()); build.clear(); } return togo.toStringArray(); }
ParseContext(Object object, MethodAnalyser ma, boolean isgeneric, boolean isleaf, SAXAccessMethod parentsetter) { this.object = object; this.ma = ma; this.isgeneric = isgeneric; this.isleaf = isleaf; this.parentsetter = parentsetter; textsofar = new CharWrap(); }
public Object parse(String toparse) { PushbackRIS lr = new PushbackRIS(new StringRIS(toparse)); int size = LexUtil.readInt(lr); if (size > toparse.length() / 2) { throw UniversalRuntimeException.accumulate(new IllegalArgumentException(), "Possible DOS attack! Impossibly long string array encoded"); } String[] togo = new String[size]; LexUtil.expect(lr, ":"); CharWrap readbuffer = new CharWrap(); for (int i = 0; i < size; ++i) { try { int length = LexUtil.readInt(lr); if (size > toparse.length()) { throw UniversalRuntimeException.accumulate(new IllegalArgumentException(), "Possible DOS attack! Impossibly long string encoded"); } LexUtil.expect(lr, ":"); readbuffer.ensureCapacity(length); lr.read(readbuffer.storage, 0, length); togo[i] = new String(readbuffer.storage, 0, length); } catch (Exception e) { throw UniversalRuntimeException.accumulate(e, "Error reading integer vector at position " + i + " of expected " + size); } } return togo; }
public String toString() { return buffer.toString(); }
/** * Appends the specified character onto this CharWrap. * * @param c * The character to be appended. * @return A reference to this CharWrap. */ public CharWrap append(char c) { ensureCapacity(size + 1); storage[size + offset] = c; size++; return this; }
public char get() { if (pushback.size > 0) { return pushback.charAt(--pushback.size); } else return wrapped.get(); }
public void concatto(CharWrap buf, int index1, int index2) { buf.clear(); appendto(buf, index1); appendto(buf, index2); }
public String render(Object torendero) { double[] torender = (double[]) torendero; CharWrap renderinto = new CharWrap(torender.length * 15); renderinto.append(Integer.toString(torender.length) + ": "); for (int i = 0; i < torender.length; ++i) { renderinto.append(Double.toString(torender[i]) + " "); } return renderinto.toString(); }
public void unread(char c) { if (c != EOF) { pushback.append(c); } }