Example usage for java.util StringTokenizer hasMoreTokens

List of usage examples for java.util StringTokenizer hasMoreTokens

Introduction

In this page you can find the example usage for java.util StringTokenizer hasMoreTokens.

Prototype

public boolean hasMoreTokens() 

Source Link

Document

Tests if there are more tokens available from this tokenizer's string.

Usage

From source file:com.salesmanager.core.util.MerchantConfigurationUtil.java

public static IntegrationProperties getIntegrationProperties(String configurationValue, String delimiter) {
    if (configurationValue == null)
        return new IntegrationProperties();
    StringTokenizer st = new StringTokenizer(configurationValue, delimiter);
    int i = 1;/*from w  w w .  ja v  a 2 s .c  om*/
    IntegrationProperties keys = new IntegrationProperties();
    while (st.hasMoreTokens()) {
        String value = st.nextToken();
        if (i == 1) {
            keys.setProperties1(value);
        } else if (i == 2) {
            keys.setProperties2(value);
        } else if (i == 3) {
            keys.setProperties3(value);
        } else if (i == 4) {
            keys.setProperties4(value);
        } else {
            keys.setProperties5(value);
        }

        i++;
    }
    return keys;
}

From source file:com.fiveamsolutions.nci.commons.web.struts2.validator.HibernateValidator.java

private static Set<String> parseList(String list) {
    if (StringUtils.isBlank(list)) {
        return null;
    }//from w w w  . j  a  va 2 s. c  o  m
    HashSet<String> names = new HashSet<String>();
    StringTokenizer st = new StringTokenizer(list, ",");
    while (st.hasMoreTokens()) {
        String n = st.nextToken().trim();
        if (StringUtils.isNotBlank(n)) {
            names.add(n);
        }
    }
    return !names.isEmpty() ? names : null;
}

From source file:com.collabnet.ccf.pi.qc.v90.QCRequirement.java

public static List<String> getFieldValues(String fieldValue) {

    List<String> fieldValues = new ArrayList<String>();
    StringTokenizer st = new StringTokenizer(fieldValue, ";");
    while (st.hasMoreTokens()) {
        String thisFieldValue = st.nextToken();
        fieldValues.add(thisFieldValue);
    }//from   w  w  w . j a va 2 s.  c o m
    return fieldValues;
}

From source file:com.salesmanager.core.util.MerchantConfigurationUtil.java

public static IntegrationKeys getIntegrationKeys(String configvalue, String delimiter) throws Exception {
    if (configvalue == null)
        return new IntegrationKeys();
    StringTokenizer st = new StringTokenizer(configvalue, delimiter);
    int i = 1;//from w  w  w  .  java2s .  co m
    int j = 1;
    IntegrationKeys keys = new IntegrationKeys();
    while (st.hasMoreTokens()) {
        String value = st.nextToken();

        if (i == 1) {
            // decrypt
            keys.setUserid(value);
        } else if (i == 2) {
            // decrypt
            keys.setPassword(value);
        } else if (i == 3) {
            // decrypt
            keys.setTransactionKey(value);
        } else {
            if (j == 1) {
                keys.setKey1(value);
            } else if (j == 2) {
                keys.setKey2(value);
            } else if (j == 3) {
                keys.setKey3(value);
            }
            j++;
        }
        i++;
    }
    return keys;
}

From source file:LocaleMap.java

public static Locale parseLocale(String localeString) {
    StringTokenizer localeParser = new StringTokenizer(localeString, "-_");

    String lang = null, country = null, variant = null;

    if (localeParser.hasMoreTokens())
        lang = localeParser.nextToken();
    if (localeParser.hasMoreTokens())
        country = localeParser.nextToken();
    if (localeParser.hasMoreTokens())
        variant = localeParser.nextToken();

    if (lang != null && country != null && variant != null)
        return new Locale(lang, country, variant);
    else if (lang != null && country != null)
        return new Locale(lang, country);
    else if (lang != null)
        return new Locale(lang);
    else//from  w  w w. j av a2  s .c om
        return new Locale("");
}

From source file:com.cburch.logisim.util.LocaleManager.java

private static HashMap<Character, String> fetchReplaceAccents() {
    HashMap<Character, String> ret = null;
    String val;
    try {/*from  w  w  w .j  a  v a 2 s  .co  m*/
        val = LocaleString.getUtilLocaleManager().locale.getString("accentReplacements");
    } catch (MissingResourceException e) {
        return null;
    }
    StringTokenizer toks = new StringTokenizer(val, "/");
    while (toks.hasMoreTokens()) {
        String tok = toks.nextToken().trim();
        char c = '\0';
        String s = null;
        if (tok.length() == 1) {
            c = tok.charAt(0);
            s = "";
        } else if (tok.length() >= 2 && tok.charAt(1) == ' ') {
            c = tok.charAt(0);
            s = tok.substring(2).trim();
        }
        if (s != null) {
            if (ret == null)
                ret = new HashMap<Character, String>();
            ret.put(new Character(c), s);
        }
    }
    return ret;
}

