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.chinamobile.bcbsp.examples.connectedcomponent.CCVertexLiteNew.java

@Override
public void fromString(String vertexData) throws Exception {
    String[] buffer = new String[2];
    StringTokenizer str = new StringTokenizer(vertexData, Constants.KV_SPLIT_FLAG);
    if (str.hasMoreElements()) {
        buffer[0] = str.nextToken();//from  w w  w . j  a  v a2  s .  co  m
    } else {
        throw new Exception();
    }
    if (str.hasMoreElements()) {
        buffer[1] = str.nextToken();
    }
    str = new StringTokenizer(buffer[0], Constants.SPLIT_FLAG);
    if (str.countTokens() != 2) {
        throw new Exception();
    }
    this.vertexID = Integer.valueOf(str.nextToken());
    float tmp = Float.valueOf(str.nextToken());
    this.vertexValue = (int) tmp;

    if (buffer[1].length() > 0) { // There has edges.
        str = new StringTokenizer(buffer[1], Constants.SPACE_SPLIT_FLAG);
        while (str.hasMoreTokens()) {
            CCEdgeLiteNew edge = new CCEdgeLiteNew();
            edge.fromString(str.nextToken());
            this.edgesList.add(edge);
        }
    }
}

From source file:nl.nn.adapterframework.jdbc.MessageStoreSender.java

public String sendMessage(String correlationID, String message, ParameterResolutionContext prc)
        throws SenderException, TimeOutException {
    if (sessionKeys != null) {
        List<String> list = new ArrayList<String>();
        list.add(StringEscapeUtils.escapeCsv(message));
        StringTokenizer tokenizer = new StringTokenizer(sessionKeys, ",");
        while (tokenizer.hasMoreElements()) {
            String sessionKey = (String) tokenizer.nextElement();
            list.add(StringEscapeUtils.escapeCsv((String) prc.getSession().get(sessionKey)));
        }/*from  w  ww  . j  a v a2  s.  c o m*/
        StrBuilder sb = new StrBuilder();
        sb.appendWithSeparators(list, ",");
        message = sb.toString();
    }
    String messageId = prc.getSession().getMessageId();
    if (prc != null && paramList != null && paramList.findParameter("messageId") != null) {
        try {
            messageId = (String) prc.getValueMap(paramList).get("messageId");
        } catch (ParameterException e) {
            throw new SenderException("Could not resolve parameter messageId", e);
        }
    }
    return storeMessage(messageId, correlationID, new Date(), null, null, message);
}

From source file:nl.nn.adapterframework.jdbc.MessageStoreListener.java

public void configure() throws ConfigurationException {
    if (sessionKeys != null) {
        sessionKeysList = new ArrayList<String>();
        StringTokenizer stringTokenizer = new StringTokenizer(sessionKeys, ",");
        while (stringTokenizer.hasMoreElements()) {
            sessionKeysList.add((String) stringTokenizer.nextElement());
        }/*from  w w w  . ja  v  a2s.com*/
    }
    setSelectQuery("SELECT MESSAGEKEY, MESSAGE FROM IBISSTORE " + "WHERE TYPE = '"
            + JdbcTransactionalStorage.TYPE_MESSAGESTORAGE + "' AND SLOTID = '" + slotId + "' ");
    // This class was initially developed as DelayStoreListener with
    // the following condition added. We could still add an
    // optional delay attribute but this functionality wasn't used
    // anymore and the condition is Oracle specific.
    // + "AND SYSTIMESTAMP >= MESSAGEDATE + INTERVAL '" + delay + "' SECOND");
    String query = "UPDATE IBISSTORE SET TYPE = '" + JdbcTransactionalStorage.TYPE_MESSAGELOG_RECEIVER
            + "', COMMENTS = '" + ReceiverBase.RCV_MESSAGE_LOG_COMMENTS
            + "', EXPIRYDATE = ({fn now()} + 30) WHERE MESSAGEKEY = ?";

    //      Date date = new Date();
    //      Calendar cal = Calendar.getInstance();
    //      cal.setTime(date);
    //      cal.add(Calendar.DAY_OF_MONTH, getRetention());
    //      stmt.setTimestamp(++parPos, new Timestamp(cal.getTime().getTime()));

    if (!isMoveToMessageLog()) {
        query = "DELETE FROM IBISSTORE WHERE MESSAGEKEY = ?";
    }
    setUpdateStatusToProcessedQuery(query);
    setUpdateStatusToErrorQuery(query);
    setKeyField("MESSAGEKEY");
    setMessageField("MESSAGE");
    setMessageFieldType("blob");
    setBlobSmartGet(true);
    super.configure();
}

From source file:org.xdi.oxauth.util.RedirectUri.java

public void parseQueryString(String queryString) {
    if (queryString != null) {
        StringTokenizer st = new StringTokenizer(queryString, "&", false);
        while (st.hasMoreElements()) {
            String nameValueToken = st.nextElement().toString();

            StringTokenizer stParamValue = new StringTokenizer(nameValueToken, "=", false);

            if (stParamValue.countTokens() == 1) {
                String paramName = stParamValue.nextElement().toString();
                responseParameters.put(paramName, null);
            } else if (stParamValue.countTokens() == 2) {
                try {
                    String paramName = stParamValue.nextElement().toString();
                    String paramValue = URLDecoder.decode(stParamValue.nextElement().toString(),
                            Util.UTF8_STRING_ENCODING);
                    responseParameters.put(paramName, paramValue);
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }//from   www  .  ja va2s  .  c om
            }
        }
    }
}

From source file:ubic.pubmedgate.organism.SpeciesLoader.java

