Example usage for java.util StringTokenizer hasMoreElements

List of usage examples for java.util StringTokenizer hasMoreElements

Introduction

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

Prototype

public boolean hasMoreElements() 

Source Link

Document

Returns the same value as the hasMoreTokens method.

Usage

From source file:com.pari.swim.ImagePropertyCCOHelper.java

private static void populateImagePropsType3(String[] lines, SoftwareImage image, String imageName)
        throws PariException {
    // int index;
    String line;// w w  w. j  a va  2  s. c o m
    if (lines.length > 0) {
        line = lines[0];
    } else {
        logger.error("Pari Exception while populating Image properties for image: " + imageName);
        throw new PariException(-1, "Pari Exception while populating Image properties for image: " + imageName);
    }
    if (line == null) {
        logger.error("Pari Exception while populating Image properties for image: " + imageName);
        throw new PariException(-1, "Pari Exception while populating Image properties for image: " + imageName);
    }
    String imageDets = line.substring(line.indexOf("[") + 1, line.indexOf("]"));
    imageDets = imageDets.substring(imageDets.indexOf("{") + 1, imageDets.indexOf("}"));
    StringTokenizer st = new StringTokenizer(imageDets, ",");
    while (st.hasMoreElements()) {
        String token = (String) st.nextElement();
        String value;
        if (token.contains("osType")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setOsName(value);
        } else if (token.contains("releaseNumber")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setOsVersion(value);
        } else if (token.contains("dram")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setMinRAMSize(Long.valueOf(value));
        } else if (token.contains("flash")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setMinFlashSize(Long.valueOf(value));
        } else if (token.contains("platform")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            String[] applicablePlatforms = { value };
            image.setApplicablePlatforms(applicablePlatforms);
        } else if (token.contains("swAdvised")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setHasAdvisories(Boolean.valueOf(value));
        } else if (token.contains("swDeffered")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setDeferred(Boolean.valueOf(value));
        } else if (token.contains("baseImageName")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setBuildName(value);
        } else if (token.contains("featureSet")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            String[] featureList = { value };
            image.setFeatureList(featureList);
        }

    }

}

From source file:org.apache.hyracks.control.nc.NodeControllerService.java

private static List<IODeviceHandle> getDevices(String ioDevices) {
    List<IODeviceHandle> devices = new ArrayList<>();
    StringTokenizer tok = new StringTokenizer(ioDevices, ",");
    while (tok.hasMoreElements()) {
        String devPath = tok.nextToken().trim();
        devices.add(new IODeviceHandle(new File(devPath), "."));
    }//from   ww  w.  j  av a 2  s  . com
    return devices;
}

From source file:com.pari.nm.modules.imgmgmt.ImagePropertyCCOHelper.java

private static void populateImagePropsType3(String[] lines, SoftwareImage image, String imageName)
        throws PariException {

    String line;//from  w ww  .j  a va 2s .  c o m
    if (lines.length > 0) {
        line = lines[0];
    } else {
        logger.error("Pari Exception while populating Image properties for image: " + imageName);
        throw new PariException(-1, "Pari Exception while populating Image properties for image: " + imageName);
    }

    String imageDets = line.substring(line.indexOf("[") + 1, line.indexOf("]"));
    imageDets = imageDets.substring(imageDets.indexOf("{") + 1, imageDets.indexOf("}"));
    StringTokenizer st = new StringTokenizer(imageDets, ",");
    while (st.hasMoreElements()) {
        String token = (String) st.nextElement();
        String value;
        if (token.contains("osType")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setOsName(value);
        } else if (token.contains("releaseNumber")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setOsVersion(value);
        } else if (token.contains("dram")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setMinRAMSize(Long.valueOf(value));
        } else if (token.contains("flash")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setMinFlashSize(Long.valueOf(value));
        } else if (token.contains("platform")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            String[] applicablePlatforms = { value };
            image.setApplicablePlatforms(applicablePlatforms);
        } else if (token.contains("swAdvised")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setHasAdvisories(Boolean.valueOf(value));
        } else if (token.contains("swDeffered")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setDeferred(Boolean.valueOf(value));
        } else if (token.contains("baseImageName")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            image.setBuildName(value);
        } else if (token.contains("featureSet")) {
            value = token.substring(token.indexOf(":") + 2, token.lastIndexOf("\""));
            String[] featureList = { value };
            image.setFeatureList(featureList);
        }

    }

}

From source file:com.jims.oauth2.common.utils.OAuthUtils.java

public static Set<String> decodeScopes(String s) {
    Set<String> scopes = new HashSet<String>();
    if (!OAuthUtils.isEmpty(s)) {
        StringTokenizer tokenizer = new StringTokenizer(s, " ");

        while (tokenizer.hasMoreElements()) {
            scopes.add(tokenizer.nextToken());
        }/*from w w  w  .j  a  v  a  2  s  .  c  o m*/
    }
    return scopes;

}

From source file:com.liusoft.dlog4j.search.SearchProxy.java

/**
 * //  w  w w  . j av  a  2s  .com
 * @param obj
 * @param field
 * @param value
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 * @throws IntrospectionException 
 * @throws InstantiationException 
 */
