List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified.
From source file:com.pureinfo.srm.action.SuccessAction.java
/** * @see com.pureinfo.ark.interaction.ActionBase#executeAction() *///from www.j a v a 2 s . c o m public ActionForward executeAction() throws PureException { String sForward = request.getString("forward", true); logger.debug(request.getParameter("forward")); if (sForward != null) { sForward = PropertiesUtil.loadConvert(sForward); String[] forwards = StringUtils.split(sForward, ','); List forwardList = new ArrayList(); for (int i = 0; i < forwards.length; i += 2) { Pair pair = new Pair(); pair.setValue1(forwards[i]); if (i + 1 < forwards.length) { pair.setValue2(forwards[i + 1]); } else { pair.setValue2(""); } forwardList.add(pair); } request.setAttribute("forward", forwardList); } String timeout = request.getParameter("timeout"); if (sForward != null) { request.setAttribute("timeout", timeout); } return mapping.findForward("success"); }
From source file:com.tdclighthouse.prototype.utils.MIMEParse.java
/** * Carves up a mime-type and returns a ParseResults object * /* w ww . java 2s .co m*/ * For example, the media range 'application/xhtml;q=0.5' would get parsed * into: * * ('application', 'xhtml', {'q', '0.5'}) */ protected static ParseResults parseMimeType(String mimeType) { String[] parts = StringUtils.split(mimeType, ";"); ParseResults results = new ParseResults(); results.params = new HashMap<String, String>(); for (int i = 1; i < parts.length; ++i) { String p = parts[i]; String[] subParts = StringUtils.split(p, '='); if (subParts.length == 2) { results.params.put(subParts[0].trim(), subParts[1].trim()); } } String fullType = parts[0].trim(); // Java URLConnection class sends an Accept header that includes a // single "*" - Turn it into a legal wildcard. if (fullType.equals(ASTERISK)) { fullType = "*/*"; } String[] types = StringUtils.split(fullType, "/"); results.type = types[0].trim(); results.subType = types[1].trim(); return results; }
From source file:com.intel.cosbench.driver.iterator.RangeIterator.java
private static RangeIterator tryParse(String pattern) { pattern = StringUtils.substringBetween(pattern, "(", ")"); String[] args = StringUtils.split(pattern, ","); int lower = Integer.parseInt(args[0]); int upper = Integer.parseInt(args[1]); return new RangeIterator(lower, upper); }
From source file:com.yiji.ypayment.common.utils.Reflections.java
public static List<Object> invokeGetter(Object obj, String[] propertyNames) { List<Object> list = new ArrayList<Object>(propertyNames.length); for (String propertyName : propertyNames) { Object propertyValue = null; if (StringUtils.contains(propertyName, ".")) { String[] propertyNamePaths = StringUtils.split(propertyName, "."); Object temp = obj;//from w ww . j a va 2s .co m for (String propertyNamePath : propertyNamePaths) { if (temp == null) { break; } temp = Reflections.invokeGetter(temp, propertyNamePath); } propertyValue = temp; } else { propertyValue = Reflections.invokeGetter(obj, propertyName); } list.add(propertyValue); } return list; }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.AbstractPattern.java
static SortedSet<Integer> parseLineValues(final String lineValues) { final SortedSet<Integer> lines = new TreeSet<>(); if ("*".equals(lineValues)) { return lines; }//from w w w . ja v a2 s.co m final String s = StringUtils.substringBetween(StringUtils.trim(lineValues), "[", "]"); final String[] parts = StringUtils.split(s, ','); for (final String part : parts) { if (StringUtils.contains(part, '-')) { final String[] range = StringUtils.split(part, '-'); final int from = Integer.parseInt(range[0]); final int to = Integer.parseInt(range[1]); addLines(lines, from, to); } else { lines.add(Integer.parseInt(part)); } } return lines; }
From source file:au.edu.anu.portal.portlets.basiclti.support.CollectionsSupport.java
/** * Split a String to a List, based on the given delimiter, and also chomp any new lines that may be present. * @param str the string/*ww w .ja v a 2 s . c o m*/ * @param delimiter delimiter to split on * @param chomp remove new lines as well? * @return */ public static List<String> splitStringToList(String str, String delimiter, boolean chomp) { String[] array = StringUtils.split(str, delimiter); if (chomp) { //iterate and chomp for (int i = 0; i < array.length; i++) { array[i] = StringUtils.strip(array[i]); } } List<String> list = Arrays.asList(array); return list; }
From source file:com.bstek.dorado.view.widget.ComponentReferencePropertyOutputter.java
public void output(Object object, OutputContext context) throws Exception { Writer writer = context.getWriter(); JsonBuilder jsonBuilder = context.getJsonBuilder(); String id = String.valueOf(object); String[] ids = StringUtils.split(id, ','); if (ids.length > 1) { jsonBuilder.array();/*from w w w. jav a2 s. c o m*/ for (int i = 0; i < ids.length; i++) { jsonBuilder.beginValue(); writer.append("view.getComponentReference(\""); writer.append(ids[i]); writer.append("\")"); jsonBuilder.endValue(); } jsonBuilder.endArray(); } else { jsonBuilder.beginValue(); writer.append("view.getComponentReference(\""); writer.append(id); writer.append("\")"); jsonBuilder.endValue(); } }
From source file:com.bstek.dorado.config.xml.StringArrayPropertyParser.java
@Override protected Object doParse(Node node, ParseContext context) throws Exception { Object value = super.doParse(node, context); if (value == null) return null; if (value instanceof String) { String text = (String) value; if (!StringUtils.isEmpty(text)) { return StringUtils.split(text, seperator); } else {/* w ww. j a v a 2s. c o m*/ return null; } } else if (value instanceof String[]) { return value; } else { throw new XmlParseException("String array expected.", node, context); } }
From source file:com.intel.cosbench.driver.random.UniformIntGenerator.java
private static UniformIntGenerator tryParse(String pattern) { pattern = StringUtils.substringBetween(pattern, "(", ")"); String[] args = StringUtils.split(pattern, ','); int lower = Integer.parseInt(args[0]); int upper = Integer.parseInt(args[1]); return new UniformIntGenerator(lower, upper); }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.SQLTextUtil.java
/** * cursor object arry//from w w w .j a va 2 s . c o m * * @param strQuery * @param intPosition * @param startIndex * @param endIndex * @return */ private static String[] cusrsotObjectArry(String strQuery, int intPosition, int startIndex, int endIndex) { String[] arryCursor = { "", "" }; String strPosTxt = StringUtils.trimToEmpty(StringUtils.substring(strQuery, startIndex, endIndex)); // if(logger.isDebugEnabled()) logger.debug("==> postion char : " + strPosTxt); if (StringUtils.isEmpty(strPosTxt)) return arryCursor; String strBeforeTxt = strQuery.substring(0, startIndex); String[] strArryBeforeTxt = StringUtils.split(strBeforeTxt, ' '); // ? ? . String strAfterTxt = strQuery.substring(startIndex); String[] strArryAfterTxt = StringUtils.split(strAfterTxt, ' '); if (strArryBeforeTxt.length == 0) { arryCursor[0] = removeSpecialChar(strArryAfterTxt[0]); arryCursor[1] = ""; } else { arryCursor[0] = removeSpecialChar(strArryBeforeTxt[strArryBeforeTxt.length - 1]); arryCursor[1] = removeSpecialChar(strArryAfterTxt[0]); } return arryCursor; }