java.util.StringTokenizer

Here are the examples of the java api class java.util.StringTokenizer taken from open source projects.

1. StringTokenizerTest#test_hasMoreElements()

Project: j2objc
Source File: StringTokenizerTest.java
View license
/**
	 * @tests java.util.StringTokenizer#hasMoreElements()
	 */
public void test_hasMoreElements() {
    // Test for method boolean java.util.StringTokenizer.hasMoreElements()
    StringTokenizer st = new StringTokenizer("This is a test String");
    st.nextElement();
    assertTrue("hasMoreElements returned incorrect value", st.hasMoreElements());
    st.nextElement();
    st.nextElement();
    st.nextElement();
    st.nextElement();
    assertTrue("hasMoreElements returned incorrect value", !st.hasMoreElements());
}

2. RequestStatus#setValue()

Project: ical4j
Source File: RequestStatus.java
View license
/**
     * {@inheritDoc}
     */
public final void setValue(final String aValue) {
    final StringTokenizer t = new StringTokenizer(aValue, ";");
    if (t.hasMoreTokens()) {
        statusCode = t.nextToken();
    }
    if (t.hasMoreTokens()) {
        description = t.nextToken();
    }
    if (t.hasMoreTokens()) {
        exData = t.nextToken();
    }
}

3. NewLocaleTask#setParams()

Project: lucene-solr
Source File: NewLocaleTask.java
View license
@Override
public void setParams(String params) {
    super.setParams(params);
    language = country = variant = "";
    StringTokenizer st = new StringTokenizer(params, ",");
    if (st.hasMoreTokens())
        language = st.nextToken();
    if (st.hasMoreTokens())
        country = st.nextToken();
    if (st.hasMoreTokens())
        variant = st.nextToken();
}

4. TestDOMContentUtils#equalsIgnoreWhitespace()

Project: anthelion
Source File: TestDOMContentUtils.java
View license
private static boolean equalsIgnoreWhitespace(String s1, String s2) {
    StringTokenizer st1 = new StringTokenizer(s1);
    StringTokenizer st2 = new StringTokenizer(s2);
    while (st1.hasMoreTokens()) {
        if (!st2.hasMoreTokens())
            return false;
        if (!st1.nextToken().equals(st2.nextToken()))
            return false;
    }
    if (st2.hasMoreTokens())
        return false;
    return true;
}

5. StubUtility#hasPrefixOrSuffix()

Project: che
Source File: StubUtility.java
View license
private static boolean hasPrefixOrSuffix(String prefixes, String suffixes, String name) {
    //$NON-NLS-1$
    final String listSeparartor = ",";
    StringTokenizer tok = new StringTokenizer(prefixes, listSeparartor);
    while (tok.hasMoreTokens()) {
        String curr = tok.nextToken();
        if (name.startsWith(curr)) {
            return true;
        }
    }
    tok = new StringTokenizer(suffixes, listSeparartor);
    while (tok.hasMoreTokens()) {
        String curr = tok.nextToken();
        if (name.endsWith(curr)) {
            return true;
        }
    }
    return false;
}

6. Util#toAddress()

Project: directory-kerby
Source File: Util.java
View license
public static HostPort toAddress(final String target, final int defaultPort) throws UnknownHostException {
    String host = target;
    int port = defaultPort;
    StringTokenizer st = new StringTokenizer(target, ":");
    if (st.hasMoreTokens()) {
        host = st.nextToken().trim();
    }
    if (st.hasMoreTokens()) {
        port = Integer.parseInt(st.nextToken().trim());
    }
    if (st.hasMoreTokens()) {
        throw new IllegalArgumentException("Invalid host: " + target);
    }
    return new HostPort(host, port);
}

7. ColoredPatternLayout#makeColorString()

Project: h-store
Source File: ColoredPatternLayout.java
View license
private String makeColorString(String colorName) {
    //System.out.println(colorName);
    StringTokenizer tokenizer = new StringTokenizer(colorName, CONFIGURATION_SEPARATOR);
    String fgColor = FG_WHITE;
    String bgColor = BG_BLACK;
    String attr = ATTR_NORMAL;
    if (!tokenizer.hasMoreTokens()) {
        return PREFIX + ATTR_NORMAL + SEPARATOR + FG_WHITE + SUFFIX;
    }
    if (tokenizer.hasMoreTokens()) {
        fgColor = makeFgString(tokenizer.nextToken());
    }
    if (tokenizer.hasMoreTokens()) {
        bgColor = makeBgString(tokenizer.nextToken());
    }
    if (tokenizer.hasMoreTokens()) {
        attr = makeAttributeString(tokenizer.nextToken());
    }
    //return PREFIX + ATTR_DIM + SEPARATOR + FG_WHITE + SUFFIX;
    return PREFIX + attr + SEPARATOR + fgColor + SEPARATOR + bgColor + SUFFIX;
}

8. TextUtils#replaceAllWhitespace()

Project: atlasdb
Source File: TextUtils.java
View license
private static String replaceAllWhitespace(String text, String newSeparator) {
    StringBuilder sb = new StringBuilder();
    StringTokenizer st = new StringTokenizer(text);
    if (st.hasMoreTokens()) {
        sb.append(st.nextToken());
    }
    while (st.hasMoreTokens()) {
        sb.append(newSeparator);
        sb.append(st.nextToken());
    }
    return sb.toString();
}

9. ConversionExceptionTest#testInfoRetainsOrder()

View license
public void testInfoRetainsOrder() {
    ConversionException ex = new ConversionException("Message");
    ex.add("1st", "first");
    ex.add("2nd", "second");
    ex.add("3rd", "third");
    StringTokenizer tokenizer = new StringTokenizer(ex.getMessage(), "\n\r");
    tokenizer.nextToken();
    tokenizer.nextToken();
    assertEquals("message             : Message", tokenizer.nextToken());
    assertEquals("1st                 : first", tokenizer.nextToken());
    assertEquals("2nd                 : second", tokenizer.nextToken());
    assertEquals("3rd                 : third", tokenizer.nextToken());
}

10. ContentType#parse()

Project: tapestry3
Source File: ContentType.java
View license
/**
     * Parses the argument and configures the content type accordingly.
     * The format of the argument has to be type/subtype(;key=value)* 
     * 
     * @param contentType the content type that needs to be represented
     */
public void parse(String contentType) {
    initialize();
    StringTokenizer tokens = new StringTokenizer(contentType, ";");
    if (!tokens.hasMoreTokens())
        return;
    String mimeType = tokens.nextToken();
    StringTokenizer mimeTokens = new StringTokenizer(mimeType, "/");
    setBaseType(mimeTokens.hasMoreTokens() ? mimeTokens.nextToken() : "");
    setSubType(mimeTokens.hasMoreTokens() ? mimeTokens.nextToken() : "");
    while (tokens.hasMoreTokens()) {
        String parameter = tokens.nextToken();
        StringTokenizer parameterTokens = new StringTokenizer(parameter, "=");
        String key = parameterTokens.hasMoreTokens() ? parameterTokens.nextToken() : "";
        String value = parameterTokens.hasMoreTokens() ? parameterTokens.nextToken() : "";
        setParameter(key, value);
    }
}

11. ContentType#parse()

Project: tapestry4
Source File: ContentType.java
View license
/**
     * Parses the argument and configures the content type accordingly. The format of the argument
     * has to be type/subtype(;key=value)*
     * 
     * @param contentType
     *            the content type that needs to be represented
     */
public void parse(String contentType) {
    _baseType = "";
    _subType = "";
    _parameters.clear();
    StringTokenizer tokens = new StringTokenizer(contentType, ";");
    if (!tokens.hasMoreTokens())
        return;
    String mimeType = tokens.nextToken();
    StringTokenizer mimeTokens = new StringTokenizer(mimeType, "/");
    setBaseType(mimeTokens.hasMoreTokens() ? mimeTokens.nextToken() : "");
    setSubType(mimeTokens.hasMoreTokens() ? mimeTokens.nextToken() : "");
    while (tokens.hasMoreTokens()) {
        String parameter = tokens.nextToken();
        StringTokenizer parameterTokens = new StringTokenizer(parameter, "=");
        String key = parameterTokens.hasMoreTokens() ? parameterTokens.nextToken() : "";
        String value = parameterTokens.hasMoreTokens() ? parameterTokens.nextToken() : "";
        setParameter(key, value);
    }
}

12. ContentType#parse()

Project: tapestry5
Source File: ContentType.java
View license
/**
     * Parses the argument and configures the content type accordingly. The format of the argument has to be
     * type/subtype(;key=value)*
     *
     * @param contentType the content type that needs to be represented
     */
public void parse(String contentType) {
    baseType = "";
    subType = "";
    parameters.clear();
    StringTokenizer tokens = new StringTokenizer(contentType, ";");
    if (!tokens.hasMoreTokens())
        return;
    String mimeType = tokens.nextToken();
    StringTokenizer mimeTokens = new StringTokenizer(mimeType, "/");
    setBaseType(mimeTokens.hasMoreTokens() ? mimeTokens.nextToken() : "");
    setSubType(mimeTokens.hasMoreTokens() ? mimeTokens.nextToken() : "");
    while (tokens.hasMoreTokens()) {
        String parameter = tokens.nextToken();
        StringTokenizer parameterTokens = new StringTokenizer(parameter, "=");
        String key = parameterTokens.hasMoreTokens() ? parameterTokens.nextToken() : "";
        String value = parameterTokens.hasMoreTokens() ? parameterTokens.nextToken() : "";
        setParameter(key, value);
    }
}

13. DistCp#makeRelative()

