use of java.util.StringTokenizer in project che by eclipse.
the class NonDeprecatedFilter method decodeFiltersString.
private static JavaMatchFilter[] decodeFiltersString(String encodedString) {
StringTokenizer tokenizer = new StringTokenizer(encodedString, String.valueOf(';'));
HashSet<JavaMatchFilter> result = new HashSet<JavaMatchFilter>();
while (tokenizer.hasMoreTokens()) {
JavaMatchFilter curr = findMatchFilter(tokenizer.nextToken());
if (curr != null) {
result.add(curr);
}
}
return result.toArray(new JavaMatchFilter[result.size()]);
}
use of java.util.StringTokenizer in project hackpad by dropbox.
the class ScriptableOutputStream method lookupQualifiedName.
static Object lookupQualifiedName(Scriptable scope, String qualifiedName) {
StringTokenizer st = new StringTokenizer(qualifiedName, ".");
Object result = scope;
while (st.hasMoreTokens()) {
String s = st.nextToken();
result = ScriptableObject.getProperty((Scriptable) result, s);
if (result == null || !(result instanceof Scriptable))
break;
}
return result;
}
use of java.util.StringTokenizer in project jodd by oblac.
the class LoggableAdvice method getQueryString.
// ---------------------------------------------------------------- additional methods
/**
* Returns the query string.
*/
public String getQueryString() {
if (sqlTemplate == null) {
return toString();
}
if (parameterValues == null) {
return sqlTemplate;
}
StringBuilder sb = new StringBuilder();
int qMarkCount = 0;
StringTokenizer tok = new StringTokenizer(sqlTemplate + ' ', "?");
while (tok.hasMoreTokens()) {
String oneChunk = tok.nextToken();
sb.append(oneChunk);
try {
Object value;
if (parameterValues.size() > 1 + qMarkCount) {
value = parameterValues.get(1 + qMarkCount);
qMarkCount++;
} else {
if (tok.hasMoreTokens()) {
value = null;
} else {
value = "";
}
}
sb.append(value);
} catch (Throwable th) {
sb.append("--- Building query failed: ").append(th.toString());
}
}
return sb.toString().trim();
}
use of java.util.StringTokenizer in project openhab1-addons by openhab.
the class BaseStation method eventOccured.
/**
* {@inheritDoc}
*
* handles new events send from the smarthomatic basestation to openhab
*/
@Override
public void eventOccured(String message) {
// Filter out the lines that contain garbage data
if (message.contains("(CRC wrong after decryption)")) {
logger.debug("BaseStation eventOccured: CRC wrong after decryption");
return;
}
if (message.contains("Base Station")) {
StringTokenizer strTok = new StringTokenizer(message, "\n");
String data = null;
versionInfo = new String[strTok.countTokens()];
logger.debug("BaseStation eventOccured - initial message ( {} )", strTok.countTokens());
int i = 0;
while (strTok.hasMoreTokens()) {
versionInfo[i] = strTok.nextToken();
logger.debug("<BaseStation>[ {} ]: {}", i, versionInfo[i]);
i++;
}
} else {
String logResult = message.replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r").substring(0, 40);
logger.debug("BaseStation eventOccured - giving to Binding {}", logResult);
if (bindingEventWorker != null) {
bindingEventWorker.eventOccured(message);
}
}
}
use of java.util.StringTokenizer in project openhab1-addons by openhab.
the class SmarthomaticGenericBindingProvider method parseConfig.
private SmarthomaticBindingConfig parseConfig(Item item, String bindingConfig) throws BindingConfigParseException {
SmarthomaticBindingConfig config = new SmarthomaticBindingConfig();
Matcher matcher = CONFIG_PATTERN.matcher(bindingConfig);
if (!matcher.matches()) {
throw new BindingConfigParseException("Config for item '" + item.getName() + "' could not be parsed.");
}
bindingConfig = matcher.group(1);
config.setItemName(item.getName());
config.setItem(item);
matcher = TRANSFORMATION_PATTERN.matcher(bindingConfig);
if (matcher.matches()) {
bindingConfig = matcher.group(1);
String transformation = matcher.group(2);
config.getConfigParams().put("transformation", transformation);
}
// parse bindingconfig here ...
StringTokenizer confItems = new StringTokenizer(bindingConfig, ",");
while (confItems.hasMoreTokens()) {
String[] token = confItems.nextToken().split("=");
String key = token[0];
String value = token[1];
config.getConfigParams().put(key, value);
// Strip all whitespaces from token[0]
key = key.replaceAll("\\s", "");
if ("deviceId".equals(key)) {
config.setDeviceId(value.replaceAll("\\s", ""));
} else if ("messageGroupId".equals(key)) {
config.setMessageGroupId(value.replaceAll("\\s", ""));
} else if ("messageId".equals(key)) {
config.setMessageId(value.replaceAll("\\s", ""));
} else if ("messagePart".equals(key)) {
config.setMessagePartId(value.replaceAll("\\s", ""));
} else if ("messageItem".equals(key)) {
config.setMessageItemId(value.replaceAll("\\s", ""));
}
}
return config;
}
Aggregations