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.github.dozermapper.core.fieldmap.HintContainer.java

public List<Class<?>> getHints() {
    if (hints == null) {
        List<Class<?>> list = new ArrayList<>();
        StringTokenizer st = new StringTokenizer(this.hintName, ",");
        while (st.hasMoreElements()) {
            String theHintName = st.nextToken().trim();

            Class<?> clazz = MappingUtils.loadClass(theHintName, beanContainer);
            list.add(clazz);// w  ww  . j a v a  2 s .co  m
        }
        hints = list;
    }
    return hints;
}

From source file:org.jumpmind.symmetric.io.data.transform.ColumnsToRowsKeyColumnTransform.java

public List<String> transform(IDatabasePlatform platform, DataContext context, TransformColumn column,
        TransformedData data, Map<String, String> sourceValues, String newValue, String oldValue)
        throws IgnoreRowException {

    if (StringUtils.trimToNull(column.getTransformExpression()) == null) {
        throw new RuntimeException(
                "Transform configured incorrectly.  A map representing PK and column names must be defined as part of the transform expression");
    }/*from  ww  w  . ja v a2  s.c om*/
    String mapAsString = StringUtils.trimToEmpty(column.getTransformExpression());

    // Build reverse map, while also building up array to return

    List<String> result = new ArrayList<String>();
    Map<String, String> reverseMap = new HashMap<String, String>();

    StringTokenizer tokens = new StringTokenizer(mapAsString);

    while (tokens.hasMoreElements()) {
        String keyValue = (String) tokens.nextElement();
        int equalIndex = keyValue.indexOf("=");
        if (equalIndex != -1) {
            reverseMap.put(keyValue.substring(equalIndex + 1), keyValue.substring(0, equalIndex));
            result.add(keyValue.substring(equalIndex + 1));
        } else {
            throw new RuntimeException(
                    "Map string for " + column.getTransformExpression() + " is invalid format: " + mapAsString);
        }
    }

    context.put(getContextBase(column.getTransformId()) + CONTEXT_MAP, reverseMap);
    context.put(getContextBase(column.getTransformId()) + CONTEXT_PK_COLUMN, column.getTargetColumnName());

    return result;
}

From source file:org.seasar.struts.lessconfig.validator.config.impl.ArgsConfigRegisterImpl.java

protected String[] toArrays(String str) {
    StringTokenizer tokenizer = new StringTokenizer(str, ",");
    List list = new ArrayList();
    while (tokenizer.hasMoreElements()) {
        list.add(tokenizer.nextToken().trim());
    }//from  www  . jav a  2s  . c o m
    return (String[]) list.toArray(new String[list.size()]);
}

From source file:com.josue.jsf.jaxrs.base64.GenericResource.java

@GET
@Produces("text/plain")
public String getText(@QueryParam("query") String query) {
    byte[] decodedBytes = Base64.decodeBase64(query.getBytes());
    StringTokenizer token = new StringTokenizer(new String(decodedBytes), "&");
    Map<String, Object> params = new HashMap<>();
    while (token.hasMoreElements()) {
        String keyVal = token.nextToken();
        params.put(keyVal.split("=")[0], keyVal.split("=")[1]);
    }//from w  w w  . j a v a  2  s.  c o  m

    for (Object o : params.values()) {
        LOG.info(o.toString());
    }

    return new String(decodedBytes);
}

From source file:biblivre3.z3950.BiblivrePrefixString.java

@Override
public InternalModelRootNode toInternalQueryModel(ApplicationContext ctx) throws InvalidQueryException {
    if (StringUtils.isBlank(queryAttr) || StringUtils.isBlank(queryTerms)) {
        throw new InvalidQueryException("Null prefix string");
    }/*from  w  w w  .  jav  a 2 s .c  o m*/
    try {
        if (internalModel == null) {
            internalModel = new InternalModelRootNode();
            InternalModelNamespaceNode node = new InternalModelNamespaceNode();
            node.setAttrset(DEFAULT_ATTRSET);
            internalModel.setChild(node);
            AttrPlusTermNode attrNode = new AttrPlusTermNode();
            final String attrValue = "1." + queryAttr;
            attrNode.setAttr(DEFAULT_ATTRTYPE, new AttrValue(null, attrValue));
            Vector terms = new Vector();
            StringTokenizer tokenizer = new StringTokenizer(queryTerms);
            while (tokenizer.hasMoreElements()) {
                terms.add(tokenizer.nextElement());
            }
            if (terms.size() > 1) {
                attrNode.setTerm(terms);
            } else if (terms.size() == 1) {
                attrNode.setTerm(terms.get(0));
            } else {
                throw new PrefixQueryException("No Terms");
            }
            node.setChild(attrNode);
        }
    } catch (Exception e) {
        throw new InvalidQueryException(e.getMessage());
    }
    return internalModel;
}

From source file:com.enonic.vertical.adminweb.handlers.xmlbuilders.ContentFileXMLBuilder.java

