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.qualogy.qafe.gwt.server.event.assembler.LogFunctionEventRenderer.java
public BuiltInFunctionGVO convert(EventItem eventItem, EventDataGVO eventData, ApplicationContext context, SessionContainer sc) {//from w ww .j a v a 2s.c o m BuiltInFunctionGVO bif = null; if (eventItem instanceof LogFunction) { LogFunction logFunction = (LogFunction) eventItem; LogFunctionGVO logFunctionGVO = new LogFunctionGVO(); Object data = logFunction.getMessageData(); logFunctionGVO.setMessage(data != null ? data.toString() : ""); logFunctionGVO.setWindowId(eventData.getWindowId()); logFunctionGVO.setUuid(eventData.getUuid()); logFunctionGVO.setDebug(logFunction.getDebug()); logFunctionGVO.setDelay(logFunction.getDelay()); String[] properties = StringUtils.split(logFunction.getStyle() == null ? "" : logFunction.getStyle(), ';'); String[][] styleProperties = new String[properties.length][2]; for (int i = 0; i < properties.length; i++) { styleProperties[i] = StringUtils.split(properties[i], ':'); } /* * Modify the properties since this is DOM manipulation : font-size for css has to become fontSize for DOM */ for (int i = 0; i < styleProperties.length; i++) { styleProperties[i][0] = StyleDomUtil.initCapitalize(styleProperties[i][0]); } logFunctionGVO.setStyleProperties(styleProperties); logFunctionGVO.setStyleClass(logFunction.getStyleClass()); bif = logFunctionGVO; } return bif; }
From source file:com.flexive.shared.FxArrayUtils.java
/** * Converts a list with integer items separated by a specific delimeter to a array. * <p/>//from w ww . j a v a 2 s . c om * A empty array will be returned if the list is null or a empty string. * * @param list the list * @param separator the separator character * @return the array * @throws FxInvalidParameterException if the list can not be converted, the exception's getParameterName() * function will return the token that caused the exception */ public static int[] toIntArray(String list, char separator) throws FxInvalidParameterException { if (list == null || list.length() == 0) return new int[0]; String sInts[] = StringUtils.split(list, separator); int iInts[] = new int[sInts.length]; for (int i = 0; i < sInts.length; i++) { try { iInts[i] = Integer.parseInt(sInts[i]); } catch (Exception exc) { throw new FxInvalidParameterException( "'" + list + "' can not be converted to a int[] array using separator '" + separator + "'", sInts[i]); } } return iInts; }
From source file:com.voa.weixin.task.WeixinResult.java
public int getInt(String xpath) { int value = 0; JSONObject temp = result;// w ww . ja v a 2s .c om String[] names = StringUtils.split(xpath, "/"); for (int i = 0; i < names.length; i++) { if (i == (names.length - 1)) { value = temp.getInt(names[i]); break; } temp = temp.getJSONObject(names[i]); } return value; }
From source file:com.haulmont.cuba.gui.ScreenHistorySupport.java
public ScreenHistorySupport() { metadata = AppBeans.get(Metadata.NAME); messages = AppBeans.get(Messages.NAME); configuration = AppBeans.get(Configuration.NAME); String property = configuration.getConfig(ClientConfig.class).getScreenIdsToSaveHistory(); if (StringUtils.isNotBlank(property)) { screenIds.addAll(Arrays.asList(StringUtils.split(property, ','))); }//from w w w . ja va 2 s. c o m WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); for (MetaClass metaClass : metadata.getTools().getAllPersistentMetaClasses()) { Map<String, Object> attributes = metadata.getTools() .getMetaAnnotationAttributes(metaClass.getAnnotations(), TrackEditScreenHistory.class); if (Boolean.TRUE.equals(attributes.get("value"))) { screenIds.add(windowConfig.getEditorScreenId(metaClass)); } } }
From source file:info.magnolia.commands.impl.RuleBasedCommand.java
public Rule getRule() { if (rule == null) { rule = new Rule(); String[] nodeTypes = StringUtils.split(this.getItemTypes(), " ,"); for (int i = 0; i < nodeTypes.length; i++) { String nodeType = nodeTypes[i]; rule.addAllowType(nodeType); }/*from w w w . j av a2 s. c o m*/ // magnolia resource and metadata must always be included rule.addAllowType(NodeTypes.MetaData.NAME); rule.addAllowType(NodeTypes.Resource.NAME); } return rule; }
From source file:com.mirth.connect.model.converters.EDIXMLHandler.java
public void startElement(String uri, String name, String qName, Attributes atts) { if (sawHeader == false) { sawHeader = true;//w w w . ja v a 2 s . c o m } else { if (currentLocation.equals(Location.DOCUMENT)) { output.append(name); currentLocation = Location.SEGMENT; lastInSubelement = false; previousSegmentNameArray = null; } else if (currentLocation.equals(Location.SEGMENT)) { String[] currentNameArray = StringUtils.split(name, "."); int currentDelimeterCount = currentNameArray.length - 1; if (currentDelimeterCount == 1) { int previousId = 0; if (previousSegmentNameArray != null) { previousId = NumberUtils.toInt(previousSegmentNameArray[1]); } int currentId = NumberUtils.toInt(currentNameArray[1]); for (int i = 1; i < (currentId - previousId); i++) { output.append(elementDelimeter); } previousSegmentNameArray = currentNameArray; } output.append(elementDelimeter); currentLocation = Location.ELEMENT; lastInSubelement = false; previousElementNameArray = null; } else if (currentLocation.equals(Location.ELEMENT)) { String[] currentNameArray = StringUtils.split(name, "."); int currentDelimeterCount = currentNameArray.length - 1; if (currentDelimeterCount == 2) { int previousId = 0; if (previousElementNameArray != null) { previousId = NumberUtils.toInt(previousElementNameArray[2]); } int currentId = NumberUtils.toInt(currentNameArray[2]); for (int i = 1; i < (currentId - previousId); i++) { output.append(subelementDelimeter); } previousElementNameArray = currentNameArray; } if (lastInSubelement) { output.append(subelementDelimeter); } currentLocation = Location.SUBELEMENT; lastInSubelement = true; } } }
From source file:com.qualogy.qafe.gwt.server.event.assembler.AbstractEventRenderer.java
public void setComponents(BuiltInFunctionGVO out, BuiltInFunction in, EventDataGVO eventData) { if (out != null && in != null) { List<Component> components = in.getComponents(); if (components != null) { List<BuiltInComponentGVO> componentIds = new ArrayList<BuiltInComponentGVO>(); for (Component component : components) { String[] componentData = StringUtils.split(component.getComponentId(), "."); BuiltInComponentGVO builtInComponentGVO = new BuiltInComponentGVO(); builtInComponentGVO.setUUID(eventData.getUuid()); builtInComponentGVO.setComponentName(generateId(component.getComponentName(), eventData)); if (componentData != null && componentData.length == 1) { // so // only // the // name // is // provided if (containsAttribute(componentData[0])) { fillBuiltInComponentGVO(builtInComponentGVO, componentData[0]); } else { builtInComponentGVO.setComponentId(componentData[0]); }// w w w.j ava 2 s. co m builtInComponentGVO .setComponentIdUUID(generateId(builtInComponentGVO.getComponentId(), eventData)); } else if (componentData != null && componentData.length == 2) { // strip uud String[] uuidSplit = StringUtils.split(eventData.getUuid(), "|"); if (uuidSplit != null) { if (uuidSplit.length == 1) {// standard // RootPanel // processing if (containsAttribute(componentData[1])) { fillBuiltInComponentGVO(builtInComponentGVO, componentData[1]); } else { builtInComponentGVO.setComponentId(component.getComponentId()); } builtInComponentGVO.setComponentIdUUID( generateId(builtInComponentGVO.getComponentId(), eventData)); builtInComponentGVO.setWindowId(eventData.getParent()); } else if (uuidSplit.length == 2) { if (containsAttribute(componentData[1])) { fillBuiltInComponentGVO(builtInComponentGVO, componentData[1]); } else { builtInComponentGVO.setComponentId(componentData[1]); } builtInComponentGVO .setComponentIdUUID(generateId(builtInComponentGVO.getComponentId(), componentData[0], eventData.getContext())); builtInComponentGVO.setWindowId(componentData[0]); } } else { logger.info("The UUID is not of correct format at all:" + eventData.getUuid()); } // // strip uud // String[] uuidSplit = StringUtils.split(eventData.getUuid(), "|"); // if (uuidSplit != null) { // if (uuidSplit.length == 1) {// standard // // RootPanel // // processing // if (containsAttribute(componentData[1])) { // fillBuiltInComponentGVO(builtInComponentGVO, componentData[1]); // } else { // builtInComponentGVO.setComponentId(component.getComponentId()); // //builtInComponentGVO.setComponentId(componentData[1]); // } // builtInComponentGVO.setComponentIdUUID(generateId(builtInComponentGVO.getComponentId(), eventData)); // //builtInComponentGVO.setWindowId(componentData[0]); // builtInComponentGVO.setWindowId(eventData.getParent()); // } // if (uuidSplit.length == 2) { // if (containsAttribute(componentData[1])) { // fillBuiltInComponentGVO(builtInComponentGVO, componentData[1]); // } else { // builtInComponentGVO.setComponentId(componentData[1]); // } // // builtInComponentGVO.setComponentIdUUID(builtInComponentGVO.getComponentId() + "|" + componentData[0] + "|" + uuidSplit[1]); // builtInComponentGVO.setWindowId(componentData[0]); // } // } else { // logger.info("The UUID is not of correct format at all:" + eventData.getUuid()); // } } componentIds.add(builtInComponentGVO); } out.setComponents(componentIds); } } }
From source file:ml.shifu.shifu.udf.stats.NumericalVarStats.java
@Override public void runVarStats(String binningInfo, DataBag databag) throws ExecException { String[] binningDataArr = StringUtils.split(binningInfo, CalculateStatsUDF.CATEGORY_VAL_SEPARATOR); log.info("Column Name - " + this.columnConfig.getColumnName() + ", Column Bin Length - " + binningDataArr.length);//from w w w . java2 s . c o m List<Double> binBoundary = new ArrayList<Double>(); for (String binningElement : binningDataArr) { binBoundary.add(Double.valueOf(binningElement)); } columnConfig.setBinBoundary(binBoundary); statsNumericalColumnInfo(databag, columnConfig); }
From source file:com.sinosoft.one.mvc.scanning.LoadScope.java
private void init(String loadScope, String defType) { if (StringUtils.isBlank(loadScope) || "*".equals(loadScope)) { return;//from w w w. j a va 2 s. c o m } loadScope = loadScope.trim(); String[] componetConfs = StringUtils.split(loadScope, ";"); for (String componetConf : componetConfs) { if (StringUtils.isBlank(loadScope)) { continue; } // "controllers=com.renren.xoa, com.renren.yourapp" componetConf = componetConf.trim(); int componetTypeIndex; String componetType = defType; // "controllers", "applicationContext", "dao", "messages", "*" String componetConfValue = componetConf; if ((componetTypeIndex = componetConf.indexOf('=')) != -1) { componetType = componetConf.substring(0, componetTypeIndex).trim(); componetConfValue = componetConf.substring(componetTypeIndex + 1).trim(); } if (componetType.startsWith("!")) { componetType = componetType.substring(1); } else { componetConfValue = componetConfValue + ", com.sinosoft.one.mvc"; } String[] packages = StringUtils.split(componetConfValue, ", \t\n\r\0");//\t this.load.put(componetType, packages); } }
From source file:com.alibaba.otter.node.etl.common.io.download.impl.aria2c.Aria2cDownload.java
protected void analyzeResult(Exec.Result result) { String[] results = StringUtils.split(result.getStdout(), SystemUtils.LINE_SEPARATOR); List<Aria2cStat> segmentStat = new ArrayList<Aria2cStat>(); int pos = 0;// w w w .j a v a2 s. c o m for (; pos < results.length; pos++) { if (true == results[pos].toLowerCase().startsWith("gid|stat")) { break; } } for (pos++; pos < results.length; pos++) { // ? // Download Results: // gid|stat|avg speed |path/URI // ===+====+===========+=========================================================== // 1| OK| 103.7KiB/s|./index.html // // Status Legend: // (OK):download completed. if (true == StringUtils.isNumeric(results[pos].substring(0, 1))) { // ????? String[] status = StringUtils.split(results[pos], " \t|"); if (status.length > 2) { if (StringUtils.equalsIgnoreCase(Aria2cStat.OK.name(), status[1])) { segmentStat.add(Aria2cStat.OK); } else if (StringUtils.equalsIgnoreCase(Aria2cStat.ERR.name(), status[1])) { segmentStat.add(Aria2cStat.ERR); } else if (StringUtils.equalsIgnoreCase(Aria2cStat.INPR.name(), status[1])) { segmentStat.add(Aria2cStat.INPR); } logger.warn(results[pos]); } else { logger.error("it seems aria2 changed it's status format: " + results[pos]); } } } int size = segmentStat.size(); int errCount = 0; int inprCount = 0; for (int i = 0; i < size; i++) { final Aria2cStat stat = segmentStat.get(i); if (Aria2cStat.ERR == stat) { errCount++; } else if (Aria2cStat.INPR == stat) { inprCount++; } } // ??? if (errCount == 0) { if (inprCount == 0) { // ? completed.set(true); } else { // ? paused.set(true); } } else { if (errCount == size) { // ? aborted.set(true); } else { // ?? paused.set(true); } } }