Example usage for java.util StringTokenizer nextElement

List of usage examples for java.util StringTokenizer nextElement

Introduction

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

Prototype

public Object nextElement() 

Source Link

Document

Returns the same value as the nextToken method, except that its declared return value is Object rather than String .

Usage

From source file:org.glite.slcs.pki.CertificateExtensionFactory.java

/**
 * Creates a CertificateExtension. The id can be the OID or the name as
 * defined below. The values is a comma separated list of value(s)
 * <p>//  ww  w.  ja  v a 2  s  .  com
 * Valid names and values:
 * <ul>
 * <li>KeyUsage
 * <ul>
 * <li>DigitalSignature
 * <li>NonRepudiation
 * <li>KeyEncipherment
 * <li>DataEncipherment
 * <li>KeyAgreement
 * <li>KeyCertSign
 * <li>CRLSign
 * <li>EncipherOnly
 * <li>DecipherOnly
 * </ul>
 * <li>ExtendedKeyUsage
 * <ul>
 * <li>AnyExtendedKeyUsage
 * <li>ServerAuth
 * <li>ClientAuth
 * <li>CodeSigning
 * <li>EmailProtection
 * <li>IPSecEndSystem
 * <li>IPSecTunnel
 * <li>IPSecUser
 * <li>OCSPSigning
 * <li>Smartcardlogon
 * </ul>
 * <li>CertificatePolicies
 * <ul>
 * <li>The policy OID(s)
 * </ul>
 * <li>SubjectAltName
 * <ul>
 * <li>email:EMAIL_ADDRESS
 * <li>dns:HOSTNAME
 * </ul>
 * </ul>
 * <p>
 * Example:
 * <pre>
 * CertificateExtension keyUsageExtension = 
 *       CertificateExtensionFactory.createCertificateExtension("KeyUsage", "DigitalSignature,KeyEncipherment");
 * CertificateExtension subjectAltNameExtension = 
 *       CertificateExtensionFactory.createCertificateExtension("SubjectAltName", "email:john.doe@example.com,dns:www.exmaple.com");
 * </pre>
 * 
 * @param id
 *            The name or the OID of the extension.
 * @param values
 *            A comma separated list of extension value(s).
 * @return The corresponding CertificateExtension or <code>null</code> if
 *         the id (name or oid) is not supported.
 */