public String getSingleName(String names) {
    StringTokenizer toker = new StringTokenizer(names, "[],");
    String shortest = toker.nextToken().toLowerCase().trim();
    while (toker.hasMoreElements()) {
        String current = toker.nextToken().toLowerCase().trim();
        // skip po as it's linked to rat.
        if (current.equals("po"))
            continue;
        // skip 'man' so human is used
        if (current.equals("man"))
            continue;
        if (current.length() < shortest.length())
            shortest = current;//from w w  w  .j  a va 2 s  .c om
    }
    return shortest;
}

From source file:org.eclipse.emf.mwe.utils.DirectoryCleaner.java

@Override
protected void invokeInternal(final WorkflowContext model, final ProgressMonitor monitor, final Issues issues) {
    if (directory != null) {
        final StringTokenizer st = new StringTokenizer(directory, ",");
        while (st.hasMoreElements()) {
            final String dir = st.nextToken().trim();
            final File f = new File(dir);
            if (f.exists() && f.isDirectory()) {
                LOG.info("Cleaning " + f.getAbsolutePath());
                try {
                    cleanFolder(f.getAbsolutePath());
                } catch (FileNotFoundException e) {
                    issues.addError(e.getMessage());
                }//from  w ww.  j ava 2s .c o m
            }
        }
    }
}

From source file:TransformHandler.java

/**
 * This method is run for every HTTP request sent to the proxy
 *///from  w  ww . j ava  2 s .c om
public boolean respond(Request request) throws IOException {

    // Initialise the output buffer
    final StringWriter sout = new StringWriter();
    m_out = new PrintWriter(sout);

    // These two hold the parameters from the URL 'translet' and 'document'
    String transletName = null;
    String document = null;
    String stats = null;

    // Get the parameters from the URL
    final StringTokenizer params = new StringTokenizer(request.query, "&");
    while (params.hasMoreElements()) {
        final String param = params.nextToken();
        if (param.startsWith(PARAM_TRANSLET)) {
            transletName = param.substring(PARAM_TRANSLET.length());
        } else if (param.startsWith(PARAM_DOCUMENT)) {
            document = param.substring(PARAM_DOCUMENT.length());
        } else if (param.startsWith(PARAM_STATS)) {
            stats = param.substring(PARAM_STATS.length());
        }
    }

    try {
        // Make sure that both parameters were specified
        if ((transletName == null) || (document == null)) {
            errorMessage(
                    "Parameters <b><tt>translet</tt></b> and/or " + "<b><tt>document</tt></b> not specified.");
        } else {
            if (m_tf == null) {
                m_tf = TransformerFactory.newInstance();
                try {
                    m_tf.setAttribute("use-classpath", Boolean.TRUE);
                } catch (IllegalArgumentException iae) {
                    System.err.println("Could not set XSLTC-specific TransformerFactory "
                            + "attributes.  Transformation failed.");
                }
            }
            Transformer t = m_tf.newTransformer(new StreamSource(transletName));

            // Do the actual transformation
            final long start = System.currentTimeMillis();
            t.transform(new StreamSource(document), new StreamResult(m_out));
            final long done = System.currentTimeMillis() - start;
            m_out.println("<!-- transformed by XSLTC in " + done + "ms -->");
        }
    } catch (Exception e) {
        errorMessage("Internal error.", e);
    }

    // Pass the transformation output as the HTTP response
    request.sendResponse(sout.toString());
    return true;
}

From source file:org.qedeq.base.io.IoUtility.java

/**
 * Get currently running java version and subversion numbers. This is the running JRE version.
 * If no version could be identified <code>null</code> is returned.
 *
 * @return  Array of version and subversion numbers.
 *///from w  w w  .  ja v  a 2s .c  o  m
public static int[] getJavaVersion() {
    final String version = System.getProperty("java.version");
    final List numbers = new ArrayList();
    final StringTokenizer tokenizer = new StringTokenizer(version, ".");
    while (tokenizer.hasMoreElements()) {
        String sub = tokenizer.nextToken();
        for (int i = 0; i < sub.length(); i++) {
            if (!Character.isDigit(sub.charAt(i))) {
                sub = sub.substring(0, i);
                break;
            }
        }
        try {
            numbers.add(new Integer(Integer.parseInt(sub)));
        } catch (Exception e) {
            e.printStackTrace();
            break;
        }
    }
    if (numbers.size() == 0) {
        return null;
    }
    final int[] result = new int[numbers.size()];
    for (int i = 0; i < numbers.size(); i++) {
        result[i] = ((Integer) numbers.get(i)).intValue();
    }
    return result;
}

From source file:org.junit.extensions.dynamicsuite.engine.ClassPathScanner.java

private List<String> getClassPathEntries() {
    String separator = getPathSeparator();
    String classpath = getClassPathString();

    StringTokenizer tokenizer = new StringTokenizer(classpath, separator);
    List<String> classPathEntries = new ArrayList<String>();

    while (tokenizer.hasMoreElements()) {
        String entry = tokenizer.nextToken();
        classPathEntries.add(entry);/*  ww w .  java  2s.c  o  m*/
    }
    return classPathEntries;
}

From source file:com.sfs.whichdoctor.beans.IsbPayloadBean.java

/**
 * Gets the formatted xml payload body.//from   w  w  w  . ja  v a2 s . com
 *
 * @return the formatted xml payload body
 */
public final String getFormattedXmlPayloadBody() {
    final String htmlPayload = getTabbedXmlPayload();

    StringBuffer htmlHeader = new StringBuffer();

    StringTokenizer tokenizer = new StringTokenizer(htmlPayload, "\n");

    int i = 0;
    while (tokenizer.hasMoreElements()) {
        final String line = tokenizer.nextToken();
        if (i >= this.headerCount) {
            htmlHeader.append(line);
            htmlHeader.append("<br/>");
        }
        i++;
    }
    return htmlHeader.toString();
}