Project: hadoop-20
Source File: DistCp.java
View license
/**
   * Make a path relative with respect to a root path.
   * absPath is always assumed to descend from root.
   * Otherwise returned path is null.
   */
static String makeRelative(Path root, Path absPath) {
    if (!absPath.isAbsolute()) {
        throw new IllegalArgumentException("!absPath.isAbsolute(), absPath=" + absPath);
    }
    String p = absPath.toUri().getPath();
    StringTokenizer pathTokens = new StringTokenizer(p, "/");
    for (StringTokenizer rootTokens = new StringTokenizer(root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
        if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
            return null;
        }
    }
    StringBuilder sb = new StringBuilder();
    for (; pathTokens.hasMoreTokens(); ) {
        sb.append(pathTokens.nextToken());
        if (pathTokens.hasMoreTokens()) {
            sb.append(Path.SEPARATOR);
        }
    }
    return sb.length() == 0 ? "." : sb.toString();
}

14. DistCp#makeRelative()

Project: hadoop-common
Source File: DistCp.java
View license
/**
   * Make a path relative with respect to a root path.
   * absPath is always assumed to descend from root.
   * Otherwise returned path is null.
   */
static String makeRelative(Path root, Path absPath) {
    if (!absPath.isAbsolute()) {
        throw new IllegalArgumentException("!absPath.isAbsolute(), absPath=" + absPath);
    }
    String p = absPath.toUri().getPath();
    StringTokenizer pathTokens = new StringTokenizer(p, "/");
    for (StringTokenizer rootTokens = new StringTokenizer(root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
        if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
            return null;
        }
    }
    StringBuilder sb = new StringBuilder();
    for (; pathTokens.hasMoreTokens(); ) {
        sb.append(pathTokens.nextToken());
        if (pathTokens.hasMoreTokens()) {
            sb.append(Path.SEPARATOR);
        }
    }
    return sb.length() == 0 ? "." : sb.toString();
}

15. DistCp#makeRelative()

Project: hadoop-mapreduce
Source File: DistCp.java
View license
/**
   * Make a path relative with respect to a root path.
   * absPath is always assumed to descend from root.
   * Otherwise returned path is null.
   */
static String makeRelative(Path root, Path absPath) {
    if (!absPath.isAbsolute()) {
        throw new IllegalArgumentException("!absPath.isAbsolute(), absPath=" + absPath);
    }
    String p = absPath.toUri().getPath();
    StringTokenizer pathTokens = new StringTokenizer(p, "/");
    for (StringTokenizer rootTokens = new StringTokenizer(root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
        if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
            return null;
        }
    }
    StringBuilder sb = new StringBuilder();
    for (; pathTokens.hasMoreTokens(); ) {
        sb.append(pathTokens.nextToken());
        if (pathTokens.hasMoreTokens()) {
            sb.append(Path.SEPARATOR);
        }
    }
    return sb.length() == 0 ? "." : sb.toString();
}

16. Util#createFileSet()

Project: hudson-2.x
Source File: Util.java
View license
public static FileSet createFileSet(File baseDir, String includes, String excludes) {
    FileSet fs = new FileSet();
    fs.setDir(baseDir);
    fs.setProject(new Project());
    StringTokenizer tokens;
    tokens = new StringTokenizer(includes, ",");
    while (tokens.hasMoreTokens()) {
        String token = tokens.nextToken().trim();
        fs.createInclude().setName(token);
    }
    if (excludes != null) {
        tokens = new StringTokenizer(excludes, ",");
        while (tokens.hasMoreTokens()) {
            String token = tokens.nextToken().trim();
            fs.createExclude().setName(token);
        }
    }
    return fs;
}

17. StringUtil#deduceLocale()

View license
public static Locale deduceLocale(String input) {
    if (input == null)
        return null;
    Locale locale = Locale.getDefault();
    if (input.length() > 0 && input.charAt(0) == '"')
        input = input.substring(1, input.length() - 1);
    StringTokenizer st = new StringTokenizer(input, ",_ ");
    String lang = "", country = "";
    if (st.hasMoreTokens()) {
        lang = st.nextToken();
    }
    if (st.hasMoreTokens()) {
        country = st.nextToken();
    }
    if (!st.hasMoreTokens()) {
        locale = new Locale(lang, country);
    } else {
        locale = new Locale(lang, country, st.nextToken());
    }
    return locale;
}

18. Task#parseCompactString()

Project: incubator-systemml
Source File: Task.java
View license
/**
	 * 
	 * @param stask
	 * @return
	 */
public static Task parseCompactString(String stask) {
    StringTokenizer st = new StringTokenizer(stask.trim(), ".");
    Task newTask = new Task(TaskType.valueOf(st.nextToken()));
    String meta = st.nextToken();
    //iteration data
    String sdata = st.nextToken();
    // remove brackets
    sdata = sdata.substring(1, sdata.length() - 1);
    StringTokenizer st2 = new StringTokenizer(sdata, ",");
    while (st2.hasMoreTokens()) {
        //create new iteration
        String lsdata = st2.nextToken();
        IntObject ldata = new IntObject(meta, Integer.parseInt(lsdata));
        newTask.addIteration(ldata);
    }
    return newTask;
}

19. InstructionUtils#getInstructionParts()

View license
/**
	 * Given an instruction string, strip-off the execution type and return 
	 * opcode and all input/output operands WITHOUT their data/value type. 
	 * i.e., ret.length = parts.length-1 (-1 for execution type)
	 * 
	 * @param str
	 * @return 
	 */
public static String[] getInstructionParts(String str) {
    StringTokenizer st = new StringTokenizer(str, Instruction.OPERAND_DELIM);
    String[] ret = new String[st.countTokens() - 1];
    // stripping-off the exectype
    st.nextToken();
    // opcode
    ret[0] = st.nextToken();
    int index = 1;
    while (st.hasMoreTokens()) {
        String tmp = st.nextToken();
        int ix = tmp.indexOf(Instruction.DATATYPE_PREFIX);
        ret[index++] = tmp.substring(0, ((ix >= 0) ? ix : tmp.length()));
    }
    return ret;
}

20. JavaFilenameFilter#getExtension()

Project: lenya
Source File: JavaFilenameFilter.java
View license
/**
     * Get the extension
     * 
     * @param filename the file name from which the extension is extracted
     * @return the extension
     */
public static String getExtension(String filename) {
    StringTokenizer st = new StringTokenizer(filename, ".");
    st.nextToken();
    String extension = "";
    while (st.hasMoreTokens()) {
        extension = st.nextToken();
    }
    return extension;
}

21. SyslogAppenderTest#testActualLogging()

Project: log4j
Source File: SyslogAppenderTest.java
View license
public void testActualLogging() throws Exception {
    SyslogAppender appender = new SyslogAppender();
    appender.setSyslogHost("localhost:" + ds.getLocalPort());
    appender.setName("name");
    PatternLayout pl = new PatternLayout("%m");
    pl.setFooter("EOF");
    appender.setLayout(pl);
    appender.activateOptions();
    Logger l = Logger.getRootLogger();
    l.addAppender(appender);
    l.info("greetings");
    ds.receive(p);
    String s = toString(p);
    StringTokenizer st = new StringTokenizer(s, "<>() ");
    assertEquals("14", st.nextToken());
    assertEquals(3, st.nextToken().length());
    // date
    st.nextToken();
    // time
    st.nextToken();
    assertEquals(appender.getLocalHostname(), st.nextToken());
    assertEquals("greetings", st.nextToken());
}

22. JAXWSRIWSDLGenerator#expandDirs()

View license
/**
     * Expand a directory path or list of directory paths (File.pathSeparator
     * delimited) into a list of file paths of all the jar files in those
     * directories.
     *
     * @param dirPaths The string containing the directory path or list of
     *                 directory paths.
     * @return The file paths of the jar files in the directories. This is an
     *         empty string if no files were found, and is terminated by an
     *         additional pathSeparator in all other cases.
     */
public static String expandDirs(String dirPaths) {
    StringTokenizer st = new StringTokenizer(dirPaths, File.pathSeparator);
    StringBuffer buffer = new StringBuffer();
    while (st.hasMoreTokens()) {
        String d = st.nextToken();
        File dir = new File(d);
        if (dir.isDirectory()) {
            File[] files = dir.listFiles(new JavaArchiveFilter());
            for (int i = 0; i < files.length; i++) {
                buffer.append(files[i]).append(File.pathSeparator);
            }
        }
    }
    return buffer.toString();
}

23. BIEnumeration#buildMemberList()

Project: openjdk
Source File: BIEnumeration.java
View license
private static List<CEnumConstant> buildMemberList(Model model, Element dom) {
    List<CEnumConstant> r = new ArrayList<CEnumConstant>();
    String members = DOMUtil.getAttribute(dom, "members");
    // TODO: error handling
    if (members == null)
        members = "";
    StringTokenizer tokens = new StringTokenizer(members);
    while (tokens.hasMoreTokens()) {
        String token = tokens.nextToken();
        r.add(new CEnumConstant(model.getNameConverter().toConstantName(token), null, token, null, /*TODO*/
        null, null));
    }
    return r;
}

24. MexUtil#parseForms()

Project: axis2-java
Source File: MexUtil.java
View license
private static OutputForm[] parseForms(String form_values) {
    List forms = new ArrayList();
    StringTokenizer st = new StringTokenizer(form_values, MexConstants.MEX_CONFIG.DELIMITER);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.equals(MexConstants.MEX_CONFIG.INLINE))
            forms.add(OutputForm.INLINE_FORM);
        else if (token.equals(MexConstants.MEX_CONFIG.LOCATION))
            forms.add(OutputForm.LOCATION_FORM);
        else if (token.equals(MexConstants.MEX_CONFIG.REFERENCE))
            forms.add(OutputForm.REFERENCE_FORM);
        else {
            log.debug("Invalid form configured, " + form_values);
        }
    }
    return (OutputForm[]) forms.toArray(new OutputForm[0]);
}

