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. 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;
}

3. 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;
}

4. 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);
}

5. 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;
}

6. RequestStatus#setValue()

Project: ical4j
Source File: RequestStatus.java
View license
/**
     * [email protected]}
     */
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();
    }
}

7. 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();
}

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. 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();
}

10. 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();
}

11. 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();
}

12. 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;
}

13. 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;
}

14. 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;
}

15. 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;
}

16. 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;
}

17. 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());
}

18. 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);
    }
}

19. 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);
    }
}

20. 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);
    }
}

21. 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());
}

22. JNDIUtil#createContext()

Project: activemq-artemis
Source File: JNDIUtil.java
View license
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
/**
    * Create a context path recursively.
    */
public static Context createContext(final Context c, final String path) throws NamingException {
    Context crtContext = c;
    for (StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens(); ) {
        String tok = st.nextToken();
        try {
            Object o = crtContext.lookup(tok);
            if (!(o instanceof Context)) {
                throw new NamingException("Path " + path + " overwrites and already bound object");
            }
            crtContext = (Context) o;
            continue;
        } catch (NameNotFoundException e) {
        }
        crtContext = crtContext.createSubcontext(tok);
    }
    return crtContext;
}

23. StompFrameFactoryV10#createFrame()

View license
@Override
public ClientStompFrame createFrame(String data) {
    //split the string at "\n\n"
    String[] dataFields = data.split("\n\n");
    StringTokenizer tokenizer = new StringTokenizer(dataFields[0], "\n");
    String command = tokenizer.nextToken();
    ClientStompFrame frame = new ClientStompFrameV10(command);
    while (tokenizer.hasMoreTokens()) {
        String header = tokenizer.nextToken();
        String[] fields = header.split(":");
        frame.addHeader(fields[0], fields[1]);
    }
    //body (without null byte)
    if (dataFields.length == 2) {
        frame.setBody(dataFields[1]);
    }
    return frame;
}

24. StompFrameFactoryV11#createFrame()

View license
@Override
public ClientStompFrame createFrame(final String data) {
    //split the string at "\n\n"
    String[] dataFields = data.split("\n\n");
    StringTokenizer tokenizer = new StringTokenizer(dataFields[0], "\n");
    String command = tokenizer.nextToken();
    ClientStompFrame frame = new ClientStompFrameV11(command);
    while (tokenizer.hasMoreTokens()) {
        String header = tokenizer.nextToken();
        String[] fields = splitAndDecodeHeader(header);
        frame.addHeader(fields[0], fields[1]);
    }
    //body (without null byte)
    if (dataFields.length == 2) {
        frame.setBody(dataFields[1]);
    }
    return frame;
}

25. StompFrameFactoryV12#createFrame()

View license
@Override
public ClientStompFrame createFrame(String data) {
    //split the string at "\n\n"
    String[] dataFields = data.split("\n\n");
    StringTokenizer tokenizer = new StringTokenizer(dataFields[0], "\n");
    String command = tokenizer.nextToken();
    ClientStompFrame frame = new ClientStompFrameV12(command);
    while (tokenizer.hasMoreTokens()) {
        String header = tokenizer.nextToken();
        String[] fields = splitAndDecodeHeader(header);
        frame.addHeader(fields[0], fields[1]);
    }
    //body (without null byte)
    if (dataFields.length == 2) {
        frame.setBody(dataFields[1]);
    }
    return frame;
}

26. ObjectMessageTest#newClassLoader()

View license
protected static ClassLoader newClassLoader(final Class anyUserClass) throws Exception {
    URL classLocation = anyUserClass.getProtectionDomain().getCodeSource().getLocation();
    StringTokenizer tokenString = new StringTokenizer(System.getProperty("java.class.path"), File.pathSeparator);
    String pathIgnore = System.getProperty("java.home");
    if (pathIgnore == null) {
        pathIgnore = classLocation.toString();
    }
    ArrayList<URL> urls = new ArrayList<>();
    while (tokenString.hasMoreElements()) {
        String value = tokenString.nextToken();
        URL itemLocation = new File(value).toURI().toURL();
        if (!itemLocation.equals(classLocation) && itemLocation.toString().indexOf(pathIgnore) >= 0) {
            urls.add(itemLocation);
        }
    }
    URL[] urlArray = urls.toArray(new URL[urls.size()]);
    ClassLoader masterClassLoader = URLClassLoader.newInstance(urlArray, null);
    ClassLoader appClassLoader = URLClassLoader.newInstance(new URL[] { classLocation }, masterClassLoader);
    return appClassLoader;
}

