public void concatto(CharWrap buf, int index1, int index2) { buf.clear(); appendto(buf, index1); appendto(buf, index2); }
public void println(String toprint) { if (incompleteline.size() > 0) { incompleteline.append(toprint); stringlist.add(incompleteline.toString()); incompleteline.clear(); } else { stringlist.add(toprint); } }
/** * 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(); }
/** 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(); }