25. HTTPProxyConfigurator#isHostInNonProxyList()

View license
/**
     * Check if the specified host is in the list of non proxy hosts.
     *
     * @param host
     *            host name
     * @param nonProxyHosts
     *            string containing the list of non proxy hosts
     * @return true/false
     */
public static boolean isHostInNonProxyList(String host, String nonProxyHosts) {
    if ((nonProxyHosts == null) || (host == null)) {
        return false;
    }
    /*
         * The http.nonProxyHosts system property is a list enclosed in double
         * quotes with items separated by a vertical bar.
         */
    StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|\"");
    while (tokenizer.hasMoreTokens()) {
        String pattern = tokenizer.nextToken();
        if (match(pattern, host, false)) {
            return true;
        }
    }
    return false;
}

26. HTTPProxcyConfigurator#isHostInNonProxyList()

View license
/**
     * Check if the specified host is in the list of non proxy hosts.
     * 
     * @param host
     *            host name
     * @param nonProxyHosts
     *            string containing the list of non proxy hosts
     * @return true/false
     */
public static boolean isHostInNonProxyList(String host, String nonProxyHosts) {
    if ((nonProxyHosts == null) || (host == null)) {
        return false;
    }
    /*
         * The http.nonProxyHosts system property is a list enclosed in double
         * quotes with items separated by a vertical bar.
         */
    StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|\"");
    while (tokenizer.hasMoreTokens()) {
        String pattern = tokenizer.nextToken();
        if (match(pattern, host, false)) {
            return true;
        }
    }
    return false;
}

27. HTTPProxyConfigurator#isHostInNonProxyList()

View license
/**
     * Check if the specified host is in the list of non proxy hosts.
     * 
     * @param host
     *            host name
     * @param nonProxyHosts
     *            string containing the list of non proxy hosts
     * @return true/false
     */
public static boolean isHostInNonProxyList(String host, String nonProxyHosts) {
    if ((nonProxyHosts == null) || (host == null)) {
        return false;
    }
    /*
         * The http.nonProxyHosts system property is a list enclosed in double
         * quotes with items separated by a vertical bar.
         */
    StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|\"");
    while (tokenizer.hasMoreTokens()) {
        String pattern = tokenizer.nextToken();
        if (match(pattern, host, false)) {
            return true;
        }
    }
    return false;
}

28. HTTPProxyConfigurationUtil#isHostInNonProxyList()

View license
/**
     * Check if the specified host is in the list of non proxy hosts.
     *
     * @param host          host name
     * @param nonProxyHosts string containing the list of non proxy hosts
     * @return true/false
     */
public static boolean isHostInNonProxyList(String host, String nonProxyHosts) {
    if ((nonProxyHosts == null) || (host == null)) {
        return false;
    }
    /*
         * The http.nonProxyHosts system property is a list enclosed in
         * double quotes with items separated by a vertical bar.
         */
    StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|\"");
    while (tokenizer.hasMoreTokens()) {
        String pattern = tokenizer.nextToken();
        if (match(pattern, host, false)) {
            return true;
        }
    }
    return false;
}

29. SVGGVTFont#languageMatches()

Project: batik
Source File: SVGGVTFont.java
View license
/**
     * Returns true if the glyph language matches the language of the
     * text node to be rendered by this font.  This will be the case
     * if one of the languages in glyphLang matches exactly with the
     * xml:lang attibute of the text node, or if the xml:lang
     * attribute exactly equals a prefix of one glyph languages.
     *
     * @param glyphLang A comma separated list of languages that are associated
     * with a glyph.
     *
     * @return Whether or not the glyph language matches the language of the
     * text node.
     */
private boolean languageMatches(String glyphLang) {
    if (glyphLang == null || glyphLang.length() == 0) {
        // will match all languages
        return true;
    }
    StringTokenizer st = new StringTokenizer(glyphLang, ",");
    while (st.hasMoreTokens()) {
        String s = st.nextToken();
        if (s.equals(language) || (s.startsWith(language) && s.length() > language.length() && s.charAt(language.length()) == '-')) {
            return true;
        }
    }
    return false;
}

30. SVGUtilities#matchUserLanguage()

Project: batik
Source File: SVGUtilities.java
View license
/**
     * Tests whether or not the specified language specification matches
     * the user preferences.
     *
     * @param s the langage to check
     * @param userLanguages the user langages
     */
protected static boolean matchUserLanguage(String s, String userLanguages) {
    StringTokenizer st = new StringTokenizer(userLanguages, ", ");
    while (st.hasMoreTokens()) {
        String t = st.nextToken();
        if (s.startsWith(t)) {
            if (s.length() > t.length()) {
                return (s.charAt(t.length()) == '-');
            }
            return true;
        }
    }
    return false;
}

31. TextUtilities#svgHorizontalCoordinateArrayToUserSpace()

Project: batik
Source File: TextUtilities.java
View license
/**
     * Returns the float list that represents a set of horizontal
     * values or percentage.
     *
     * @param element the element that defines the specified coordinates
     * @param attrName the name of the attribute (used by error handling)
     * @param valueStr the delimited string containing values of the coordinate
     * @param ctx the bridge context
     */
public static ArrayList svgHorizontalCoordinateArrayToUserSpace(Element element, String attrName, String valueStr, BridgeContext ctx) {
    UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);
    ArrayList values = new ArrayList();
    StringTokenizer st = new StringTokenizer(valueStr, ", ", false);
    while (st.hasMoreTokens()) {
        values.add(new Float(UnitProcessor.svgHorizontalCoordinateToUserSpace(st.nextToken(), attrName, uctx)));
    }
    return values;
}

32. TextUtilities#svgVerticalCoordinateArrayToUserSpace()

Project: batik
Source File: TextUtilities.java
View license
/**
     * Returns the float list that represents a set of values or percentage.
     *
     *
     * @param element the element that defines the specified coordinates
     * @param attrName the name of the attribute (used by error handling)
     * @param valueStr the delimited string containing values of the coordinate
     * @param ctx the bridge context
     */
public static ArrayList svgVerticalCoordinateArrayToUserSpace(Element element, String attrName, String valueStr, BridgeContext ctx) {
    UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);
    ArrayList values = new ArrayList();
    StringTokenizer st = new StringTokenizer(valueStr, ", ", false);
    while (st.hasMoreTokens()) {
        values.add(new Float(UnitProcessor.svgVerticalCoordinateToUserSpace(st.nextToken(), attrName, uctx)));
    }
    return values;
}

33. TextUtilities#svgRotateArrayToFloats()

Project: batik
Source File: TextUtilities.java
View license
public static ArrayList svgRotateArrayToFloats(Element element, String attrName, String valueStr, BridgeContext ctx) {
    StringTokenizer st = new StringTokenizer(valueStr, ", ", false);
    ArrayList values = new ArrayList();
    String s;
    while (st.hasMoreTokens()) {
        try {
            s = st.nextToken();
            values.add(new Float(Math.toRadians(SVGUtilities.convertSVGNumber(s))));
        } catch (NumberFormatException nfEx) {
            throw new BridgeException(ctx, element, nfEx, ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] { attrName, valueStr });
        }
    }
    return values;
}

34. JavaNameGenerator#underscoreOmitSchemaMethod()

Project: bboss
Source File: JavaNameGenerator.java
View license
/**
     * Converts a database schema name to java object name. 
     * First, it removes all characters before the last occurence of 
     * .<code>SCHEMA_SEPARATOR_CHAR</code>. Then, in a second step, removes
     * <code>STD_SEPARATOR_CHAR</code>, capitilizes first letter of
     * name and each letter after the <code>STD_SEPERATOR</code>,
     * and converts the rest of the letters to lowercase.
     *
     * @param schemaName name to be converted.
     * @return converted name.
     * @see com.frameworkset.orm.engine.model.NameGenerator
     * @see #underscoreOmitSchemaMethod(String)
     */
protected String underscoreOmitSchemaMethod(String schemaName, boolean IGNORE_FIRST_TOKEN) {
    // take only part after last dot
    int lastDotPos = schemaName.lastIndexOf(SCHEMA_SEPARATOR_CHAR);
    if (lastDotPos != -1) {
        schemaName = schemaName.substring(lastDotPos + 1);
    }
    StringBuffer name = new StringBuffer();
    StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR));
    while (tok.hasMoreTokens()) {
        String namePart = ((String) tok.nextElement()).toLowerCase();
        name.append(StringUtils.capitalize(namePart));
    }
    return name.toString();
}

35. SimpleStringUtil#tokenizeToStringArray()

Project: bboss
Source File: SimpleStringUtil.java
View license
/**
	 * Tokenize the given String into a String array via a StringTokenizer.
	 * <p>The given delimiters string is supposed to consist of any number of
	 * delimiter characters. Each of those characters can be used to separate
	 * tokens. A delimiter is always a single character; for multi-character
	 * delimiters, consider using <code>delimitedListToStringArray</code>
	 * @param str the String to tokenize
	 * @param delimiters the delimiter characters, assembled as String
	 * (each of those characters is individually considered as delimiter)
	 * @param trimTokens trim the tokens via String's <code>trim</code>
	 * @param ignoreEmptyTokens omit empty tokens from the result array
	 * (only applies to tokens that are empty after trimming; StringTokenizer
	 * will not consider subsequent delimiters as token in the first place).
	 * @return an array of the tokens (<code>null</code> if the input String
	 * was <code>null</code>)
	 * @see java.util.StringTokenizer
	 * @see java.lang.String#trim()
	 * @see #delimitedListToStringArray
	 */
