Here you can find the source of collapseQualifier(String qualifier, boolean includeDots)
Parameter | Description |
---|---|
qualifier | The qualifier to collapse. |
includeDots | Should we include the dots in the collapsed form? |
public static String collapseQualifier(String qualifier, boolean includeDots)
//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(); } }