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.manydesigns.portofino.dispatcher.Dispatcher.java
/** * Returns a dispatch for the provided path. * @param path the path to resolve, not including the context path. * @return the dispatch. If no dispatch can be constructed, this method returns null. *///w w w.j ava 2s. c o m public Dispatch getDispatch(String path) { if (path.endsWith(".jsp")) { logger.debug("Path is a JSP page ({}), not dispatching.", path); return null; } path = normalizePath(path); Dispatch dispatch = cache.get(path); if (dispatch != null) { return dispatch; } int index; String subPath = path; while ((index = subPath.lastIndexOf('/')) != -1) { subPath = path.substring(0, index); dispatch = cache.get(subPath); if (dispatch != null) { break; } } if (dispatch == null) { List<PageInstance> pagePath = new ArrayList<PageInstance>(); String[] fragments = StringUtils.split(path, '/'); List<String> fragmentsAsList = Arrays.asList(fragments); ListIterator<String> fragmentsIterator = fragmentsAsList.listIterator(); File rootDir = pagesDirectory; Page rootPage; try { rootPage = DispatcherLogic.getPage(rootDir); } catch (Exception e) { logger.error("Cannot load root page", e); return null; } PageInstance rootPageInstance = new PageInstance(null, rootDir, rootPage, null); pagePath.add(rootPageInstance); dispatch = getDispatch(pagePath, fragmentsIterator); if (dispatch != null) { cache.put(path, dispatch); } return dispatch; } else { List<PageInstance> pagePath = new ArrayList<PageInstance>( Arrays.asList(dispatch.getPageInstancePath())); String[] fragments = StringUtils.split(path.substring(subPath.length()), '/'); List<String> fragmentsAsList = Arrays.asList(fragments); ListIterator<String> fragmentsIterator = fragmentsAsList.listIterator(); dispatch = getDispatch(pagePath, fragmentsIterator); if (dispatch != null) { cache.put(path, dispatch); } return dispatch; } }
From source file:com.alibaba.otter.manager.biz.monitor.impl.ExceptionRuleMonitor.java
private void check(AlarmRule rule, NodeAlarmEvent alarmEvent) { if (!inPeriod(rule)) { return;/*from ww w.jav a 2 s. com*/ } String matchValue = rule.getMatchValue(); matchValue = StringUtils.substringBeforeLast(matchValue, "@"); String[] matchValues = StringUtils.split(matchValue, ","); for (String match : matchValues) { if (StringUtils.containsIgnoreCase(alarmEvent.getMessage(), match)) { String message = String.format(MESAGE_FORMAT, alarmEvent.getPipelineId(), alarmEvent.getNid(), alarmEvent.getMessage()); sendAlarm(rule, message); break; } } }
From source file:com.googlecode.jmxtrans.model.output.StatsDTelegrafWriterFactory.java
public StatsDTelegrafWriterFactory(@JsonProperty("bucketType") String bucketType, @JsonProperty("host") String host, @JsonProperty("port") Integer port, @JsonProperty("tags") ImmutableMap<String, String> tags, @JsonProperty("resultTags") List<String> resultTags, @JsonProperty("flushStrategy") String flushStrategy, @JsonProperty("flushDelayInSeconds") Integer flushDelayInSeconds, @JsonProperty("poolSize") Integer poolSize) { this.bucketTypes = StringUtils.split(firstNonNull(bucketType, "c"), ","); this.server = new InetSocketAddress(checkNotNull(host, "Host cannot be null."), checkNotNull(port, "Port cannot be null.")); this.resultAttributesToWriteAsTags = initResultAttributesToWriteAsTags(resultTags); this.tags = initCustomTagsMap(tags); this.flushStrategy = createFlushStrategy(flushStrategy, flushDelayInSeconds); this.poolSize = firstNonNull(poolSize, 1); }
From source file:com.thoughtworks.go.server.web.TabInterceptor.java
String[] urlToParams(String url) { String[] params = StringUtils.split(StringUtils.defaultString(url), '/'); String[] decodedParams = new String[params.length]; for (int i = 0; i < params.length; i++) { decodedParams[i] = decode(params[i]); }//from www. j a v a 2 s.c om return decodedParams; }
From source file:com.linkedin.pinot.core.data.readers.CSVRecordReader.java
@Override public GenericRow next() { CSVRecord record = _iterator.next(); Map<String, Object> fieldMap = new HashMap<String, Object>(); for (final FieldSpec fieldSpec : _schema.getAllFieldSpecs()) { String column = fieldSpec.getName(); String token = getValueForColumn(record, column); Object value = null;/*from w ww .j a v a2s. c o m*/ if (token == null || token.isEmpty()) { incrementNullCountFor(fieldSpec.getName()); } if (fieldSpec.isSingleValueField()) { value = RecordReaderUtils.convertToDataType(token, fieldSpec.getDataType()); } else { String[] tokens = (token != null) ? StringUtils.split(token, _delimiterString) : null; value = RecordReaderUtils.convertToDataTypeArray(tokens, fieldSpec.getDataType()); } fieldMap.put(column, value); } GenericRow genericRow = new GenericRow(); genericRow.init(fieldMap); return genericRow; }
From source file:com.mirth.connect.server.util.SMTPConnection.java
public void send(String toList, String ccList, String from, String subject, String body) throws EmailException { Email email = new SimpleEmail(); email.setHostName(host);/*from w w w . j ava 2s . c o m*/ email.setSmtpPort(Integer.parseInt(port)); email.setSocketConnectionTimeout(socketTimeout); email.setDebug(true); if (useAuthentication) { email.setAuthentication(username, password); } if (StringUtils.equalsIgnoreCase(secure, "TLS")) { email.setTLS(true); } else if (StringUtils.equalsIgnoreCase(secure, "SSL")) { email.setSSL(true); } for (String to : StringUtils.split(toList, ",")) { email.addTo(to); } if (StringUtils.isNotEmpty(ccList)) { for (String cc : StringUtils.split(ccList, ",")) { email.addCc(cc); } } email.setFrom(from); email.setSubject(subject); email.setMsg(body); email.send(); }
From source file:mysoft.sonar.plugins.web.check.StyleAttributeRegExpCheck.java
private HashMap<String, String> GetStyles(TagNode node) { HashMap<String, String> hash = new HashMap<String, String>(); String inlineStyle = node.getAttribute("style"); if (StringUtils.isEmpty(inlineStyle)) return hash; String[] styles = StringUtils.split(inlineStyle, ";"); if (styles.length <= 0) return hash; for (String style : styles) { if (StringUtils.isEmpty(style)) continue; if (!style.contains(":")) continue; String[] pair = StringUtils.split(style, ":"); if (pair.length != 2) continue; hash.put(pair[0].trim(), pair[1].trim()); }/*from w ww. j av a2s.c om*/ return hash; }
From source file:com.flexive.faces.FxJsf1Utils.java
/** * Workaround for facelets component tree update problems - deletes * the given components and its children so they can be recreated * when the component tree is rendered again. * Prefixes component ids with the given form prefix. * (e.g prefix "frm" and componentId "queryEditor" result in "frm:queryEditor") * * @param formPrefix the form prefix, e.g. frm * @param componentIds comma separated component ids, e.g. queryEditor, contentEditor *//*from ww w . j a va2s .co m*/ public static void resetFaceletsComponents(String formPrefix, String componentIds) { if (StringUtils.isBlank(componentIds)) { return; } if (StringUtils.isEmpty(formPrefix)) { resetFaceletsComponents(componentIds); } else { String[] ids = StringUtils.split(componentIds, ","); for (String id : ids) { resetFaceletsComponent(formPrefix.trim() + NamingContainer.SEPARATOR_CHAR + id.trim()); } } }