List of usage examples for java.util StringTokenizer StringTokenizer
public StringTokenizer(String str, String delim)
From source file:com.blackducksoftware.integration.hub.detect.util.filter.DetectOverrideableFilter.java
private Set<String> createSetFromString(final String s) { final Set<String> set = new HashSet<>(); final StringTokenizer stringTokenizer = new StringTokenizer(StringUtils.trimToEmpty(s), ","); while (stringTokenizer.hasMoreTokens()) { set.add(StringUtils.trimToEmpty(stringTokenizer.nextToken())); }// w ww. j ava2 s . co m return set; }
From source file:StringUtils.java
public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) { StringTokenizer st = new StringTokenizer(str, delimiters); List tokens = new ArrayList(); while (st.hasMoreTokens()) { String token = st.nextToken(); if (trimTokens) { token = token.trim();/* w w w . j a v a 2s . c o m*/ } if (!ignoreEmptyTokens || token.length() > 0) { tokens.add(token); } } return toStringArray(tokens); }
From source file:com.flipkart.poseidon.handlers.http.utils.StringUtils.java
/** * Gets the query parameters from the URL * @param httpUrl The URL from which query params have to be extracted * @return /*from w w w . j a va 2 s.c om*/ */ public static Map<String, String> getQueryParams(String httpUrl) { Map<String, String> params = new HashMap<String, String>(); if (httpUrl == null) { return params; } URL url = null; try { url = new URL(httpUrl); } catch (MalformedURLException e) { throw new RuntimeException(e); } String query = url.getQuery(); if (query == null) { return params; } StringTokenizer tokenizer = new StringTokenizer(query, "&"); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); int index = token.indexOf("="); params.put(token.substring(0, index).trim(), token.substring(index + 1).trim()); } return params; }
From source file:com.glaf.base.tag.PermissionTag.java
public int doStartTag() { String userId = RequestUtils.getActorId((HttpServletRequest) super.pageContext.getRequest()); AuthorizeBean bean = new AuthorizeBean(); SysUser user = bean.getUser(userId); boolean hasPermission = false; StringTokenizer token = new StringTokenizer(key, ","); Collection<String> roleIds = new java.util.ArrayList<String>(); Collection<String> permissions = new java.util.ArrayList<String>(); if (user != null) { if (user.isSystemAdmin()) { return 1; }// ww w. j av a 2s . co m Set<SysDeptRole> roles = user.getRoles(); if (roles != null && !roles.isEmpty()) { for (SysDeptRole dr : roles) { if (dr.getRole() != null) { roleIds.add(dr.getRole().getCode()); } } } } logger.debug("roleIds:" + roleIds); logger.debug("permissions:" + permissions); logger.debug("key:" + key); if (operator != null) { if ((operator.equals("||") || operator.equals("or"))) { while (token.hasMoreTokens()) { String permKey = token.nextToken(); if (roleIds != null && permissions != null) { if (permissions.contains(permKey) || roleIds.contains(permKey)) { hasPermission = true; } } } } } else { if (roleIds != null && permissions != null) { while (token.hasMoreTokens()) { String permKey = token.nextToken(); if (permissions.contains(permKey) || roleIds.contains(permKey)) { hasPermission = true; } } } } return hasPermission ? 1 : 0; }
From source file:com.canoo.webtest.plugins.emailtest.EmailMessageStructureFilter.java
private void prepareHeaders() { final StringTokenizer tokens = new StringTokenizer(getHeaders(), " ,"); fTokenizedHeaders = new String[tokens.countTokens()]; for (int i = 0; i < fTokenizedHeaders.length; i++) { fTokenizedHeaders[i] = tokens.nextToken(); }/* w w w. j av a 2 s . c o m*/ }
From source file:de.innovationgate.webgate.api.jdbc.custom.KeyMap.java
/** * @param key//w w w . ja v a2 s .co m */ public KeyMap(JDBCSource jdbcSource, String key, String folder) throws ParseException { super(); List keyColumns = (List) jdbcSource.getTables().get(folder); if (keyColumns == null) { throw new IllegalArgumentException("Table " + folder + " does not exist or has no primary key"); } StringTokenizer tokens = new StringTokenizer(key, "--"); int idx = 0; while (tokens.hasMoreTokens()) { String token = tokens.nextToken(); char dataType = token.charAt(0); String valueStr = token.substring(1); Object value = null; if (dataType == '#') { value = NUMBER_FORMATTER.parse(WGUtils.strReplace(valueStr, "D", ".", true)); } else if (dataType == '*') { value = Timestamp.valueOf(valueStr); } else { value = valueStr; } put(keyColumns.get(idx), value); idx++; } }
From source file:com.chinamobile.bcbsp.examples.simrank.SRRecordParse.java
/** * This method is used to parse a record and obtain VertexID . * @param key The key of the vertex record * @return the vertex id//from w ww.jav a 2 s. co m */ public Text getVertexID(Text key) { try { StringTokenizer str = new StringTokenizer(key.toString(), ":"); if (str.countTokens() != 3) { return null; } return new Text(str.nextToken()); } catch (Exception e) { return null; } }
From source file:de.erdesignerng.dialect.GenericDataTypeImpl.java
protected GenericDataTypeImpl(String aName, String aDefinition, int... aJdbcType) { name = aName;// w w w. j ava2s . co m definition = aDefinition; jdbcType = aJdbcType; for (StringTokenizer theST = new StringTokenizer(aDefinition.trim(), ","); theST.hasMoreTokens();) { String theToken = theST.nextToken().trim(); // Bug Fixing 2876916 [ERDesignerNG] Reverse-Eng. PgSQL VARCHAR // max-length wrong // to also match optional tokens theToken = theToken.replace("[", "").replace("]", ""); if (SIZE_TOKEN.equals(theToken)) { supportsSize = true; } else { if (FRACTION_TOKEN.equals(theToken)) { supportsFraction = true; } else { if (SCALE_TOKEN.equals(theToken)) { supportsScale = true; } else { if (EXTRA_TOKEN.equals(theToken)) { supportsExtra = true; } else { throw new IllegalArgumentException("Invalid Token : " + theToken); } } } } } }
From source file:com.qframework.core.ItemFactory.java
LayoutItem createItem(String type, LayoutItem item) { try {/*from w w w .java2 s . c om*/ StringTokenizer tok = new StringTokenizer(type, "."); String imageset = tok.nextToken(); //String imagetype = tok.nextToken(); GameonModel model = mModels.get(imageset); if (model == null) { return null; } int imageid = -1; if (tok.hasMoreTokens()) imageid = Integer.parseInt(tok.nextToken()); return createItemFromModel(model, imageid, item); } catch (NoSuchElementException e) { return null; } }
From source file:com.chinamobile.bcbsp.ml.RecordParseML.java
/** * This method is used to parse a record and obtain VertexID . * @param key The key of the vertex record * @return the vertex id/*w w w . j a v a2 s.c o m*/ */ @Override public Text getVertexID(Text key) { try { StringTokenizer str = new StringTokenizer(key.toString(), Constants.SPLIT_FLAG); if (str.countTokens() < 1) { return null; } return new Text(str.nextToken()); } catch (Exception e) { return null; } }