public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {
    if (str == null) {
        return null;
    }
    StringTokenizer st = new StringTokenizer(str, delimiters);
    List tokens = new ArrayList();
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (trimTokens) {
            token = token.trim();
        }
        if (!ignoreEmptyTokens || token.length() > 0) {
            tokens.add(token);
        }
    }
    return toStringArray(tokens);
}

36. TexenTask#setTemplatePath()

Project: bboss
Source File: TexenTask.java
View license
/**
     * [REQUIRED] Set the path where Velocity will look
     * for templates using the file template
     * loader.
     * @param templatePath
     * @throws Exception
     */
public void setTemplatePath(String templatePath) throws Exception {
    StringBuffer resolvedPath = new StringBuffer();
    StringTokenizer st = new StringTokenizer(templatePath, ",");
    while (st.hasMoreTokens()) {
        // resolve relative path from basedir and leave
        // absolute path untouched.
        File fullPath = project.resolveFile(st.nextToken());
        resolvedPath.append(fullPath.getCanonicalPath());
        if (st.hasMoreTokens()) {
            resolvedPath.append(",");
        }
    }
    this.templatePath = resolvedPath.toString();
    System.out.println(templatePath);
}

37. StringUtils#removeUnderScores()

Project: bboss
Source File: StringUtils.java
View license
/**
     * <p>
     * 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.
     */
public static 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();
}

38. StringUtils#removeAndHump()

Project: bboss
Source File: StringUtils.java
View license
/**
     * <p>
     * '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;
    StringBuffer out = new StringBuffer();
    temp = data;
    StringTokenizer st = new StringTokenizer(temp, replaceThis);
    while (st.hasMoreTokens()) {
        String element = (String) st.nextElement();
        out.append(capitalizeFirstLetter(element));
    }
    return out.toString();
}

39. FSCmdExecutor#getCommandAsArgs()

Project: bigtop
Source File: FSCmdExecutor.java
View license
/**
   * Prapare given FsShell command for execution by ToolRunner.
   * This method also expands all variables used in the command.
   */
@Override
protected String[] getCommandAsArgs(final String cmd, final String masterKey, final String master) {
    StringTokenizer tokenizer = new StringTokenizer(cmd, " ");
    String[] args = new String[tokenizer.countTokens()];
    int i = 0;
    while (tokenizer.hasMoreTokens()) {
        args[i] = tokenizer.nextToken();
        // HCFS fs.default.name Hack (see TestCLI.java)
        args[i] = args[i].replaceAll("NAMENODETEST_DIR_ABSOLUTE", TestCLI.NAMENODE_TESTDIR_HACK);
        args[i] = args[i].replaceAll(masterKey, master);
        args[i] = args[i].replaceAll("CLITEST_DATA", new File(CLITestHelper.TEST_CACHE_DATA_DIR).toURI().toString().replace(' ', '+'));
        args[i] = args[i].replaceAll("USER_NAME", System.getProperty("user.name"));
        args[i] = args[i].replaceAll("TEST_DIR_ABSOLUTE", TestCLI.TEST_DIR_ABSOLUTE);
        args[i] = args[i].replaceAll("HCFS_SCHEME", TestCLI.HCFS_SCHEME);
        args[i] = args[i].replaceAll("HCFS_DIRSIZE", TestCLI.HCFS_DIRSIZE);
        args[i] = args[i].replaceAll("HCFS_NNMATCH", TestCLI.HCFS_NNMATCH);
        i++;
    }
    return args;
}

40. TestRegionMover#setUp()

Project: bigtop
Source File: TestRegionMover.java
View license
@BeforeClass
public static void setUp() throws InterruptedException {
    String region_servers = System.getProperty("regionservers", null);
    assertNotNull("Region server(s) must be specified to run this test", region_servers);
    StringTokenizer st = new StringTokenizer(region_servers, ",");
    while (st.hasMoreTokens()) {
        regionservers.add(st.nextToken());
    }
    System.out.println("Region servers to load/unload:\n" + regionservers);
    load_iterations = Integer.parseInt(System.getProperty("load.iterations", "10"));
    timeout_intervals = Integer.parseInt(System.getProperty("timeout.intervals", "20"));
    timeout_ms = Integer.parseInt(System.getProperty("timeout.ms", "20000"));
}

41. RawImageInputStream#getByteArray()

Project: bioformats
Source File: RawImageInputStream.java
View license
/** Gets the integer type attribute. */
private static byte[] getByteArray(Node node, String name) {
    String s = getAttribute(node, name);
    if (s == null)
        return null;
    StringTokenizer token = new StringTokenizer(s);
    int count = token.countTokens();
    if (count == 0)
        return null;
    byte[] buf = new byte[count];
    int i = 0;
    while (token.hasMoreElements()) {
        buf[i++] = new Byte(token.nextToken()).byteValue();
    }
    return buf;
}

42. RawImageInputStream#getIntArray()

Project: bioformats
Source File: RawImageInputStream.java
View license
/** Gets the integer type attribute. */
private static int[] getIntArray(Node node, String name) {
    String s = getAttribute(node, name);
    if (s == null)
        return null;
    StringTokenizer token = new StringTokenizer(s);
    int count = token.countTokens();
    if (count == 0)
        return null;
    int[] buf = new int[count];
    int i = 0;
    while (token.hasMoreElements()) {
        buf[i++] = new Integer(token.nextToken()).intValue();
    }
    return buf;
}

43. Box#parseByteArray()

Project: bioformats
Source File: Box.java
View license
/** Parses the byte array expressed by a string. */
public static byte[] parseByteArray(String value) {
    if (value == null)
        return null;
    StringTokenizer token = new StringTokenizer(value);
    int count = token.countTokens();
    byte[] buf = new byte[count];
    int i = 0;
    while (token.hasMoreElements()) {
        buf[i++] = new Byte(token.nextToken()).byteValue();
    }
    return buf;
}

44. Box#parseIntArray()

Project: bioformats
Source File: Box.java
View license
/** Parses the integer array expressed a string. */
protected static int[] parseIntArray(String value) {
    if (value == null)
        return null;
    StringTokenizer token = new StringTokenizer(value);
    int count = token.countTokens();
    int[] buf = new int[count];
    int i = 0;
    while (token.hasMoreElements()) {
        buf[i++] = new Integer(token.nextToken()).intValue();
    }
    return buf;
}

45. TIFFImageMetadata#listToIntArray()

Project: bioformats
Source File: TIFFImageMetadata.java
View license
private int[] listToIntArray(String list) {
    StringTokenizer st = new StringTokenizer(list, " ");
    ArrayList intList = new ArrayList();
    while (st.hasMoreTokens()) {
        String nextInteger = st.nextToken();
        Integer nextInt = new Integer(nextInteger);
        intList.add(nextInt);
    }
    int[] intArray = new int[intList.size()];
    for (int i = 0; i < intArray.length; i++) {
        intArray[i] = ((Integer) intList.get(i)).intValue();
    }
    return intArray;
}

46. TIFFImageMetadata#listToCharArray()

Project: bioformats
Source File: TIFFImageMetadata.java
View license
private char[] listToCharArray(String list) {
    StringTokenizer st = new StringTokenizer(list, " ");
    ArrayList intList = new ArrayList();
    while (st.hasMoreTokens()) {
        String nextInteger = st.nextToken();
        Integer nextInt = new Integer(nextInteger);
        intList.add(nextInt);
    }
    char[] charArray = new char[intList.size()];
    for (int i = 0; i < charArray.length; i++) {
        charArray[i] = (char) ((Integer) intList.get(i)).intValue();
    }
    return charArray;
}

47. TiffReader#parseCommentMetamorph()

Project: bioformats
Source File: TiffReader.java
View license
private void parseCommentMetamorph(String comment) {
    // parse key/value pairs
    StringTokenizer st = new StringTokenizer(comment, "\n");
    while (st.hasMoreTokens()) {
        String line = st.nextToken();
        int colon = line.indexOf(":");
        if (colon < 0) {
            addGlobalMeta("Comment", line);
            description = line;
            continue;
        }
        String key = line.substring(0, colon);
        String value = line.substring(colon + 1);
        addGlobalMeta(key, value);
    }
}

48. NetCDFServiceImpl#getGroup()

Project: bioformats
Source File: NetCDFServiceImpl.java
View license
/**
   * Retrieves a group based on its fully qualified path.
   * @param path Fully qualified path to the group.
   * @return Group or <code>root</code> if the group cannot be found.
   */
private Group getGroup(String path) {
    if (path.indexOf("/") == -1) {
        return root;
    }
    StringTokenizer tokens = new StringTokenizer(path, "/");
    Group parent = root;
    while (tokens.hasMoreTokens()) {
        String token = tokens.nextToken();
        Group nextParent = parent.findGroup(token);
        if (nextParent == null) {
            break;
        }
        parent = nextParent;
    }
    return parent == null ? root : parent;
}

49. ScaledSubstitutionMatrix#toString()

View license
/**
	 * Returns in a format similar to the standard NCBI files.
	 */
@Override
public String toString() {
    String newline = System.getProperty("line.separator");
    StringBuilder s = new StringBuilder();
    StringTokenizer st = new StringTokenizer(description, newline);
    while (st.hasMoreTokens()) {
        String line = st.nextToken();
        if (!line.startsWith(comment)) {
            s.append(comment);
        }
        s.append(String.format("%s%n", line));
    }
    if (scale != 1)
        s.append("# Matrix scaled by a factor of " + scale + newline);
    s.append(getMatrixAsString());
    return s.toString();
}

