Java String Equal collapseQualifier(String qualifier, boolean includeDots)

Here you can find the source of collapseQualifier(String qualifier, boolean includeDots)

Description

Given a qualifier, collapse it.

License

Apache License

Parameter

Parameter Description
qualifier The qualifier to collapse.
includeDots Should we include the dots in the collapsed form?

Return

The collapsed form.

Declaration

public static String collapseQualifier(String qualifier, boolean includeDots) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**/*from   w  ww.ja v a  2  s  . c o  m*/
     * Given a qualifier, collapse it.
     *
     * @param qualifier   The qualifier to collapse.
     * @param includeDots Should we include the dots in the collapsed form?
     * @return The collapsed form.
     */
    public static String collapseQualifier(String qualifier, boolean includeDots) {
        StringTokenizer tokenizer = new StringTokenizer(qualifier, ".");
        String collapsed = Character.toString(tokenizer.nextToken().charAt(0));
        while (tokenizer.hasMoreTokens()) {
            if (includeDots) {
                collapsed += '.';
            }
            collapsed += tokenizer.nextToken().charAt(0);
        }
        return collapsed;
    }

    public static String toString(Object[] array) {
        int len = array.length;
        if (len == 0)
            return "";
        StringBuilder buf = new StringBuilder(len * 12);
        for (int i = 0; i < len - 1; i++) {
            buf.append(array[i]).append(", ");
        }
        return buf.append(array[len - 1]).toString();
    }
}

Related

  1. areStringEquals(String string1, String string2)
  2. areStringsEqual(String one, String two)
  3. areStringsEqual(String s1, String s2, boolean caseInsensitive)
  4. areStringsEqual(String s1, String s2, boolean caseInsensitive, boolean dontDistinctNullAndEmpty)
  5. areStringsEqual(String str1, String str2)
  6. equalsCaseless(String sA_, String sB_)
  7. equalsIgnoreCase(String s1, String s2)
  8. equalsIgnoreCase(String source, String query)
  9. equalsOrExceeds(String version, String threshold)