Search in sources :

Example 76 with StringTokenizer

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()]);
}
Also used : StringTokenizer(java.util.StringTokenizer) HashSet(java.util.HashSet)

Example 77 with StringTokenizer

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;
}
Also used : StringTokenizer(java.util.StringTokenizer)

Example 78 with StringTokenizer

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();
}
Also used : StringTokenizer(java.util.StringTokenizer)

Example 79 with StringTokenizer

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);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer)

Example 80 with StringTokenizer

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) Matcher(java.util.regex.Matcher) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException)

Aggregations

StringTokenizer (java.util.StringTokenizer)4881 ArrayList (java.util.ArrayList)1083 IOException (java.io.IOException)506 File (java.io.File)392 BufferedReader (java.io.BufferedReader)380 HashMap (java.util.HashMap)375 HashSet (java.util.HashSet)263 FileReader (java.io.FileReader)224 List (java.util.List)200 InputStreamReader (java.io.InputStreamReader)191 Map (java.util.Map)152 FileInputStream (java.io.FileInputStream)135 Iterator (java.util.Iterator)114 Set (java.util.Set)114 URL (java.net.URL)108 NoSuchElementException (java.util.NoSuchElementException)90 Properties (java.util.Properties)84 InputStream (java.io.InputStream)83 BufferedWriter (java.io.BufferedWriter)80 FileNotFoundException (java.io.FileNotFoundException)78