50. InetRange#ip2intarray()

Project: bitsquare
Source File: InetRange.java
View license
static int[] ip2intarray(final String host) {
    final int[] address = { -1, -1, -1, -1 };
    int i = 0;
    final StringTokenizer tokens = new StringTokenizer(host, ".");
    if (tokens.countTokens() > 4) {
        return null;
    }
    while (tokens.hasMoreTokens()) {
        try {
            address[i++] = Integer.parseInt(tokens.nextToken()) & 0xFF;
        } catch (final NumberFormatException nfe) {
            return null;
        }
    }
    return address;
}

51. HeaderClause#getListAttrib()

Project: bnd
Source File: HeaderClause.java
View license
public List<String> getListAttrib(String attrib) {
    String string = attribs.get(attrib);
    if (string == null)
        return null;
    List<String> result = new ArrayList<String>();
    StringTokenizer tokenizer = new StringTokenizer(string, ",");
    while (tokenizer.hasMoreTokens()) {
        result.add(tokenizer.nextToken().trim());
    }
    return result;
}

52. EclipseClasspath#getFile()

Project: bnd
Source File: EclipseClasspath.java
View license
private File getFile(File abs, File relative, String opath) {
    String path = opath.replace('/', File.separatorChar);
    File result = new File(path);
    if (result.isAbsolute() && result.isFile()) {
        return result;
    }
    if (path.startsWith(File.separator)) {
        result = abs;
        path = path.substring(1);
    } else
        result = relative;
    StringTokenizer st = new StringTokenizer(path, File.separator);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        result = new File(result, token);
    }
    if (!result.exists())
        System.err.println("File not found: project=" + project + " workspace=" + workspace + " path=" + opath + " file=" + result);
    return result;
}

53. NanoHTTPD#encodeUri()

Project: bnd
Source File: NanoHTTPD.java
View license
/**
	 * URL-encodes everything between "/"-characters. Encodes spaces as '%20'
	 * instead of '+'.
	 */
@SuppressWarnings("deprecation")
private String encodeUri(String uri) {
    String newUri = "";
    StringTokenizer st = new StringTokenizer(uri, "/ ", true);
    while (st.hasMoreTokens()) {
        String tok = st.nextToken();
        if (tok.equals("/"))
            newUri += "/";
        else if (tok.equals(" "))
            newUri += "%20";
        else {
            newUri += URLEncoder.encode(tok);
        // For Java 1.4 you'll want to use this instead:
        // try { newUri += URLEncoder.encode( tok, "UTF-8" ); } catch (
        // java.io.UnsupportedEncodingException uee ) {}
        }
    }
    return newUri;
}

54. NanoHTTPD#encodeUri()

Project: bnd
Source File: NanoHTTPD.java
View license
/**
	 * URL-encodes everything between "/"-characters. Encodes spaces as '%20'
	 * instead of '+'.
	 */
private static String encodeUri(String uri) {
    String newUri = "";
    StringTokenizer st = new StringTokenizer(uri, "/ ", true);
    while (st.hasMoreTokens()) {
        String tok = st.nextToken();
        if (tok.equals("/"))
            newUri += "/";
        else if (tok.equals(" "))
            newUri += "%20";
        else {
            try {
                newUri += URLEncoder.encode(tok, "UTF-8");
            } catch (java.io.UnsupportedEncodingException uee) {
            }
        }
    }
    return newUri;
}

55. ServiceComponentAttribs#parseList()

View license
private static List<String> parseList(String string) {
    if (string == null)
        return null;
    List<String> result = new ArrayList<String>();
    StringTokenizer tokenizer = new StringTokenizer(string, ",");
    while (tokenizer.hasMoreTokens()) {
        result.add(tokenizer.nextToken().trim());
    }
    return result;
}

56. BValVersion#toString()

Project: bval
Source File: BValVersion.java
View license
/**
     * {@inheritDoc}
     */
public String toString() {
    StringBuilder buf = new StringBuilder(80 * 40);
    appendBanner(buf);
    buf.append("\n");
    appendProperty("os.name", buf).append("\n");
    appendProperty("os.version", buf).append("\n");
    appendProperty("os.arch", buf).append("\n\n");
    appendProperty("java.version", buf).append("\n");
    appendProperty("java.vendor", buf).append("\n\n");
    buf.append("java.class.path:\n");
    StringTokenizer tok = new StringTokenizer(PrivilegedActions.getProperty("java.class.path"));
    while (tok.hasMoreTokens()) {
        buf.append("\t").append(tok.nextToken());
        buf.append("\n");
    }
    buf.append("\n");
    appendProperty("user.dir", buf).append("\n");
    return buf.toString();
}

57. AntPathMatcher#tokenizeToStringArray()

Project: camel
Source File: AntPathMatcher.java
View license
/**
     * Tokenize the given String into a String array via a StringTokenizer.
     * Trims tokens and omits empty tokens.
     * <p>
     * The given delimiters string is supposed to consist of any number of
     * delimiter characters. Each of those characters can be used to separate
     * tokens. A delimiter is always a single character; for multi-character
     * delimiters, consider using <code>delimitedListToStringArray</code>
     * 
     * @param str the String to tokenize
     * @param delimiters the delimiter characters, assembled as String (each of
     *            those characters is individually considered as delimiter).
     * @return an array of the tokens
     * @see java.util.StringTokenizer
     * @see java.lang.String#trim()
     */
public static String[] tokenizeToStringArray(String str, String delimiters) {
    if (str == null) {
        return null;
    }
    StringTokenizer st = new StringTokenizer(str, delimiters);
    List<String> tokens = new ArrayList<String>();
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        token = token.trim();
        if (token.length() > 0) {
            tokens.add(token);
        }
    }
    return tokens.toArray(new String[tokens.size()]);
}

58. CommentEntity#getMessageParts()

View license
public List<String> getMessageParts() {
    if (message == null) {
        return null;
    }
    List<String> messageParts = new ArrayList<String>();
    StringTokenizer tokenizer = new StringTokenizer(message, MESSAGE_PARTS_MARKER);
    while (tokenizer.hasMoreTokens()) {
        String nextToken = tokenizer.nextToken();
        if ("null".equals(nextToken)) {
            messageParts.add(null);
        } else {
            messageParts.add(nextToken);
        }
    }
    return messageParts;
}

59. UiUtils#computeStateMask()

Project: ccw
Source File: UiUtils.java
View license
/**
     * <i>[from org.eclipse.jdt]</i><br/>
     * Computes the state mask for the given modifier string (no trim is executed on the input string).
     *
     * @param modifiers	the string with the modifiers, separated by '+', '-', ';', ',' or '.'
     * @return the state mask or SWT.DEFAULT if the input is null or invalid or SWT.NONE if the input string is empty.
     */
public static int computeStateMask(@Nullable String modifiers) {
    if (modifiers == null) {
        return SWT.DEFAULT;
    }
    if (modifiers.length() == 0) {
        return SWT.NONE;
    }
    int stateMask = 0;
    //$NON-NLS-1$
    StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* ");
    while (modifierTokenizer.hasMoreTokens()) {
        int modifier = findLocalizedModifier(modifierTokenizer.nextToken());
        if (modifier == 0 || (stateMask & modifier) == modifier) {
            return SWT.DEFAULT;
        }
        stateMask = stateMask | modifier;
    }
    return stateMask;
}

60. StringUtils#getStringCollection()

Project: cdap
Source File: StringUtils.java
View license
/**
   * Returns a collection of strings.
   * @param str comma seperated string values
   * @return an <code>ArrayList</code> of string values
   */
public static Collection<String> getStringCollection(String str) {
    List<String> values = new ArrayList<>();
    if (str == null) {
        return values;
    }
    StringTokenizer tokenizer = new StringTokenizer(str, ",");
    values = new ArrayList<>();
    while (tokenizer.hasMoreTokens()) {
        values.add(tokenizer.nextToken());
    }
    return values;
}

61. MemoryClassLoader#toURLs()

Project: cdk
Source File: MemoryClassLoader.java
View license
private static URL[] toURLs(String classPath) {
    if (classPath == null) {
        return new URL[0];
    }
    List<URL> list = new ArrayList<URL>();
    StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        File file = new File(token);
        if (file.exists()) {
            try {
                list.add(file.toURI().toURL());
            } catch (MalformedURLException mue) {
            }
        } else {
            try {
                list.add(new URL(token));
            } catch (MalformedURLException mue) {
            }
        }
    }
    URL[] res = new URL[list.size()];
    list.toArray(res);
    return res;
}

62. Locations#pathToURLs()

Project: ceylon
Source File: Locations.java
View license
/**
     * Utility method for converting a search path string to an array
     * of directory and JAR file URLs.
     *
     * Note that this method is called by apt and the DocletInvoker.
     *
     * @param path the search path string
     * @return the resulting array of directory and JAR file URLs
     */
public static URL[] pathToURLs(String path) {
    StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
    URL[] urls = new URL[st.countTokens()];
    int count = 0;
    while (st.hasMoreTokens()) {
        URL url = fileToURL(new File(st.nextToken()));
        if (url != null) {
            urls[count++] = url;
        }
    }
    urls = Arrays.copyOf(urls, count);
    return urls;
}

63. Paths#pathToURLs()

Project: ceylon-compiler
Source File: Paths.java
View license
/**
     * Utility method for converting a search path string to an array
     * of directory and JAR file URLs.
     *
     * Note that this method is called by apt and the DocletInvoker.
     *
     * @param path the search path string
     * @return the resulting array of directory and JAR file URLs
     */