static public CertificateExtension createCertificateExtension(String id, String values) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("id:" + id + " value(s):" + values);
    }
    if (id.equals(X509Extensions.KeyUsage.getId()) || id.equalsIgnoreCase("KeyUsage")) {
        // parse the comma separated list of key usage
        int usage = 0;
        StringTokenizer st = new StringTokenizer(values, ",");
        while (st.hasMoreElements()) {
            String keyUsage = (String) st.nextElement();
            keyUsage = keyUsage.trim();

            if (keyUsage.equalsIgnoreCase("DigitalSignature")) {
                usage += KeyUsage.digitalSignature;
            } else if (keyUsage.equalsIgnoreCase("NonRepudiation")) {
                usage += KeyUsage.nonRepudiation;
            } else if (keyUsage.equalsIgnoreCase("KeyEncipherment")) {
                usage += KeyUsage.keyEncipherment;
            } else if (keyUsage.equalsIgnoreCase("DataEncipherment")) {
                usage += KeyUsage.dataEncipherment;
            } else if (keyUsage.equalsIgnoreCase("KeyAgreement")) {
                usage += KeyUsage.keyAgreement;
            } else if (keyUsage.equalsIgnoreCase("KeyCertSign")) {
                usage += KeyUsage.keyCertSign;
            } else if (keyUsage.equalsIgnoreCase("CRLSign")) {
                usage += KeyUsage.cRLSign;
            } else if (keyUsage.equalsIgnoreCase("EncipherOnly")) {
                usage += KeyUsage.encipherOnly;
            } else if (keyUsage.equalsIgnoreCase("DecipherOnly")) {
                usage += KeyUsage.decipherOnly;
            } else {
                LOG.error("Unknown KeyUsage: " + keyUsage);
            }

        }
        return createKeyUsageExtension(usage, values);
    } else if (id.equals(X509Extensions.ExtendedKeyUsage.getId()) || id.equalsIgnoreCase("ExtendedKeyUsage")) {
        // value is a comma separated list of keyPurpose
        Vector keyPurposeIds = new Vector();
        StringTokenizer st = new StringTokenizer(values, ",");
        while (st.hasMoreElements()) {
            String keyPurpose = (String) st.nextElement();
            keyPurpose = keyPurpose.trim();
            if (keyPurpose.equalsIgnoreCase("AnyExtendedKeyUsage")) {
                keyPurposeIds.add(KeyPurposeId.anyExtendedKeyUsage);
            } else if (keyPurpose.equalsIgnoreCase("ServerAuth")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_serverAuth);
            } else if (keyPurpose.equalsIgnoreCase("ClientAuth")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_clientAuth);
            } else if (keyPurpose.equalsIgnoreCase("CodeSigning")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_codeSigning);
            } else if (keyPurpose.equalsIgnoreCase("EmailProtection")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_emailProtection);
            } else if (keyPurpose.equalsIgnoreCase("IPSecEndSystem")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_ipsecEndSystem);
            } else if (keyPurpose.equalsIgnoreCase("IPSecTunnel")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_ipsecTunnel);
            } else if (keyPurpose.equalsIgnoreCase("IPSecUser")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_ipsecUser);
            } else if (keyPurpose.equalsIgnoreCase("TimeStamping")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_timeStamping);
            } else if (keyPurpose.equalsIgnoreCase("OCSPSigning")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_OCSPSigning);
            } else if (keyPurpose.equalsIgnoreCase("Smartcardlogon")) {
                keyPurposeIds.add(KeyPurposeId.id_kp_smartcardlogon);
            } else {
                LOG.error("Unknown ExtendedKeyUsage: " + keyPurpose);
            }
        }
        return createExtendedKeyUsageExtension(keyPurposeIds, values);
    } else if (id.equals(X509Extensions.CertificatePolicies.getId())
            || id.equalsIgnoreCase("CertificatePolicies")) {
        // values is a comma separated list of policyOIDs
        Vector policyOIDs = new Vector();
        StringTokenizer st = new StringTokenizer(values, ",");
        while (st.hasMoreElements()) {
            String policyOID = (String) st.nextElement();
            policyOID = policyOID.trim();
            policyOIDs.add(policyOID);
        }
        return createCertificatePoliciesExtension(policyOIDs, values);
    } else if (id.equals(X509Extensions.SubjectAlternativeName.getId())
            || id.equalsIgnoreCase("SubjectAltName")) {
        // values is a comma separated list of altername names prefixed with
        // the type (email: or dns:)
        Vector typedSubjectAltNames = new Vector();
        StringTokenizer st = new StringTokenizer(values, ",");
        while (st.hasMoreElements()) {
            String typedAltName = (String) st.nextElement();
            typedAltName = typedAltName.trim();
            typedSubjectAltNames.add(typedAltName);
        }
        return createSubjectAltNameExtension(typedSubjectAltNames, values);
    }
    LOG.error("Unsupported CertificateExtension: " + id);
    return null;
}

From source file:org.hyperic.util.exec.Execute.java

public static int execute(Vector envVars, String cmd, File baseDir) {
    Vector v = new Vector();
    StringTokenizer st = new StringTokenizer(cmd, " ");
    while (st.hasMoreTokens()) {
        v.addElement(st.nextElement());
    }/*w  w  w.ja va2  s.com*/

    return execute(envVars, v, baseDir);
}

From source file:net.antidot.semantic.rdf.rdb2rdf.r2rml.tools.R2RMLToolkit.java

/**
 * Extracts column names referenced by enclosing them in curly braces ({?
 * and }?) in a string template./* w ww .ja  v a 2  s  .  com*/
 * 
 * @param stringTemplate
 * @return
 */
public static Set<String> extractColumnNamesFromStringTemplate(String stringTemplate) {
    Set<String> result = new HashSet<String>();
    // Curly braces that do not enclose column names MUST be
    // escaped by a backslash character (\?).
    stringTemplate = stringTemplate.replaceAll("\\\\\\{", "");
    stringTemplate = stringTemplate.replaceAll("\\\\\\}", "");
    if (stringTemplate != null) {
        StringTokenizer st = new StringTokenizer(stringTemplate, "{}", true);
        boolean keepNext = false;
        String next = null;
        while (st.hasMoreElements()) {
            String element = st.nextElement().toString();
            if (keepNext)
                next = element;
            keepNext = element.equals("{");
            if (element.equals("}") && element != null) {
                log.debug("[R2RMLToolkit:extractColumnNamesFromStringTemplate] Extracted column name " + next
                        + " from string template " + stringTemplate);
                result.add(next);
                next = null;
            }
        }
    }
    return result;
}

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

