Java Code Examples for org.apache.commons.lang.text.StrTokenizer#hasNext()
The following examples show how to use
org.apache.commons.lang.text.StrTokenizer#hasNext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IpUtil.java From bootshiro with MIT License | 6 votes |
public static String getIpFromRequest(HttpServletRequest request) { String ip; boolean found = false; if ((ip = request.getHeader(X_FORWARDED_FOR)) != null) { StrTokenizer tokenizer = new StrTokenizer(ip, ","); while (tokenizer.hasNext()) { ip = tokenizer.nextToken().trim(); if (isIPv4Valid(ip) && !isIPv4Private(ip)) { found = true; break; } } } if (!found) { ip = request.getRemoteAddr(); } return ip; }
Example 2
Source File: DBConfiguration.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 6 votes |
/** * Converts a String back to connection parameters. * @param input String from configuration * @return JDBC connection parameters */ protected static Properties propertiesFromString(String input) { if (input != null && !input.isEmpty()) { Properties result = new Properties(); StrTokenizer propertyTokenizer = StrTokenizer.getCSVInstance(input); StrTokenizer valueTokenizer = StrTokenizer.getCSVInstance(); valueTokenizer.setDelimiterChar('='); while (propertyTokenizer.hasNext()){ valueTokenizer.reset(propertyTokenizer.nextToken()); String[] values = valueTokenizer.getTokenArray(); if (values.length==2) { result.put(values[0], values[1]); } } return result; } else { return null; } }
Example 3
Source File: MessageStoreListener.java From iaf with Apache License 2.0 | 6 votes |
@Override public Object getRawMessage(Map threadContext) throws ListenerException { Object rawMessage = super.getRawMessage(threadContext); if (rawMessage != null && sessionKeys != null) { MessageWrapper messageWrapper = (MessageWrapper)rawMessage; try { StrTokenizer strTokenizer = StrTokenizer.getCSVInstance().reset(messageWrapper.getMessage().asString()); messageWrapper.setMessage(new Message((String)strTokenizer.next())); int i = 0; while (strTokenizer.hasNext()) { threadContext.put(sessionKeysList.get(i), strTokenizer.next()); i++; } } catch (IOException e) { throw new ListenerException("cannot convert message",e); } } return rawMessage; }
Example 4
Source File: UriTemplate.java From cosmo with Apache License 2.0 | 5 votes |
public UriTemplate(String pattern) { this.pattern = pattern; this.segments = new ArrayList<Segment>(); StrTokenizer tokenizer = new StrTokenizer(pattern, '/'); while (tokenizer.hasNext()) { segments.add(new Segment(tokenizer.nextToken())); } }