public void buildContentTypeXML(User user, Document doc, Element contentdata, ExtendedMap formItems)
        throws VerticalAdminException {

    // Name//from  ww w .j ava2  s  . c  om
    Element tempElement = XMLTool.createElement(doc, contentdata, "name", formItems.getString("name"));

    // Description
    tempElement = XMLTool.createElement(doc, contentdata, "description");
    XMLTool.createCDATASection(doc, tempElement, formItems.getString("description", ""));

    // Keywords
    Element keywords = XMLTool.createElement(doc, contentdata, "keywords");
    if (formItems.containsKey("keywords")) {
        StringTokenizer stringTok = new StringTokenizer(formItems.getString("keywords"), " ");
        while (stringTok.hasMoreElements()) {
            tempElement = XMLTool.createElement(doc, keywords, "keyword", (String) stringTok.nextElement());
        }
    }

    // File size
    int fileSize = formItems.getInt("filesize");
    XMLTool.createElement(doc, contentdata, "filesize", String.valueOf(fileSize));

    tempElement = XMLTool.createElement(doc, contentdata, "binarydata");
    tempElement.setAttribute("key", (String) formItems.get("binarydatakey"));
}

From source file:com.amalto.core.save.context.PartialDeleteSimulator.java

/**
 * "Source document" and "toDeleteDocument" may not be be able to share "toDeletePiovt". <br>
 * Like <b>"Kids/Kid[2]/Habits/Habit"</b> means to delete source document's <b>SECOND</b> kid's habits,<br> 
 * but "toDeleteDocument" should use <b>"Kids/Kid[1]/Habits/Habit"</b> to get the data to delete.
 * @return//from w w  w  .  j  a v  a  2 s  . c  o m
 */
private String getPivotForToDeleteDocument() {
    if (toDeletePivot.contains("[") && toDeletePivot.contains("]")) { //$NON-NLS-1$ //$NON-NLS-2$
        StringBuilder pivot = new StringBuilder();
        StringTokenizer tokenizer = new StringTokenizer(toDeletePivot, "/"); //$NON-NLS-1$
        while (tokenizer.hasMoreElements()) {
            String element = (String) tokenizer.nextElement();
            pivot.append("/").append(StringUtils.substringBefore(element, "[")); //$NON-NLS-1$ //$NON-NLS-2$
            if (element.contains("[") && element.contains("]")) { //$NON-NLS-1$ //$NON-NLS-2$
                pivot.append("[1]"); //$NON-NLS-1$
            }
        }
        return pivot.toString().substring(1);
    } else {
        return toDeletePivot;
    }
}

From source file:ca.uhn.fhir.context.RuntimeSearchParam.java

public List<String> getPathsSplit() {
    String path = getPath();//from   w w  w  . j a v  a2  s.c  o m
    if (path.indexOf('|') == -1) {
        return Collections.singletonList(path);
    }

    List<String> retVal = new ArrayList<String>();
    StringTokenizer tok = new StringTokenizer(path, "|");
    while (tok.hasMoreElements()) {
        String nextPath = tok.nextToken().trim();
        retVal.add(nextPath.trim());
    }
    return retVal;
}

From source file:org.obiba.onyx.core.etl.participant.impl.AbstractParticipantReader.java

/**
 * Set the column name to attribute name map with a configuration string.
 * //  ww  w . j  a  va  2 s  .co m
 * @param keyValuePairs list of key/value pairs separated by a comma. For example, "<code>param1=foo,param2=bar</code>
 * ".
 */
public void setColumnToAttribute(String keyValuePairs) {
    if (columnNameToAttributeNameMap != null) {
        // Get list of strings separated by the delimiter
        StringTokenizer tokenizer = new StringTokenizer(keyValuePairs, ",");
        while (tokenizer.hasMoreElements()) {
            String token = tokenizer.nextToken();
            String[] entry = token.split("=");
            if (entry.length == 2) {
                columnNameToAttributeNameMap.put(entry[0].trim(), entry[1].trim());
            } else {
                log.error("Could not identify Participant column to attribute mapping: " + token);
            }
        }
    }
}

From source file:nl.nn.adapterframework.pipes.RemoveFromSession.java

/**
 * This is where the action takes place. Pipes may only throw a PipeRunException,
 * to be handled by the caller of this object.
 *//*from  w w w .  ja v a2  s .c o  m*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    String result = null;

    String sessionKeys = getSessionKey();
    if (StringUtils.isEmpty(sessionKeys)) {
        sessionKeys = (String) input;
    }
    if (StringUtils.isEmpty(sessionKeys)) {
        log.warn(getLogPrefix(session) + "no key specified");
        result = "[null]";
    } else {
        StringTokenizer st = new StringTokenizer(sessionKeys, ",");
        while (st.hasMoreElements()) {
            String sk = st.nextToken();
            Object skResult = session.remove(sk);
            if (skResult == null) {
                log.warn(getLogPrefix(session) + "key [" + sk + "] not found");
                skResult = "[null]";
            } else {
                log.debug(getLogPrefix(session) + "key [" + sk + "] removed");
            }
            if (result == null) {
                result = (String) skResult;
            } else {
                result = result + "," + skResult;
            }
        }
    }

    return new PipeRunResult(getForward(), result);
}