public static URL[] pathToURLs(String path) {
    StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
    URL[] urls = new URL[st.countTokens()];
    int count = 0;
    while (st.hasMoreTokens()) {
        URL url = fileToURL(new File(st.nextToken()));
        if (url != null) {
            urls[count++] = url;
        }
    }
    if (urls.length != count) {
        URL[] tmp = new URL[count];
        System.arraycopy(urls, 0, tmp, 0, count);
        urls = tmp;
    }
    return urls;
}

64. LogPanelLoggerTreeModel#tokenize()

View license
/**
     * Takes the loggerName and tokenizes it into it's
     * package name lements returning the elements
     * via the Stirng[]
     * @param loggerName
     * @return array of strings representing the package hierarchy
     */
private String[] tokenize(String loggerName) {
    StringTokenizer tok = new StringTokenizer(loggerName, ".");
    String[] tokens = new String[tok.countTokens()];
    int index = 0;
    while (tok.hasMoreTokens()) {
        tokens[index++] = tok.nextToken();
    }
    return tokens;
}

65. ReorgPolicyFactory#processCreateTargetExecutionRecord()

Project: che
Source File: ReorgPolicyFactory.java
View license
private static void processCreateTargetExecutionRecord(CreateTargetExecutionLog log, JavaRefactoringArguments arguments, String token) {
    final StringTokenizer tokenizer = new StringTokenizer(token, DELIMITER_ELEMENT, false);
    String value = null;
    if (tokenizer.hasMoreTokens()) {
        value = tokenizer.nextToken();
        Object selection = JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), value, false);
        if (selection == null)
            selection = JavaRefactoringDescriptorUtil.handleToResource(arguments.getProject(), value);
        if (selection != null && tokenizer.hasMoreTokens()) {
            value = tokenizer.nextToken();
            Object created = JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), value, false);
            if (created == null)
                created = JavaRefactoringDescriptorUtil.handleToResource(arguments.getProject(), value);
            if (created != null)
                log.markAsCreated(selection, created);
        }
    }
}

66. MembersOrderPreferenceCache#fillVisibilityOffsetsFromPreferenceString()

View license
private boolean fillVisibilityOffsetsFromPreferenceString(String str, int[] offsets) {
    //$NON-NLS-1$
    StringTokenizer tokenizer = new StringTokenizer(str, ",");
    int i = 0;
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken().trim();
        if (//$NON-NLS-1$
        "B".equals(token)) {
            offsets[PUBLIC_INDEX] = i++;
        } else if (//$NON-NLS-1$
        "V".equals(token)) {
            offsets[PRIVATE_INDEX] = i++;
        } else if (//$NON-NLS-1$
        "R".equals(token)) {
            offsets[PROTECTED_INDEX] = i++;
        } else if (//$NON-NLS-1$
        "D".equals(token)) {
            offsets[DEFAULT_INDEX] = i++;
        }
    }
    return i == N_VISIBILITIES;
}

67. AbstractSection#parseToFitInToolTips()

Project: uima-uimaj
Source File: AbstractSection.java
View license
// tool tips seem to require no blanks following /n on Windows.
protected static String parseToFitInToolTips(String text) {
    if (null == text)
        return "";
    StringBuffer buffer = new StringBuffer();
    final int MAGIC_LENGTH = 65;
    StringTokenizer tokenizer = new StringTokenizer(text);
    int lengthAccumulator = 0;
    while (tokenizer.hasMoreTokens()) {
        if (lengthAccumulator > 0) {
            buffer.append(' ');
        }
        String nextToken = tokenizer.nextToken();
        buffer.append(nextToken);
        lengthAccumulator += (nextToken.length() + 1);
        if (lengthAccumulator > MAGIC_LENGTH && tokenizer.hasMoreTokens()) {
            // this is to avoid a final blank line
            //$NON-NLS-1$
            buffer.append("\n");
            lengthAccumulator = 0;
        }
    }
    return new String(buffer);
}

68. UimaAcronymAnnotator#process()

View license
/**
   * @see JCasAnnotator_ImplBase#process(JCas)
   */
public void process(JCas aJCas) {
    // go through document word-by-word
    String text = aJCas.getDocumentText();
    int pos = 0;
    StringTokenizer tokenizer = new StringTokenizer(text, " \t\n\r.<.>/?\";:[{]}\\|=+()!", true);
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        // look up token in map to see if it is an acronym
        String expandedForm = mMap.get(token);
        if (expandedForm != null) {
            // create annotation
            UimaAcronym annot = new UimaAcronym(aJCas, pos, pos + token.length(), expandedForm);
            annot.addToIndexes();
        }
        // incrememnt pos and go to next token
        pos += token.length();
    }
}

69. AnnotationViewerMain#displayError()

View license
/**
   * Displays an error message to the user.
   * 
   * @param aErrorString
   *          error message to display
   */