From source file:com.googlecode.jcimd.charset.GsmCharsetProvider.java

private static int init(BufferedReader reader) throws IOException {
    String line = null;/*ww w . j a v a2 s.  com*/
    int count = 0;
    while ((line = reader.readLine()) != null) {
        if (line.startsWith("#")) {
            if (logger.isTraceEnabled()) {
                logger.trace("Skipping line starting with '#': " + line);
            }
            continue;
        }
        StringTokenizer tokenizer = new StringTokenizer(line, "\t");
        String hex1 = null;
        String hex2 = null;
        if (tokenizer.hasMoreTokens()) {
            hex1 = tokenizer.nextToken();
        }
        if (tokenizer.hasMoreTokens()) {
            hex2 = tokenizer.nextToken();
        }
        if (hex1 == null || hex2 == null) {
            continue;
        }
        int bite = Integer.parseInt(hex1.substring(2), 16);
        byte index = (byte) (bite & 0xFF);
        char ch = (char) Integer.parseInt(hex2.substring(2), 16);
        CHAR_TO_BYTE_SMALL_C_CEDILLA[ch] = bite;
        if ((bite & 0xFF00) >> 8 == ESCAPE) {
            // escape to extension table
            BYTE_TO_CHAR_ESCAPED_DEFAULT[index] = ch;
            if (logger.isTraceEnabled()) {
                logger.trace(String.format("(escaped) %d == %s", index, (ch != 10 && ch != 12 && ch != 13) ? ch
                        : (ch == 10 ? "\\n" : (ch == 12 ? "0x0C (form feed)" : "\\r"))));
            }
        } else {
            BYTE_TO_CHAR_SMALL_C_CEDILLA[index] = ch;
            if (logger.isTraceEnabled()) {
                logger.trace(String.format("%d == %s", index,
                        (ch != 10 && ch != 13) ? ch : (ch == 10 ? "\\n" : "\\r")));
            }
        }
        count++;
    }
    if (count < 128 && logger.isWarnEnabled()) {
        logger.warn("Character look-up initialized with only " + count + " value(s) (expecting 128 values)");
    }
    return count;
}

From source file:com.salesmanager.core.service.common.impl.ModuleManagerImpl.java

/**
 * Properties are 1) Production(1) - Test(2) 2) Pre-Auth(1) - Capture (2) -
 * Sale (0) 3) No CCV (1) - With CCV (2)
 * /*from ww w . jav  a 2  s  .c om*/
 * @param configvalue
 * @return
 */
public static IntegrationProperties stripProperties(String configvalue) {
    if (configvalue == null)
        return new IntegrationProperties();
    StringTokenizer st = new StringTokenizer(configvalue, ";");
    int i = 1;
    IntegrationProperties keys = new IntegrationProperties();
    while (st.hasMoreTokens()) {
        String value = st.nextToken();
        if (i == 1) {
            keys.setProperties1(value);
        } else if (i == 2) {
            keys.setProperties2(value);
        } else if (i == 3) {
            keys.setProperties3(value);
        } else {
            keys.setProperties4(value);
        }
        i++;
    }
    return keys;
}

From source file:TreeUtil.java

public static TreePath makeTreePath(String path, DefaultMutableTreeNode parentNode) {
    DefaultMutableTreeNode tempNode = parentNode;
    TreePath res = new TreePath(parentNode);
    StringTokenizer tok = new StringTokenizer(path, ".");
    String currentPath = null;/*  w  w  w  . j a  v  a2s .  c o m*/
    while (tok.hasMoreTokens()) {
        String myTok = tok.nextToken();
        currentPath = (currentPath == null) ? myTok : currentPath + "." + myTok;
        for (int j = 0; j < tempNode.getChildCount(); j++) {
            DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) tempNode.getChildAt(j);
            if (childNode.toString().equals(myTok)) {
                tempNode = childNode;
                res = res.pathByAddingChild(tempNode);
                break;
            }
        }
    }
    return res;
}

From source file:com.emaxcore.emaxdata.common.web.Servlets.java

/**
 * ?? If-None-Match Header, Etag?./*from ww  w .  ja  v  a2 s.  co m*/
 *
 * Etag, checkIfNoneMatchfalse, 304 not modify status.
 *
 * @param etag ETag.
 */
public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response,
        String etag) {
    String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH);
    if (headerValue != null) {
        boolean conditionSatisfied = false;
        if (!"*".equals(headerValue)) {
            StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
            while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
                String currentToken = commaTokenizer.nextToken();
                if (currentToken.trim().equals(etag)) {
                    conditionSatisfied = true;
                }
            }
        } else {
            conditionSatisfied = true;
        }

        if (conditionSatisfied) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            response.setHeader(HttpHeaders.ETAG, etag);
            return false;
        }
    }
    return true;
}