27. ObjectInputStreamWithClassLoaderTest#newClassLoader()

View license
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
public static ClassLoader newClassLoader(final Class anyUserClass) throws Exception {
    ProtectionDomain protectionDomain = anyUserClass.getProtectionDomain();
    CodeSource codeSource = protectionDomain.getCodeSource();
    URL classLocation = codeSource.getLocation();
    StringTokenizer tokenString = new StringTokenizer(System.getProperty("java.class.path"), File.pathSeparator);
    String pathIgnore = System.getProperty("java.home");
    if (pathIgnore == null) {
        pathIgnore = classLocation.toString();
    }
    List<URL> urls = new ArrayList<>();
    while (tokenString.hasMoreElements()) {
        String value = tokenString.nextToken();
        URL itemLocation = new File(value).toURI().toURL();
        if (!itemLocation.equals(classLocation) && itemLocation.toString().indexOf(pathIgnore) >= 0) {
            urls.add(itemLocation);
        }
    }
    URL[] urlArray = urls.toArray(new URL[urls.size()]);
    ClassLoader masterClassLoader = URLClassLoader.newInstance(urlArray, null);
    ClassLoader appClassLoader = URLClassLoader.newInstance(new URL[] { classLocation }, masterClassLoader);
    return appClassLoader;
}

28. SmilesRecentsController#loadRecents()

View license
private void loadRecents() {
    SharedPreferences prefs = getPreferences();
    String str = prefs.getString(PREF_RECENTS, "");
    StringTokenizer tokenizer = new StringTokenizer(str, "~");
    while (tokenizer.hasMoreTokens()) {
        try {
            add(Long.valueOf(tokenizer.nextToken()));
        } catch (NumberFormatException e) {
        }
    }
}

29. Api#getListFromPref()

Project: afwall
Source File: Api.java
View license
private static List<Integer> getListFromPref(String savedPkg_uid) {
    StringTokenizer tok = new StringTokenizer(savedPkg_uid, "|");
    List<Integer> listUids = new ArrayList<Integer>();
    while (tok.hasMoreTokens()) {
        String uid = tok.nextToken();
        if (!uid.equals("")) {
            try {
                listUids.add(Integer.parseInt(uid));
            } catch (Exception ex) {
            }
        }
    }
    // Sort the array to allow using "Arrays.binarySearch" later
    Collections.sort(listUids);
    return listUids;
}

30. Api#removePackageRef()

Project: afwall
Source File: Api.java
View license
private static boolean removePackageRef(Context ctx, String pkg, int pkgRemoved, Editor editor, String store) {
    StringBuilder newuids = new StringBuilder();
    StringTokenizer tok = new StringTokenizer(pkg, "|");
    boolean changed = false;
    String uid_str = pkgRemoved + "";
    while (tok.hasMoreTokens()) {
        String token = tok.nextToken();
        if (uid_str.equals(token)) {
            changed = true;
        } else {
            if (newuids.length() > 0)
                newuids.append('|');
            newuids.append(token);
        }
    }
    if (changed) {
        editor.putString(store, newuids.toString());
    }
    return changed;
}

31. ImportApi#getPackageListFromUID()

Project: afwall
Source File: ImportApi.java
View license
private static String getPackageListFromUID(Context ctx, final String uids) {
    final PackageManager pm = ctx.getPackageManager();
    final StringBuilder pkg = new StringBuilder();
    final StringTokenizer tok = new StringTokenizer(uids, "|");
    while (tok.hasMoreTokens()) {
        final int uid = Integer.parseInt(tok.nextToken());
        String[] pack = pm.getPackagesForUid(uid);
        if (pack != null && pack.length == 1) {
            pkg.append(pack[0] + "|");
        }
        if (uid == 1000) {
            pkg.append("android|");
        }
    }
    return pkg.toString();
}

32. StreamServer#encodeUri()

Project: AmazeFileManager
Source File: StreamServer.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;
}

33. StringUtils#tokenizeToStringArray()

