/** * Splits a string using the specified delimiter. * * @param text The string to split. * @param delimiter The delimiter for the split operation. * @return A string array containing the split values. The returned array is guaranteed not to * contain null values by replacing every occurrence of a null value with an empty * string. */ public static String[] split(String text, String delimiter) { return split(text, delimiter, 0); }
/** * Splits a string using the specified delimiter. * * @param text The string to split. * @param delimiter The delimiter for the split operation. * @param count Specifies a minimum number of elements to be returned. If the result of the * split operation results in fewer elements, the returned array is expanded to * contain the minimum number of elements. * @return A string array containing the split values. The returned array is guaranteed not to * contain null values by replacing every occurrence of a null value with an empty * string. */ public static String[] split(String text, String delimiter, int count) { return split(text, delimiter, count, true); }
public Version(String value) { if (value != null && !value.isEmpty()) { String[] pcs = StrUtil.split(value, ".", 4); for (int i = 0; i < 4; i++) { seq[i] = StrUtil.extractInt(pcs[i]); } } }
public static String formatName(String name) { if (StringUtils.isEmpty(name)) { return ""; } String pcs[] = StrUtil.split(WordUtils.capitalizeFully(name, WORD_DELIMITERS), ","); StringBuilder sb = new StringBuilder(name.length() + 5); for (String pc : pcs) { if (sb.length() > 0) { sb.append(", "); } sb.append(pc.trim()); } return sb.toString(); }
size = 1; } else { pcs = split(text, delimiter); size = text.endsWith(delimiter) ? pcs.length - 1 : pcs.length;
String[] pcs = split(text, delimiter); StringBuilder result = new StringBuilder(text.length());
/** * Control parameters for the dialog. * * @param message Text message * @param title Title of dialog * @param styles Style classes for icon, message text, and panel (pipe-delimited) * @param responses Responses for the dialog. * @param saveResponseId Uniquely identifies this response for purposes of saving and retrieving * the last response. If not specified (null or empty), the response is not saved. * Otherwise, if a saved response exists, it is returned without displaying the * dialog. If a saved response does not exist, the user is prompted in the normal * manner with the addition of a check box on the dialog asking if the response is to * be saved. If this box is checked, the user's response is then saved as a user * preference. * @param callback Callback to receive response. */ public DialogControl(String message, String title, String styles, List<DialogResponse<T>> responses, String saveResponseId, IPromptCallback<T> callback) { this.message = StrUtil.formatMessage(message); this.title = StrUtil.formatMessage(title); this.saveResponseId = saveResponseId; this.callback = callback; this.responses = responses; String[] sclass = styles == null ? null : StrUtil.split(styles, "|", 3, false); iconClass = sclass == null ? null : sclass[0]; textClass = sclass == null ? null : sclass[1]; panelClass = sclass == null || sclass[2] == null ? "panel-primary" : sclass[2]; }
/** * Setter method for Layout property. This property allows an application to control the * position of the splitter bar and ordering of columns. * * @param layout The layout data. */ public void setLayout(String layout) { String[] pcs = StrUtil.split(layout, ";"); if (pcs.length > 0) { String[] spl = StrUtil.split(pcs[0], ":", 3); sortColumn = NumberUtils.toInt(spl[1]); sortAscending = BooleanUtils.toBoolean(spl[2]); } for (int i = 1; i < pcs.length; i++) { String[] col = StrUtil.split(pcs[i], ":", 2); Column lhdr = getColumnByIndex(NumberUtils.toInt(col[0])); if (lhdr != null) { lhdr.setWidth(col[1]); lhdr.setIndex(i - 1); } } doSort(); }
protected void setup(String title, int sortBy, String... headers) { setCaption(title); dataName = title; String defWidth = (100 / headers.length) + "%"; for (String header : headers) { String[] pcs = StrUtil.split(header, "^", 3); Column lhdr = new Column(pcs[0]); columns.addChild(lhdr); lhdr.setAttribute(SORT_TYPE_ATTR, NumberUtils.toInt(pcs[1])); lhdr.setAttribute(COL_INDEX_ATTR, colCount++); String width = pcs[2]; if (!width.isEmpty()) { if (NumberUtils.isDigits(width) || "min".equals(width)) { //lhdr.setHflex(width); } else { lhdr.setWidth(width); } } else { lhdr.setWidth(defWidth); } } sortColumn = Math.abs(sortBy) - 1; sortAscending = sortBy > 0; doSort(); }