private static void populateImagePropsType3(String[] lines, SoftwareImage image, String imageName)
        throws PariException {
    // int index;
    String line;/*from   w ww  . ja  v a2 s  . c  om*/
    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:com.pari.nm.modules.imgmgmt.ImagePropertyCCOHelper.java

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

    String line;/*from  w w  w .ja  v a  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);
    }

    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.bigdata.dastor.utils.FBUtilities.java

public static String[] strip(String string, String token) {
    StringTokenizer st = new StringTokenizer(string, token);
    List<String> result = new ArrayList<String>();
    while (st.hasMoreTokens()) {
        result.add((String) st.nextElement());
    }//from w  ww.j  a  v  a2 s .c  o  m
    return result.toArray(new String[0]);
}

From source file:com.floreantpos.util.StringUtils.java

/**
 * <p>/*from ww  w.  j  ava2 s  .  co  m*/
 * Remove underscores from a string and replaces first
 * letters with capitals.  Other letters are changed to lower case.
 * </p>
 *
 * <p>
 * For example <code>foo_bar</code> becomes <code>FooBar</code>
 * but <code>foo_barBar</code> becomes <code>FooBarbar</code>.
 * </p>
 *
 * @param data string to remove underscores from.
 * @return String
 * @deprecated Use the org.apache.commons.util.StringUtils class
 * instead.  Using its firstLetterCaps() method in conjunction
 * with a StringTokenizer will achieve the same result.
 */
static public String removeUnderScores(String data) {
    String temp = null;
    StringBuilder out = new StringBuilder();
    temp = data;

    StringTokenizer st = new StringTokenizer(temp, "_");

    while (st.hasMoreTokens()) {
        String element = (String) st.nextElement();
        out.append(firstLetterCaps(element));
    }

    return out.toString();
}

From source file:bboss.org.apache.velocity.util.StringUtils.java

/**
 * <p>/* w  ww .j  a  v  a2  s  .  co m*/
 * Remove underscores from a string and replaces first
 * letters with capitals.  Other letters are changed to lower case.
 * </p>
 *
 * <p>
 * For example <code>foo_bar</code> becomes <code>FooBar</code>
 * but <code>foo_barBar</code> becomes <code>FooBarbar</code>.
 * </p>
 *
 * @param data string to remove underscores from.
 * @return String
 * @deprecated Use the org.apache.commons.util.StringUtils class
 * instead.  Using its firstLetterCaps() method in conjunction
 * with a StringTokenizer will achieve the same result.
 */
static public String removeUnderScores(String data) {
    String temp = null;
    StringBuffer out = new StringBuffer();
    temp = data;

    StringTokenizer st = new StringTokenizer(temp, "_");

    while (st.hasMoreTokens()) {
        String element = (String) st.nextElement();
        out.append(firstLetterCaps(element));
    }

    return out.toString();
}

From source file:com.stratelia.webactiv.util.FileRepositoryManager.java

/**
 * to create the array of the string this array represents the repertories where the files must be
 * stored./*from www.j  av  a 2s  .  co m*/
 *
 * @param str : type String: the string of repertories
 * @return
 */
public static String[] getAttachmentContext(String str) {

    String strAt = "Attachment " + CONTEXT_TOKEN;

    if (str != null) {
        strAt = strAt.concat(str);
    }
    StringTokenizer strToken = new StringTokenizer(strAt, CONTEXT_TOKEN);
    // number of elements
    int nElt = strToken.countTokens();
    // to init array
    String[] context = new String[nElt];

    int k = 0;

    while (strToken.hasMoreElements()) {
        context[k] = ((String) strToken.nextElement()).trim();
        k++;
    }
    return context;
}

From source file:com.floreantpos.util.StringUtils.java

/**
 * <p>/*from   w  ww  .j  a  va2  s  . c  om*/
 * 'Camels Hump' replacement.
 * </p>
 *
 * <p>
 * Remove one string from another string but leave the capitalization of the
 * other letters unchanged.
 * </p>
 *
 * <p>
 * For example, removing "_" from <code>foo_barBar</code> becomes <code>FooBarBar</code>.
 * </p>
 *
 * @param data string to hump
 * @param replaceThis string to be replaced
 * @return String
 */
public static String removeAndHump(String data, String replaceThis) {
    String temp = null;
    StringBuilder out = new StringBuilder();
    temp = data;

    StringTokenizer st = new StringTokenizer(temp, replaceThis);

    while (st.hasMoreTokens()) {
        String element = (String) st.nextElement();
        out.append(capitalizeFirstLetter(element));
    } //while

    return out.toString();
}