Project: Android-Next
Source File: StringUtils.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 StringTokenizer
     * @see 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<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);
}

34. Match#split()

Project: ant-ivy
Source File: Match.java
View license
private static String[] split(String string) {
    if (string == null) {
        return new String[0];
    }
    StringTokenizer tokenizer = new StringTokenizer(string, ", ");
    List tokens = new ArrayList();
    while (tokenizer.hasMoreTokens()) {
        tokens.add(tokenizer.nextToken());
    }
    return (String[]) tokens.toArray(new String[tokens.size()]);
}

35. RobotRulesParser#setConf()

Project: anthelion
Source File: RobotRulesParser.java
View license
/* ---------------------------------- *
   * <implementation:Configurable> *
   * ---------------------------------- */
public void setConf(Configuration conf) {
    this.conf = conf;
    allowForbidden = conf.getBoolean("http.robots.403.allow", false);
    //
    // Grab the agent names we advertise to robots files.
    //
    String agentName = conf.get("http.agent.name");
    String agentNames = conf.get("http.robots.agents");
    StringTokenizer tok = new StringTokenizer(agentNames, ",");
    ArrayList agents = new ArrayList();
    while (tok.hasMoreTokens()) {
        agents.add(tok.nextToken().trim());
    }
    setRobotNames((String[]) agents.toArray(new String[agents.size()]));
}

36. BlobStoreAPIWordCountTopology#parseFile()

View license
private static Set<String> parseFile(String fileName) throws IOException {
    File file = new File(fileName);
    Set<String> wordSet = new HashSet<>();
    if (!file.exists()) {
        return wordSet;
    }
    StringTokenizer tokens = new StringTokenizer(readFile(file).toString(), "\r\n");
    while (tokens.hasMoreElements()) {
        wordSet.add(tokens.nextToken());
    }
    LOG.debug("parseFile {}", wordSet);
    return wordSet;
}

37. ShellBasedGroupsMapping#getUnixGroups()

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.debug("unable to get groups for user " + user + ".ShellUtils command failed with exit code " + e.getExitCode());
        return new HashSet<>();
    }
    StringTokenizer tokenizer = new StringTokenizer(result, ShellUtils.TOKEN_SEPARATOR_REGEX);
    Set<String> groups = new HashSet<>();
    while (tokenizer.hasMoreTokens()) {
        groups.add(tokenizer.nextToken());
    }
    return groups;
}

38. AvroToPojo#createFieldInfoMap()

Project: apex-malhar
Source File: AvroToPojo.java
View license
/**
   * Creates a map representing fieldName in POJO:field in Generic Record:Data
   * type
   * 
   * @return List of FieldInfo
   */
private List<FieldInfo> createFieldInfoMap(String str) {
    fieldInfos = new ArrayList<FieldInfo>();
    StringTokenizer strtok = new StringTokenizer(str, RECORD_SEPARATOR);
    while (strtok.hasMoreTokens()) {
        String[] token = strtok.nextToken().split(FIELD_SEPARATOR);
        try {
            fieldInfos.add(new FieldInfo(token[0], token[1], SupportType.valueOf(token[2])));
        } catch (Exception e) {
            LOG.error("Invalid support type", e);
        }
    }
    return fieldInfos;
}

39. StreamingJsonParser#createFieldInfoMap()

View license
/**
   * Creates a map representing fieldName in POJO:field in JSON:Data type
   * 
   * @return List of FieldInfo
   */
private List<FieldInfo> createFieldInfoMap(String str) {
    fieldInfos = new ArrayList<FieldInfo>();
    StringTokenizer strtok = new StringTokenizer(str, RECORD_SEPARATOR);
    while (strtok.hasMoreTokens()) {
        String[] token = strtok.nextToken().split(FIELD_SEPARATOR);
        try {
            fieldInfos.add(new FieldInfo(token[0], token[1], SupportType.valueOf(token[2])));
        } catch (Exception e) {
            LOG.error("Invalid support type", e);
        }
    }
    return fieldInfos;
}

40. TextUtils#format()

Project: atlasdb
Source File: TextUtils.java
View license
/**
     * Formats the text, inserting line breaks as necessary.
     *
     * @param f Font to use in calculation
     * @param text Text to format
     * @param maxWidth Maximum width of text
     * @param delim End of line delimiter
     * @return Formatted text
     */