public void displayError(String aErrorString) {
    // word-wrap long mesages
    StringBuffer buf = new StringBuffer(aErrorString.length());
    final int CHARS_PER_LINE = 80;
    int charCount = 0;
    StringTokenizer tokenizer = new StringTokenizer(aErrorString, " \n", true);
    while (tokenizer.hasMoreTokens()) {
        String tok = tokenizer.nextToken();
        if (tok.equals("\n")) {
            buf.append("\n");
            charCount = 0;
        } else if ((charCount > 0) && ((charCount + tok.length()) > CHARS_PER_LINE)) {
            buf.append("\n").append(tok);
            charCount = tok.length();
        } else {
            buf.append(tok);
            charCount += tok.length();
        }
    }
    JOptionPane.showMessageDialog(AnnotationViewerMain.this, buf.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}

70. CpmPanel#displayError()

Project: uima-uimaj
Source File: CpmPanel.java
View license
/**
   * Displays an error message to the user.
   * 
   * @param aErrorString
   *          error message to display
   */
public void displayError(String aErrorString) {
    // word-wrap long mesages
    StringBuffer buf = new StringBuffer(aErrorString.length());
    final int CHARS_PER_LINE = 80;
    int charCount = 0;
    StringTokenizer tokenizer = new StringTokenizer(aErrorString, " \n", true);
    while (tokenizer.hasMoreTokens()) {
        String tok = tokenizer.nextToken();
        if (tok.equals("\n")) {
            buf.append("\n");
            charCount = 0;
        } else if ((charCount > 0) && ((charCount + tok.length()) > CHARS_PER_LINE)) {
            buf.append("\n").append(tok);
            charCount = tok.length();
        } else {
            buf.append(tok);
            charCount += tok.length();
        }
    }
    JOptionPane.showMessageDialog(this, buf.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}

71. MainFrame#createLanguages()

Project: uima-uimaj
Source File: MainFrame.java
View license
public void createLanguages() {
    this.languages = new ArrayList<String>();
    if (this.languagePrefsList == null) {
        this.languagePrefsList = defaultLanguages;
    }
    if (this.language == null) {
        this.language = LANGUAGE_DEFAULT;
    }
    StringTokenizer tok = new StringTokenizer(this.languagePrefsList, ",");
    String lang;
    while (tok.hasMoreTokens()) {
        lang = tok.nextToken();
        if (!this.languages.contains(lang)) {
            this.languages.add(lang);
        }
    }
}

72. AnnotationViewerDialog#displayError()

View license
/**
   * Displays an error message to the user.
   * 
   * @param aErrorString
   *          error message to display
   */
public void displayError(String aErrorString) {
    // word-wrap long mesages
    StringBuffer buf = new StringBuffer(aErrorString.length());
    final int CHARS_PER_LINE = 80;
    int charCount = 0;
    StringTokenizer tokenizer = new StringTokenizer(aErrorString, " \n", true);
    while (tokenizer.hasMoreTokens()) {
        String tok = tokenizer.nextToken();
        if (tok.equals("\n")) {
            buf.append("\n");
            charCount = 0;
        } else if ((charCount > 0) && ((charCount + tok.length()) > CHARS_PER_LINE)) {
            buf.append("\n").append(tok);
            charCount = tok.length();
        } else {
            buf.append(tok);
            charCount += tok.length();
        }
    }
    JOptionPane.showMessageDialog(AnnotationViewerDialog.this, buf.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}

73. DocumentAnalyzer#displayError()

Project: uima-uimaj
Source File: DocumentAnalyzer.java
View license
/**
   * Displays an error message to the user.
   * 
   * @param aErrorString
   *          error message to display
   */
public void displayError(String aErrorString) {
    // word-wrap long mesages
    StringBuffer buf = new StringBuffer(aErrorString.length());
    final int CHARS_PER_LINE = 80;
    int charCount = 0;
    StringTokenizer tokenizer = new StringTokenizer(aErrorString, " \n", true);
    while (tokenizer.hasMoreTokens()) {
        String tok = tokenizer.nextToken();
        if (tok.equals("\n")) {
            buf.append("\n");
            charCount = 0;
        } else if ((charCount > 0) && ((charCount + tok.length()) > CHARS_PER_LINE)) {
            buf.append("\n").append(tok);
            charCount = tok.length();
        } else {
            buf.append(tok);
            charCount += tok.length();
        }
    }
    JOptionPane.showMessageDialog(DocumentAnalyzer.this, buf.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}

74. AbstractComponent#setStyleName()

Project: vaadin
Source File: AbstractComponent.java
View license
/*
     * Sets the component's style. Don't add a JavaDoc comment here, we use the
     * default documentation from implemented interface.
     */
@Override
public void setStyleName(String style) {
    if (style == null || "".equals(style)) {
        getState().styles = null;
        return;
    }
    if (getState().styles == null) {
        getState().styles = new ArrayList<String>();
    }
    List<String> styles = getState().styles;
    styles.clear();
    StringTokenizer tokenizer = new StringTokenizer(style, " ");
    while (tokenizer.hasMoreTokens()) {
        styles.add(tokenizer.nextToken());
    }
}

75. StringUtils#removeAndHump()

Project: velocity-engine
Source File: StringUtils.java
View license
/**
     * <p>
     * '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;
    StringBuffer out = new StringBuffer();
    temp = data;
    StringTokenizer st = new StringTokenizer(temp, replaceThis);
    while (st.hasMoreTokens()) {
        String element = (String) st.nextElement();
        out.append(capitalizeFirstLetter(element));
    }
    return out.toString();
}

76. ZaurusEditor#getWords()

Project: voltdb
Source File: ZaurusEditor.java
View license
// convert the search words in the textfield to an array of words
private String[] getWords() {
    StringTokenizer tokenizer = new StringTokenizer(fSearchWords.getText());
    String[] result = new String[tokenizer.countTokens()];
    int i = 0;
    while (tokenizer.hasMoreTokens()) {
        result[i++] = tokenizer.nextToken();
    }
    return result;
}

77. Which#parse()

Project: which
Source File: Which.java
View license
protected String[] parse(String path, String pathSeparator) {
    Vector pathList = new Vector();
    StringTokenizer pathTokenizer = new StringTokenizer(path, pathSeparator);
    while (pathTokenizer.hasMoreTokens()) {
        String pathElement = pathTokenizer.nextToken();
        pathList.addElement(pathElement);
    }
    String[] paths = new String[pathList.size()];
    pathList.copyInto(paths);
    return paths;
}

78. Which#parse()

Project: which
Source File: Which.java
View license
protected String[] parse(String path) {
    String pathSeparator = System.getProperty("path.separator");
    Vector pathList = new Vector();
    StringTokenizer pathTokenizer = new StringTokenizer(path, pathSeparator);
    while (pathTokenizer.hasMoreTokens()) {
        String pathElement = pathTokenizer.nextToken();
        pathList.addElement(pathElement);
    }
    String[] paths = new String[pathList.size()];
    pathList.copyInto(paths);
    return paths;
}

79. StringList#tokenize()

Project: wicket
Source File: StringList.java
View license
/**
	 * Extracts tokens from a delimited string.
	 * 
	 * @param string
	 *            The string
	 * @param delimiters
	 *            The delimiters
	 * @return The string tokens as a list
	 */
public static StringList tokenize(final String string, final String delimiters) {
    final StringTokenizer tokenizer = new StringTokenizer(string, delimiters);
    final StringList strings = new StringList();
    while (tokenizer.hasMoreTokens()) {
        strings.add(tokenizer.nextToken());
    }
    return strings;
}

80. ConversionExceptionTest#testDebugMessageIsNotNested()

View license
public void testDebugMessageIsNotNested() {
    Exception ex = new CannotResolveClassException("JUnit");
    ConversionException innerEx = new ConversionException("Inner", ex);
    ConversionException outerEx = new ConversionException("Outer", innerEx);
    StringTokenizer tokenizer = new StringTokenizer(outerEx.getMessage(), "\n\r");
    int ends = 0;
    while (tokenizer.hasMoreTokens()) {
        if (tokenizer.nextToken().startsWith("---- Debugging information ----")) {
            ++ends;
        }
    }
    assertEquals(1, ends);
}

81. NewCollationAnalyzerTask#setParams()

View license
@Override
public void setParams(String params) {
    super.setParams(params);
    StringTokenizer st = new StringTokenizer(params, ",");
    while (st.hasMoreTokens()) {
        String param = st.nextToken();
        StringTokenizer expr = new StringTokenizer(param, ":");
        String key = expr.nextToken();
        String value = expr.nextToken();
        // TODO: add strength, decomposition, etc
        if (key.equals("impl")) {
            if (value.equalsIgnoreCase("icu"))
                impl = Implementation.ICU;
            else if (value.equalsIgnoreCase("jdk"))
                impl = Implementation.JDK;
            else
                throw new RuntimeException("Unknown parameter " + param);
        } else {
            throw new RuntimeException("Unknown parameter " + param);
        }
    }
}

82. Config#propToStringArray()

Project: lucene-solr
Source File: Config.java
View license
private String[] propToStringArray(String s) {
    if (s.indexOf(":") < 0) {
        return new String[] { s };
    }
    ArrayList<String> a = new ArrayList<>();
    StringTokenizer st = new StringTokenizer(s, ":");
    while (st.hasMoreTokens()) {
        String t = st.nextToken();
        a.add(t);
    }
    return a.toArray(new String[a.size()]);
}

83. Config#propToIntArray()

Project: lucene-solr
Source File: Config.java
View license
// extract properties to array, e.g. for "10:100:5" return int[]{10,100,5}. 
private int[] propToIntArray(String s) {
    if (s.indexOf(":") < 0) {
        return new int[] { Integer.parseInt(s) };
    }
    ArrayList<Integer> a = new ArrayList<>();
    StringTokenizer st = new StringTokenizer(s, ":");
    while (st.hasMoreTokens()) {
        String t = st.nextToken();
        a.add(Integer.valueOf(t));
    }
    int res[] = new int[a.size()];
    for (int i = 0; i < a.size(); i++) {
        res[i] = a.get(i).intValue();
    }
    return res;
}

84. Config#propToDoubleArray()

Project: lucene-solr
Source File: Config.java
View license
// extract properties to array, e.g. for "10.7:100.4:-2.3" return int[]{10.7,100.4,-2.3}. 
private double[] propToDoubleArray(String s) {
    if (s.indexOf(":") < 0) {
        return new double[] { Double.parseDouble(s) };
    }
    ArrayList<Double> a = new ArrayList<>();
    StringTokenizer st = new StringTokenizer(s, ":");
    while (st.hasMoreTokens()) {
        String t = st.nextToken();
        a.add(Double.valueOf(t));
    }
    double res[] = new double[a.size()];
    for (int i = 0; i < a.size(); i++) {
        res[i] = a.get(i).doubleValue();
    }
    return res;
}

85. Config#propToBooleanArray()

Project: lucene-solr
Source File: Config.java
View license
// extract properties to array, e.g. for "true:true:false" return boolean[]{true,false,false}. 
private boolean[] propToBooleanArray(String s) {
    if (s.indexOf(":") < 0) {
        return new boolean[] { Boolean.valueOf(s).booleanValue() };
    }
    ArrayList<Boolean> a = new ArrayList<>();
    StringTokenizer st = new StringTokenizer(s, ":");
    while (st.hasMoreTokens()) {
        String t = st.nextToken();
        a.add(new Boolean(t));
    }
    boolean res[] = new boolean[a.size()];
    for (int i = 0; i < a.size(); i++) {
        res[i] = a.get(i).booleanValue();
    }
    return res;
}

86. TestQueryTemplateManager#getPropsFromString()

View license
//Helper method to construct Lucene query forms used in our test
Properties getPropsFromString(String nameValuePairs) {
    Properties result = new Properties();
    StringTokenizer st = new StringTokenizer(nameValuePairs, "\t=");
    while (st.hasMoreTokens()) {
        String name = st.nextToken().trim();
        if (st.hasMoreTokens()) {
            String value = st.nextToken().trim();
            result.setProperty(name, value);
        }
    }
    return result;
}

87. TestQueryTemplateManager#getDocumentFromString()

View license
//Helper method to construct Lucene documents used in our tests
org.apache.lucene.document.Document getDocumentFromString(String nameValuePairs) {
    org.apache.lucene.document.Document result = new org.apache.lucene.document.Document();
    StringTokenizer st = new StringTokenizer(nameValuePairs, "\t=");
    while (st.hasMoreTokens()) {
        String name = st.nextToken().trim();
        if (st.hasMoreTokens()) {
            String value = st.nextToken().trim();
            result.add(newTextField(name, value, Field.Store.YES));
        }
    }
    return result;
}

88. ReplicationService#getPathElements()

Project: lucene-solr
Source File: ReplicationService.java
View license
/**
   * Returns the path elements that were given in the servlet request, excluding
   * the servlet's action context.
   */
private String[] getPathElements(HttpServletRequest req) {
    String path = req.getServletPath();
    String pathInfo = req.getPathInfo();
    if (pathInfo != null) {
        path += pathInfo;
    }
    int actionLen = REPLICATION_CONTEXT.length();
    int startIdx = actionLen;
    if (path.length() > actionLen && path.charAt(actionLen) == '/') {
        ++startIdx;
    }
    // split the string on '/' and remove any empty elements. This is better
    // than using String.split() since the latter may return empty elements in
    // the array
    StringTokenizer stok = new StringTokenizer(path.substring(startIdx), "/");
    ArrayList<String> elements = new ArrayList<>();
    while (stok.hasMoreTokens()) {
        elements.add(stok.nextToken());
    }
    return elements.toArray(new String[0]);
}

89. NanoHTTPD#encodeUri()

Project: jsonapi
Source File: NanoHTTPD.java
View license
/**
	 * URL-encodes everything between "/"-characters. Encodes spaces as '%20'
	 * instead of '+'.
	 */
private String encodeUri(String uri) {
    StringBuffer newUri = new StringBuffer();
    StringTokenizer st = new StringTokenizer(uri, "/ ", true);
    while (st.hasMoreTokens()) {
        String tok = st.nextToken();
        if (tok.equals("/"))
            newUri.append("/");
        else if (tok.equals(" "))
            newUri.append("%20");
        else {
            // For Java 1.4 you'll want to use this instead:
            try {
                newUri.append(URLEncoder.encode(tok, "UTF-8"));
            } catch (UnsupportedEncodingException uee) {
                uee.printStackTrace();
            }
            ;
        }
    }
    return newUri.toString();
}

90. MemoryClassLoader#toURLs()

Project: kite
Source File: MemoryClassLoader.java
View license
private static URL[] toURLs(String classPath) {
    if (classPath == null) {
        return new URL[0];
    }
    List<URL> list = new ArrayList<URL>();
    StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        File file = new File(token);
        if (file.exists()) {
            try {
                list.add(file.toURI().toURL());
            } catch (MalformedURLException mue) {
            }
        } else {
            try {
                list.add(new URL(token));
            } catch (MalformedURLException mue) {
            }
        }
    }
    URL[] res = new URL[list.size()];
    list.toArray(res);
    return res;
}

91. KCHTTPDPooled#encodeUri()

Project: kerkee_android
Source File: KCHTTPDPooled.java
View license
/**
     * URL-encodes everything between "/"-characters. Encodes spaces as '%20' instead of '+'.
     */
private String encodeUri(String uri) {
    String newUri = "";
    StringTokenizer st = new StringTokenizer(uri, "/ ", true);
    while (st.hasMoreTokens()) {
        String tok = st.nextToken();
        if (tok.equals("/"))
            newUri += "/";
        else if (tok.equals(" "))
            newUri += "%20";
        else {
            newUri += URLEncoder.encode(tok);
        // For Java 1.4 you'll want to use this instead:
        // try { newUri += URLEncoder.encode( tok, "UTF-8" ); } catch (
        // java.io.UnsupportedEncodingException uee ) {}
        }
    }
    return newUri;
}

92. FelixLaunchHelper#getBundles()

Project: karaf-eik
Source File: FelixLaunchHelper.java
View license
public static List<BundleEntry> getBundles(String source) {
    final List<BundleEntry> bundles = new ArrayList<BundleEntry>();
    final StringTokenizer tok = new StringTokenizer(source, ",");
    while (tok.hasMoreTokens()) {
        final String bundle = tok.nextToken();
        final BundleEntry entry = BundleEntry.fromString(bundle);
        bundles.add(entry);
    }
    return bundles;
}

93. AntPathMatcher#tokenizeToStringArray()

Project: jvm-tools
Source File: AntPathMatcher.java
View license
/**
	 * Tokenize the given String into a String array via a StringTokenizer.
	 * <p>The given delimiters string is supposed to consist of any number of
	 * delimiter characters. Each of those characters can be used to separate
	 * tokens. A delimiter is always a single character; for multi-character
	 * delimiters, consider using {@code delimitedListToStringArray}
	 * @param str the String to tokenize
	 * @param delimiters the delimiter characters, assembled as String
	 * (each of those characters is individually considered as delimiter)
	 * @param trimTokens trim the tokens via String's {@code trim}
	 * @param ignoreEmptyTokens omit empty tokens from the result array
	 * (only applies to tokens that are empty after trimming; StringTokenizer
	 * will not consider subsequent delimiters as token in the first place).
	 * @return an array of the tokens ({@code null} if the input String
	 * was {@code null})
	 * @see java.util.StringTokenizer
	 * @see String#trim()
	 * @see #delimitedListToStringArray
	 */
private static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {
    if (str == null) {
        return null;
    }
    StringTokenizer st = new StringTokenizer(str, delimiters);
    List<String> tokens = new ArrayList<String>();
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (trimTokens) {
            token = token.trim();
        }
        if (!ignoreEmptyTokens || token.length() > 0) {
            tokens.add(token);
        }
    }
    return toStringArray(tokens);
}

94. EnumerationHelper#getConceptByPath()

Project: juddi-scout
Source File: EnumerationHelper.java
View license
public static Concept getConceptByPath(String path) throws IllegalArgumentException, JAXRException {
    //Lets tokenize the path
    StringTokenizer tokenizer = new StringTokenizer(path, "/");
    String firstToken = null;
    String secondToken = null;
    if (tokenizer.hasMoreTokens()) {
        firstToken = tokenizer.nextToken();
        if (tokenizer.hasMoreTokens()) {
            secondToken = tokenizer.nextToken();
            if (tokenizer.hasMoreTokens()) {
                log.warn("Looking for 2 tokens. " + tokenizer.nextToken() + " will be ignored");
            }
        } else {
            throw new IllegalArgumentException("Expected two token separated with a forward slash (/)");
        }
    } else {
        throw new IllegalArgumentException("Expected two token separated with a forward slash (/)");
    }
    return createConcept(firstToken, secondToken);
}

95. ValidateUDDIKey#isValidDomainKey()

Project: juddi
Source File: ValidateUDDIKey.java
View license
public static boolean isValidDomainKey(String token) {
    if (token.indexOf("..") != -1)
        return false;
    StringTokenizer tokenizer = new StringTokenizer(token, ".");
    int tokensCount = tokenizer.countTokens();
    for (int i = 0; tokenizer.hasMoreTokens(); i++) {
        String domainPart = tokenizer.nextToken();
        if (i == tokensCount - 1) {
            if (!isValidTopLabel(domainPart)) {
                return false;
            }
        } else if (!isValidDomainLabel(domainPart)) {
            return false;
        }
    }
    return true;
}

96. DynamicQuery#buildJPAQuery()

Project: juddi
Source File: DynamicQuery.java
View license
public Query buildJPAQuery(EntityManager em) {
    StringTokenizer tokenizer = new StringTokenizer(sql.toString(), "?");
    StringBuffer sqlBuffer = new StringBuffer();
    int numberOfTokens = tokenizer.countTokens();
    for (int i = 1; i < numberOfTokens; i++) {
        sqlBuffer.append(tokenizer.nextToken() + "?" + i);
    }
    if (tokenizer.hasMoreTokens())
        sqlBuffer.append(tokenizer.nextToken());
    Query qry = em.createQuery(sqlBuffer.toString());
    for (int i = 0; i < values.size(); i++) qry.setParameter(i + 1, values.elementAt(i));
    return qry;
}

97. ShellBasedGroupsMapping#getUnixGroups()

Project: jstorm
Source File: ShellBasedGroupsMapping.java
View license
/**
     * Get the current user's group list from Unix by running the command 'groups' NOTE. For non-existing user it will return EMPTY list
     * 
     * @param user user name
     * @return the groups set that the <code>user</code> belongs to
     * @throws IOException if encounter any error when running the command
     */
private static Set<String> getUnixGroups(final String user) throws IOException {
    String result = "";
    try {
        result = ShellUtils.execCommand(ShellUtils.getGroupsForUserCommand(user));
    } catch (ExitCodeException e) {
        LOG.warn("got exception trying to get groups for user " + user, e);
        return new HashSet<String>();
    }
    StringTokenizer tokenizer = new StringTokenizer(result, ShellUtils.TOKEN_SEPARATOR_REGEX);
    Set<String> groups = new HashSet<String>();
    while (tokenizer.hasMoreTokens()) {
        groups.add(tokenizer.nextToken());
    }
    return groups;
}

98. PkgInfo#extractTokens()

Project: jooc-legacy
Source File: PkgInfo.java
View license
protected void extractTokens(String prefix, String string, List<String> list) {
    int prefixLength = prefix.length();
    StringTokenizer st = new StringTokenizer(string);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.startsWith(prefix)) {
            list.add(token.substring(prefixLength).trim());
        }
    }
}