private static void setNestedProperty(Object obj, String field, Object value) throws IllegalAccessException,
        InvocationTargetException, NoSuchMethodException, IntrospectionException, InstantiationException {
    StringTokenizer st = new StringTokenizer(field, ".");
    Class nodeClass = obj.getClass();
    StringBuffer tmp_prop = new StringBuffer();
    while (st.hasMoreElements()) {
        String f = st.nextToken();
        if (tmp_prop.length() > 0)
            tmp_prop.append('.');
        tmp_prop.append(f);
        PropertyDescriptor[] props = Introspector.getBeanInfo(nodeClass).getPropertyDescriptors();
        for (int i = 0; i < props.length; i++) {
            if (props[i].getName().equals(f)) {
                if (PropertyUtils.getNestedProperty(obj, tmp_prop.toString()) == null) {
                    nodeClass = props[i].getPropertyType();
                    PropertyUtils.setNestedProperty(obj, f, nodeClass.newInstance());
                }
                continue;
            }
        }
    }
    PropertyUtils.setNestedProperty(obj, field, value);
}

From source file:com.aurel.track.item.SendItemEmailBL.java

public static List<TPersonBean> validateEmails(String emails, List<TPersonBean> groups) {
    if (emails == null || emails.length() == 0) {
        return new ArrayList<TPersonBean>();
    }/*from w  w  w. jav  a  2 s  .c o  m*/
    List<TPersonBean> result = new ArrayList<TPersonBean>();
    StringTokenizer st = new StringTokenizer(emails, ";");
    Set<String> emailSet = new HashSet<String>();
    String emailFull;
    String email;
    while (st.hasMoreElements()) {
        emailFull = st.nextToken();
        email = extractEmail(emailFull);
        if (!verifyEmail(email)) {
            Integer groupID = isGroup(email, groups);
            if (groupID != null) {
                LOGGER.debug("Include group");
                List<TPersonBean> personsInGroup = PersonBL.loadPersonsForGroup(groupID);
                if (personsInGroup != null && !personsInGroup.isEmpty()) {
                    for (TPersonBean p : personsInGroup) {
                        if (!emailSet.contains(p.getEmail())) {
                            result.add(p);
                            emailSet.add(p.getEmail());
                        }
                    }
                }
            } else {
                LOGGER.debug("emailFull:" + emailFull + ", email:" + email + " not Valid!");
                return null;
            }
        } else {
            LOGGER.debug("emailFull:" + emailFull + ", email:" + email + " is Valid!");
            if (emailSet.contains(email)) {
                LOGGER.debug("Email already present");
            } else {
                TPersonBean person = new TPersonBean("", "", email);
                result.add(person);
                emailSet.add(email);
            }
        }
    }
    if (LOGGER.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        sb.append("Valid emails:[");
        for (TPersonBean p : result) {
            sb.append(p.getEmail() + ";");
        }
        sb.append("]");
        LOGGER.debug(sb);
    }
    return result;
}

From source file:org.eredlab.g4.ccl.net.pop3.POP3Client.java

private static POP3MessageInfo __parseStatus(String line) {
    int num, size;
    StringTokenizer tokenizer;

    tokenizer = new StringTokenizer(line);

    if (!tokenizer.hasMoreElements())
        return null;

    num = size = 0;//from  w ww. j a  va 2 s.c o m

    try {
        num = Integer.parseInt(tokenizer.nextToken());

        if (!tokenizer.hasMoreElements())
            return null;

        size = Integer.parseInt(tokenizer.nextToken());
    } catch (NumberFormatException e) {
        return null;
    }

    return new POP3MessageInfo(num, size);
}

From source file:org.eredlab.g4.ccl.net.pop3.POP3Client.java

private static POP3MessageInfo __parseUID(String line) {
    int num;/* w  w w. j ava2s  . c o m*/
    StringTokenizer tokenizer;

    tokenizer = new StringTokenizer(line);

    if (!tokenizer.hasMoreElements())
        return null;

    num = 0;

    try {
        num = Integer.parseInt(tokenizer.nextToken());

        if (!tokenizer.hasMoreElements())
            return null;

        line = tokenizer.nextToken();
    } catch (NumberFormatException e) {
        return null;
    }

    return new POP3MessageInfo(num, line);
}

From source file:com.icesoft.jasper.compiler.TldLocationsCache.java

/**
 * Sets the list of JARs that are known not to contain any TLDs.
 *
 * @param jarNames List of comma-separated names of JAR files that are known
 *                 not to contain any TLDs
 *///w w w .  java 2s .c  om
public static void setNoTldJars(String jarNames) {
    if (jarNames != null) {
        noTldJars.clear();
        StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
        while (tokenizer.hasMoreElements()) {
            noTldJars.add(tokenizer.nextToken());
        }
    }
}

From source file:org.silverpeas.core.util.file.FileUtil.java

/**
 * Create the array of strings this array represents the repertories where the files must be
 * stored.//www.  jav a 2s . c om
 */
public static String[] getAttachmentContext(final String context) {
    if (!StringUtil.isDefined(context)) {
        return new String[] { BASE_CONTEXT };
    }
    final StringTokenizer strToken = new StringTokenizer(context, CONTEXT_TOKEN);
    final List<String> folders = new ArrayList<>(10);
    folders.add(BASE_CONTEXT);
    while (strToken.hasMoreElements()) {
        folders.add(strToken.nextToken().trim());
    }
    return folders.toArray(new String[folders.size()]);
}