public static String format(Font f, String text, int maxWidth, String delim) {
    FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f);
    StringTokenizer st = new StringTokenizer(text, " \t\n\r\f", true);
    StringBuilder all = new StringBuilder();
    StringBuilder curLine = new StringBuilder();
    while (st.hasMoreTokens()) {
        String tk = st.nextToken();
        append(fm, all, curLine, tk, maxWidth, delim);
        if (SwingUtilities.computeStringWidth(fm, curLine.toString()) > maxWidth) {
            curLine = truncate(fm, all, tk, maxWidth, delim);
        }
    }
    return all.toString() + curLine.toString();
}

41. TemplateContentAssistProcessor#lookupNodeByPath()

View license
/**
     * Identifies the node in the document for the given path and returns it.
     *
     * @param document
     *            The document associated with the editor.
     * @param path
     *            The path from the Root to the node.
     */
private TemplateNode lookupNodeByPath(TemplateDocument document, String path) {
    TemplateNode node = ((TemplateDocument) document).getModel();
    if (path.startsWith("ROOT"))
        path = path.substring("ROOT".length());
    else
        throw new RuntimeException("Unexpected path encountered");
    StringTokenizer tokenizer = new StringTokenizer(path, "/");
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        if (node != null && node.isObject()) {
            TemplateObjectNode object = (TemplateObjectNode) node;
            node = object.get(token);
        } else {
            throw new RuntimeException("Unexpected node structure");
        }
    }
    return node;
}

42. Namespaces#javify()

Project: axis1-java
Source File: Namespaces.java
View license
// putAll
/**
     * Make sure each package name doesn't conflict with a Java keyword.
     * Ie., org.apache.import.test becomes org.apache.import_.test.
     * 
     * @param pkg 
     * @return 
     */
private String javify(String pkg) {
    StringTokenizer st = new StringTokenizer(pkg, ".");
    pkg = "";
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (JavaUtils.isJavaKeyword(token)) {
            token = JavaUtils.makeNonJavaKeyword(token);
        }
        pkg = pkg + token;
        if (st.hasMoreTokens()) {
            pkg = pkg + '.';
        }
    }
    return pkg;
}

43. ClasspathUtils#expandDirs()

Project: axis1-java
Source File: ClasspathUtils.java
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();
}

44. 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();
}

45. 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]);
}

46. 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;
}

47. 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;
}

48. 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;
}

49. 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;
}

50. 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;
}

51. 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;
}

52. 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;
}

53. 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;
}

54. 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;
}

55. 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();
}

56. 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);
}

57. 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);
}

58. 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();
}

59. 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();
}

60. 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;
}

61. 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"));
}

62. 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;
}

63. 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;
}

64. 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;
}

65. 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;
}

66. 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;
}

67. 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;
}

68. 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);
    }
}

69. 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;
}

70. 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();
}

71. 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;
}

72. 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;
}

73. 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;
}

74. 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;
}

75. 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;
}

76. 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;
}

77. BValVersion#toString()

Project: bval
Source File: BValVersion.java
View license
/**
     * [email protected]}
     */
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();
}

78. 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()]);
}

79. 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;
}

80. 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;
}

81. 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;
}

82. 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;
}

83. 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;
}

84. 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;
}

85. 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;
}

86. 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);
        }
    }
}

87. 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;
}

88. StubGenerator#formatType()

View license
/** outputs the simple name of the type */
private String formatType(Object typeRep) {
    StringTokenizer tokenizer = new StringTokenizer(typeRep.toString(), "()<>[], ", true);
    StringBuilder sb = new StringBuilder();
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        if (token.length() == 1 || token.lastIndexOf('.') == -1)
            sb.append(token);
        else {
            int index = token.lastIndexOf('.');
            sb.append(token.substring(index + 1));
        }
    }
    return sb.toString();
}

89. SimplePatternParser#text()

Project: clj-pdf
Source File: SimplePatternParser.java
View license
public void text(String str) {
    StringTokenizer tk = new StringTokenizer(str);
    while (tk.hasMoreTokens()) {
        String word = tk.nextToken();
        // System.out.println("\"" + word + "\"");
        switch(currElement) {
            case ELEM_CLASSES:
                consumer.addClass(word);
                break;
            case ELEM_EXCEPTIONS:
                exception.add(word);
                exception = normalizeException(exception);
                consumer.addException(getExceptionWord(exception), (ArrayList) exception.clone());
                exception.clear();
                break;
            case ELEM_PATTERNS:
                consumer.addPattern(getPattern(word), getInterletterValues(word));
                break;
        }
    }
}

