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.redhat.rhn.domain.rhnpackage.test.PackageEvrComparableTest.java
private String[] split(String evr) { String[] values = StringUtils.split(evr, "-"); for (int i = 0; i < values.length; i++) { if ("null".equals(values[i])) { values[i] = null;/* w w w .j a v a 2 s . c o m*/ } } return values; }
From source file:gov.nih.nci.cabig.caaers.web.validation.validator.WebControllerValidatorImpl.java
public void validate(final HttpServletRequest request, final Object command, final BindException errors) { Enumeration<String> propertyNames = request.getParameterNames(); while (propertyNames.hasMoreElements()) { String propertyName = propertyNames.nextElement(); validateProperty(propertyName, command, errors); }/*ww w . ja v a2 s.c o m*/ // figure out the additional collections to validate. String additionalCollections = request.getParameter(ADDITIONAL_COLLECTIONS_PARAM); if (StringUtils.isNotEmpty(additionalCollections)) { String collectionPropertyNames[] = StringUtils.split(additionalCollections, ','); for (String collectionPropertyName : collectionPropertyNames) { validateProperty(collectionPropertyName, command, errors); } } }
From source file:edu.uiowa.icts.datatable.DataTableRequest.java
/** * <p>getGenericDaoListOptions.</p> * * @return a {@link edu.uiowa.icts.spring.GenericDaoListOptions} object. *//*w ww. j a v a2 s .c o m*/ @JsonIgnore public GenericDaoListOptions getGenericDaoListOptions() { GenericDaoListOptions options = new GenericDaoListOptions(); if (this.columns != null) { if (individualSearch != null && individualSearch) { Map<String, List<Object>> likes = new HashMap<String, List<Object>>(); for (DataTableColumn column : this.columns) { if (column.getSearchable() != null && column.getSearchable()) { if (column.getSearch() != null && column.getSearch().getValue() != null) { List<Object> values = new ArrayList<Object>(); for (String splitSearchValue : StringUtils.split(column.getSearch().getValue(), ' ')) { values.add(splitSearchValue); } likes.put(column.getName(), values); } } } options.setLikes(likes); } else { List<String> searchColumns = new ArrayList<String>(); for (DataTableColumn column : this.columns) { if (column.getSearchable() != null && column.getSearchable()) { searchColumns.add(column.getName()); } } if (this.search != null) { options.setSearch(this.search.getValue()); } options.setSearchColumns(searchColumns); } } if (this.order != null) { List<SortColumn> sortColumns = new ArrayList<SortColumn>(); for (DataTableOrder dto : this.order) { if (dto.getColumn() < this.columns.size()) { DataTableColumn col = this.columns.get(dto.getColumn()); if (col != null && col.getSearchable() != null && col.getSearchable()) { sortColumns.add(new SortColumn(col.getName(), dto.getDir() == null ? "asc" : dto.getDir())); } } } options.setSorts(sortColumns); } options.setLimit(length); options.setStart(start); return options; }
From source file:com.onehippo.gogreen.login.HstConcurrentLoginFilter.java
@SuppressWarnings("unchecked") public void init(FilterConfig filterConfig) throws ServletException { ServletContext servletContext = filterConfig.getServletContext(); usernameHttpSessionWrapperMap = (Map<String, HttpSessionWrapper>) servletContext .getAttribute(USERNAME_SESSIONID_MAP_ATTR); if (usernameHttpSessionWrapperMap == null) { usernameHttpSessionWrapperMap = Collections.synchronizedMap(new HashMap<String, HttpSessionWrapper>()); servletContext.setAttribute(USERNAME_SESSIONID_MAP_ATTR, usernameHttpSessionWrapperMap); }/*from w w w . ja va2 s.c om*/ String[] disallowConcurrentLoginUsernamesArray = StringUtils .split(filterConfig.getInitParameter("disallowConcurrentLoginUsernames"), " ,\t\r\n"); if (disallowConcurrentLoginUsernamesArray != null && disallowConcurrentLoginUsernamesArray.length > 0) { disallowConcurrentLoginUsernames = new HashSet<String>( Arrays.asList(disallowConcurrentLoginUsernamesArray)); } log.info( "HstConcurrentLoginFilter's disallowConcurrentLoginUsernames: " + disallowConcurrentLoginUsernames); String[] allowConcurrentLoginUsernamesArray = StringUtils .split(filterConfig.getInitParameter("allowConcurrentLoginUsernames"), " ,\t\r\n"); if (allowConcurrentLoginUsernamesArray != null && allowConcurrentLoginUsernamesArray.length > 0) { allowConcurrentLoginUsernames = new HashSet<String>(Arrays.asList(allowConcurrentLoginUsernamesArray)); } earlySessionInvalidation = BooleanUtils .toBoolean(filterConfig.getInitParameter("earlySessionInvalidation")); log.info("HstConcurrentLoginFilter's allowConcurrentLoginUsernames: " + allowConcurrentLoginUsernames); }
From source file:com.manpowergroup.cn.core.orm.PropertyFilter.java
/** * @param filterName ,???. /*from w w w.j av a2s . co m*/ * eg LIKES_NAME_OR_LOGIN_NAME * @param value . */ public PropertyFilter(final String filterName, final Object value) { String matchTypeStr = StringUtils.substringBefore(filterName, "_"); String matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1); String propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1, matchTypeStr.length()); try { matchType = Enum.valueOf(MatchType.class, matchTypeCode); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } try { propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue(); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR); Assert.isTrue(propertyNames.length > 0, "filter??" + filterName + ",??."); this.propertyValue = value; }
From source file:com.qualogy.qafe.mgwt.server.helper.UIAssemblerHelper.java
public static void copyFields(Component component, Window currentWindow, ComponentGVO vo, ApplicationMapping applicationMapping, ApplicationContext context, SessionContainer sc) { if ((component != null) && (vo != null)) { vo.setId(component.getId());//from ww w . j a va2 s . co m vo.setFieldName(component.getFieldName()); vo.setGroup(component.getGroup()); vo.setTooltip(component.getTooltip()); vo.setMenu((MenuItemGVO) ComponentUIAssembler.convert(component.getMenu(), currentWindow, applicationMapping, context, sc)); if (vo.getMenu() != null) { manageMenuId(vo.getMenu(), component.getId()); } vo.setDisabled(component.getDisabled()); vo.setVisible(component.getVisible()); vo.setWidth(component.getWidth()); vo.setHeight(component.getHeight()); if (currentWindow != null) { vo.setWindow(currentWindow.getId()); } if (context != null) { vo.setContext(context.getId().toString()); } // Style vo.setStyleClass(component.getStyleClass()); String[] properties = StringUtils.split(component.getStyle() == null ? "" : component.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]); } vo.setStyleProperties(styleProperties); if (component instanceof EditableComponent) { if (vo instanceof EditableComponentGVO) { EditableComponent editableComponent = (EditableComponent) component; EditableComponentGVO editableComponentGVO = (EditableComponentGVO) vo; editableComponentGVO.setEditable(editableComponent.getEditable()); ConditionalStyle conditionalStyle = editableComponent.getConditionalStyleRef(); if (conditionalStyle != null) { editableComponentGVO .setConditionalStyleRef(ConditionalStyleUIAssembler.convert(conditionalStyle)); } } } if (component instanceof HasVisibleText && vo instanceof HasVisibleTextI) { HasVisibleText hasVisibleText = (HasVisibleText) component; HasVisibleTextI hasVisibleTextI = (HasVisibleTextI) vo; if (hasVisibleText.getMessageKey() != null && hasVisibleText.getMessageKey().length() > 0) { if (ApplicationCluster.getInstance().get(applicationMapping) != null) { DataIdentifier dataId = DataStore.register(); DataStore.store(dataId, DataStore.KEY_LOCALE, sc.getLocale()); hasVisibleTextI.setDisplayname(MessagesHandler.getMessage(applicationMapping, dataId, hasVisibleText.getMessageKey(), hasVisibleText.getDisplayname())); DataStore.unregister(dataId); } else { hasVisibleTextI.setDisplayname(hasVisibleText.getDisplayname()); } } else { hasVisibleTextI.setDisplayname(hasVisibleText.getDisplayname()); } } if (component instanceof HasRequiredProperty && vo instanceof HasRequired) { ((HasRequired) vo).setRequired(((HasRequiredProperty) component).getRequired()); } } }
From source file:info.magnolia.setup.for4_5.RenameACLNodesTask.java
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { Session session = installContext.getJCRSession(RepositoryConstants.USER_ROLES); for (Node roleNode : NodeUtil.getNodes(session.getRootNode(), NodeTypes.Role.NAME)) { for (Node aclNode : NodeUtil.getNodes(roleNode, NodeTypes.ContentNode.NAME)) { String nodeName = aclNode.getName(); if (nodeName.startsWith("acl_") && nodeName.substring(4).contains("_")) { String[] tokens = StringUtils.split(nodeName, "_"); if (tokens.length == 3) { String newName = "acl_" + tokens[2]; log.info("Renaming ACL node {} to {}", aclNode.getPath(), newName); NodeUtil.renameNode(aclNode, newName); }/* w w w . ja v a2 s . c o m*/ } } } }
From source file:com.ctriposs.rest4j.internal.server.util.MIMEParse.java
/** * Carves up a mime-type and returns a ParseResults object * * For example, the media range 'application/xhtml;q=0.5' would get parsed * into:/* w w w. j a v a 2 s . c o m*/ * * ('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("*")) fullType = "*/*"; String[] types = StringUtils.split(fullType, "/"); if (types.length != 2) { throw new InvalidMimeTypeException(mimeType); } results.type = types[0].trim(); results.subType = types[1].trim(); return results; }
From source file:com.netflix.raigad.defaultimpl.StandardTuner.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public void writeAllProperties(String yamlLocation, String hostname) throws IOException { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); Yaml yaml = new Yaml(options); File yamlFile = new File(yamlLocation); Map map = (Map) yaml.load(new FileInputStream(yamlFile)); map.put("cluster.name", config.getAppName()); map.put("node.name", config.getRac() + "." + config.getInstanceId()); map.put("http.port", config.getHttpPort()); map.put("path.data", config.getDataFileLocation()); map.put("path.logs", config.getLogFileLocation()); map.put("transport.tcp.port", config.getTransportTcpPort()); if (config.isKibanaSetupRequired()) { map.put("http.cors.enabled", true); map.put("http.cors.allow-origin", "*"); }//from ww w. j a va 2s . c o m if (config.amITribeNode()) { String clusterParams = config.getCommaSeparatedSourceClustersForTribeNode(); assert (clusterParams != null) : "Source Clusters for Tribe Nodes can't be null"; String[] clusters = StringUtils.split(clusterParams, COMMA_SEPARATOR); assert (clusters.length != 0) : "One or more clusters needed"; //Common Settings for (int i = 0; i < clusters.length; i++) { String[] clusterPort = clusters[i].split(PARAM_SEPARATOR); assert (clusterPort.length != 2) : "Cluster Name or Transport Port is missing in configuration"; map.put("tribe.t" + i + ".cluster.name", clusterPort[0]); map.put("tribe.t" + i + ".transport.tcp.port", Integer.parseInt(clusterPort[1])); map.put("tribe.t" + i + ".discovery.type", config.getElasticsearchDiscoveryType()); logger.info("Adding Cluster = <{}> with Port = <{}>", clusterPort[0], clusterPort[1]); } map.put("node.master", false); map.put("node.data", false); if (config.isMultiDC()) { map.put("network.publish_host", config.getHostIP()); } if (config.amIWriteEnabledTribeNode()) map.put("tribe.blocks.write", false); else map.put("tribe.blocks.write", true); if (config.amIMetadataEnabledTribeNode()) map.put("tribe.blocks.metadata", false); else map.put("tribe.blocks.metadata", true); } else { map.put("discovery.type", config.getElasticsearchDiscoveryType()); map.put("discovery.zen.minimum_master_nodes", config.getMinimumMasterNodes()); map.put("index.number_of_shards", config.getNumOfShards()); map.put("index.number_of_replicas", config.getNumOfReplicas()); map.put("index.refresh_interval", config.getIndexRefreshInterval()); //NOTE: When using awareness attributes, shards will not be allocated to nodes //that do not have values set for those attributes. //*** Important in dedicated master nodes deployment map.put("cluster.routing.allocation.awareness.attributes", config.getClusterRoutingAttributes()); if (config.isShardPerNodeEnabled()) map.put("index.routing.allocation.total_shards_per_node", config.getTotalShardsPerNode()); if (config.isMultiDC()) { map.put("node.rack_id", config.getDC()); map.put("network.publish_host", config.getHostIP()); } else if (config.amISourceClusterForTribeNodeInMultiDC()) { map.put("node.rack_id", config.getRac()); map.put("network.publish_host", config.getHostIP()); } else { map.put("node.rack_id", config.getRac()); } //TODO: Create New Tuner for ASG Based Deployment //TODO: Need to come up with better algorithm for Non-ASG based deployments if (config.isAsgBasedDedicatedDeployment()) { if (config.getASGName().toLowerCase().contains("master")) { map.put("node.master", true); map.put("node.data", false); } else if (config.getASGName().toLowerCase().contains("data")) { map.put("node.master", false); map.put("node.data", true); } else if (config.getASGName().toLowerCase().contains("search")) { map.put("node.master", false); map.put("node.data", false); } } } addExtraEsParams(map); logger.info(yaml.dump(map)); yaml.dump(map, new FileWriter(yamlFile)); }
From source file:com.pcms.core.util.UrlUtil.java
/** * /* ww w. ja v a 2 s. c o m*/ * * @param uri URI {@link HttpServletRequest#getRequestURI()} * @return */ public static String[] getPaths(String uri) { if (uri == null) { throw new IllegalArgumentException("URI can not be null"); } if (!uri.startsWith("/")) { throw new IllegalArgumentException("URI must start width '/'"); } int bi = uri.indexOf("_"); int mi = uri.indexOf("-"); int pi = uri.indexOf("."); // ? String pathStr; if (bi != -1) { pathStr = uri.substring(0, bi); } else if (mi != -1) { pathStr = uri.substring(0, mi); } else if (pi != -1) { pathStr = uri.substring(0, pi); } else { pathStr = uri; } String[] paths = StringUtils.split(pathStr, '/'); return paths; }