99. DistLocator#tryClassPath()

Project: jooc-legacy
Source File: DistLocator.java
View license
/** 
	 * Assume we're launched with java -jar bin/ooc.jar or
	 * java -classpath path/to/ooc/build/classes/ org.ooc.frontend.CommandLine
	 * and try to find ourselves in the classpath.
	 */
protected static File tryClassPath() {
    String classPath = System.getProperty("java.class.path");
    StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        String base = "";
        for (// brute force. works for the .class and the .jar methods
        int i = 0; // brute force. works for the .class and the .jar methods
        i < 8; // brute force. works for the .class and the .jar methods
        i++) {
            base += "../";
            try {
                File distribLocation = new File(token, base).getCanonicalFile();
                File idFile = FileUtils.resolveRedundancies(new File(distribLocation, "sdk/ooc_sdk_id"));
                if (idFile.exists()) {
                    return FileUtils.resolveRedundancies(distribLocation);
                }
            } catch (IOException e) {
            }
        }
    }
    return null;
}

100. CryptographicServiceMessage#parse()

View license
/**
     * Parses a csm string
     * @param csmString
     * @return CSM object
     * @throws ParsingException
     */
public static CryptographicServiceMessage parse(String csmString) throws ParsingException {
    CryptographicServiceMessage csm = new CryptographicServiceMessage();
    StringTokenizer st = new StringTokenizer(csmString, "() \t\n\r\f");
    if (!st.nextToken().equalsIgnoreCase("CSM"))
        throw new ParsingException("Invalid CSM, doesn't start with the \"CSM(\" tag: " + csmString);
    do {
        String field = st.nextToken();
        int separatorIndex = field.indexOf('/');
        if (separatorIndex > 0) {
            String tag = field.substring(0, separatorIndex).toUpperCase();
            String content = "";
            if (separatorIndex < field.length())
                content = field.substring(separatorIndex + 1);
            if (tag.equalsIgnoreCase("MCL"))
                csm.setMCL(content);
            else
                csm.addField(tag, content);
        } else
            throw new ParsingException("Invalid field, doesn't have a tag: " + field);
    } while (st.hasMoreTokens());
    if (csm.getMCL() == null)
        throw new ParsingException("Invalid CSM, doesn't contain an MCL: " + csmString);
    return csm;
}