90. FormatValidator#parseFormatPatterns()

Project: cocoon
Source File: FormatValidator.java
View license
/**
     * Parses the <code>formatPatterns</code> into validPatterns
     * <code>ArrayList</code>. The delimiter must be "|".
     */
public void parseFormatPatterns() {
    if (formatPatterns == null || formatPatterns.length() == 0) {
        return;
    }
    if (formatPatternsList != null) {
        // formatPatterns have been parsed already.
        return;
    } else {
        formatPatternsList = new ArrayList();
    }
    StringTokenizer st = new StringTokenizer(formatPatterns, "|");
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        formatPatternsList.add(token);
    }
}

91. JavaScriptBuilder#build()

Project: cocoon
Source File: JavaScriptBuilder.java
View license
public CalculatedFieldAlgorithm build(Element algorithmElement) throws Exception {
    JavaScript ret = new JavaScript();
    String fields = DomHelper.getAttribute(algorithmElement, "triggers");
    StringTokenizer stok = new StringTokenizer(fields, ", ");
    while (stok.hasMoreTokens()) {
        String fname = stok.nextToken();
        ret.addTriggerWidget(fname);
    }
    Function func = JavaScriptHelper.buildFunction(algorithmElement, "calculate", new String[] { "form", "parent" });
    ret.setJsfunction(func);
    return ret;
}

92. TreePath#valueOf()

Project: cocoon
Source File: TreePath.java
View license
/**
     * Returns the <code>TreePath</code> represented by a given String.
     * @param s the string representation of the path
     * @return a path object
     * 
     * @see #toString()
     */
public static TreePath valueOf(String s) {
    // FIXME: see if some caching could be useful here.
    if (s == null || s.length() == 0) {
        throw new IllegalArgumentException("Invalid empty string");
    }
    StringTokenizer stok = new StringTokenizer(s, "/");
    TreePath current = ROOT_PATH;
    while (stok.hasMoreTokens()) {
        String tok = stok.nextToken();
        current = current == null ? new TreePath(tok) : new TreePath(current, tok);
    }
    return current;
}

93. HTMLTransformer#setup()

Project: cocoon
Source File: HTMLTransformer.java
View license
/**
     * Setup this component, passing the tag names to be tidied.
     */
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
    super.setup(resolver, objectModel, src, par);
    String tagsParam = par.getParameter("tags", "");
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("tags: " + tagsParam);
    }
    this.tags = new HashMap();
    StringTokenizer tokenizer = new StringTokenizer(tagsParam, ",");
    while (tokenizer.hasMoreElements()) {
        String tok = tokenizer.nextToken().trim();
        this.tags.put(tok, tok);
    }
}

94. NekoHTMLTransformer#setup()

Project: cocoon
Source File: NekoHTMLTransformer.java
View license
/**
     * Setup this component, passing the tag names to be tidied.
     */
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
    super.setup(resolver, objectModel, src, par);
    String tagsParam = par.getParameter("tags", "");
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("tags: " + tagsParam);
    }
    this.tags = new HashMap();
    StringTokenizer tokenizer = new StringTokenizer(tagsParam, ",");
    while (tokenizer.hasMoreElements()) {
        String tok = tokenizer.nextToken().trim();
        this.tags.put(tok, tok);
    }
}

95. AffineTransformOperation#getFloatArray()

View license
private float[] getFloatArray(String values) {
    float[] fvalues = new float[30];
    int counter = 0;
    StringTokenizer st = new StringTokenizer(values, ",", false);
    for (int i = 0; st.hasMoreTokens(); i++) {
        String value = st.nextToken().trim();
        fvalues[i] = Float.parseFloat(value);
        counter = counter + 1;
    }
    float[] result = new float[counter];
    for (int i = 0; i < counter; i++) {
        result[i] = fvalues[i];
    }
    return result;
}

96. ConvolveOperation#getFloatArray()

Project: cocoon
Source File: ConvolveOperation.java
View license
private float[] getFloatArray(String values) {
    float[] fvalues = new float[30];
    int counter = 0;
    StringTokenizer st = new StringTokenizer(values, ",", false);
    for (int i = 0; st.hasMoreTokens(); i++) {
        String value = st.nextToken().trim();
        fvalues[i] = Float.parseFloat(value);
        counter = counter + 1;
    }
    float[] result = new float[counter];
    for (int i = 0; i < counter; i++) {
        result[i] = fvalues[i];
    }
    return result;
}

97. InterpolatingConfigurationHandler#interp()

View license
/**
     * Interpolate variable values into a string.
     *
     * @param str String with {var} tokens
     * @return <code>str</code>, with {variables} replaced by values.  If an
     * unknown variable token is encountered it is ignored.
     */
private String interp(String str) {
    StringBuffer buf = new StringBuffer(str.length() * 2);
    StringTokenizer tok = new StringTokenizer(str, "{}", true);
    // 0=outside, 1=inside
    int state = 0;
    while (tok.hasMoreTokens()) {
        String token = tok.nextToken();
        if (state == 0 && "{".equals(token)) {
            state = 1;
        } else if (state == 1 && "}".equals(token)) {
            state = 0;
        } else if (state == 0) {
            buf.append(token);
        } else if (state == 1) {
            //System.out.println("Replacing "+token+" with "+vars.get(token));
            String val = (String) vars.get(token);
            if (val == null) {
                buf.append("{").append(token).append("}");
            } else {
                buf.append(val);
            }
        }
    }
    return buf.toString();
}

98. LinkRewriterTransformer#split()

Project: cocoon
Source File: LinkRewriterTransformer.java
View license
/**
     * Split a string into a Set of strings.
     *
     * @param str String to split
     * @param delim Delimiter character
     * @return A Set of strings in 'str'
     */
private Set split(String str, String delim) {
    if (str == null) {
        return null;
    }
    Set tokens = new HashSet();
    StringTokenizer st = new StringTokenizer(str, delim);
    while (st.hasMoreTokens()) {
        tokens.add(st.nextToken());
    }
    return tokens;
}

99. LinkRewriterTransformer#split()

Project: cocoon
Source File: LinkRewriterTransformer.java
View license
/**
     * Split a string and create a Map where keys are the tokens from the string.
     *
     * @param str String to split
     * @param delim Delimiter character
     * @param valueObj Object to insert in the Map (may be null)
     * @return A Map of strings in 'str'
     */
private Map split(String str, String delim, Object valueObj) {
    if (str == null) {
        return null;
    }
    // valueObj may be null, because HashMap permits null values
    Map schemes = new HashMap();
    StringTokenizer st = new StringTokenizer(str, delim);
    while (st.hasMoreTokens()) {
        String pfx = st.nextToken();
        if (schemes.containsKey(pfx) && getLogger().isWarnEnabled()) {
            getLogger().warn("Duplicate configuration entry found for attribute '" + pfx + "', overwriting previous configuration");
        }
        schemes.put(pfx, valueObj);
    }
    return schemes;
}

100. RequestParameterEventAspect#process()

View license
/* (non-Javadoc)
	 * @see org.apache.cocoon.portal.event.aspect.EventAspect#process(org.apache.cocoon.portal.event.aspect.EventAspectContext, org.apache.cocoon.portal.PortalService)
	 */
public void process(EventAspectContext context, PortalService service) {
    final Request request = ObjectModelHelper.getRequest(context.getObjectModel());
    final Parameters config = context.getAspectParameters();
    final String requestParameterNames = config.getParameter("parameter-name", LinkService.DEFAULT_REQUEST_EVENT_PARAMETER_NAME);
    boolean processedDefault = false;
    StringTokenizer tokenizer = new StringTokenizer(requestParameterNames, ", ");
    while (tokenizer.hasMoreTokens()) {
        final String currentName = tokenizer.nextToken();
        this.process(context, service, request, currentName);
        if (LinkService.DEFAULT_REQUEST_EVENT_PARAMETER_NAME.equals(currentName)) {
            processedDefault = true;
        }
    }
    if (!processedDefault) {
        this.process(context, service, request, LinkService.DEFAULT_REQUEST_EVENT_PARAMETER_NAME);
    }
    context.invokeNext(service);
}