⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strings.java

📁 一个类似于openJMS分布在ObjectWeb之下的JMS消息中间件。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  public static final void toString(StringBuffer output, byte[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of an array of chars.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param tab		the array to print   */  public static final void toString(StringBuffer output, char[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of an array of shorts.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param tab		the array to print   */  public static final void toString(StringBuffer output, short[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of an array of ints.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param tab		the array to print   */  public static final void toString(StringBuffer output, int[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of an array of longs.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param tab		the array to print   */  public static final void toString(StringBuffer output, long[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of an array of floats.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param tab		the array to print   */  public static final void toString(StringBuffer output, float[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of an array of doubles.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param tab		the array to print   */  public static final void toString(StringBuffer output, double[] tab) {    if (tab == null) {      output.append("null");      return;    }    output.append("(");    int size = tab.length;    output.append(size);    if (listMax == -1 || size <= listMax) {      for (int i = 0; i < size; i ++) {	output.append(",");	output.append(tab[i]);      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	output.append(tab[i]);      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	output.append(tab[size - i]);      }    }    output.append(")");  }  /**   * Provides a string representation of a list of objects.   * This includes Vectors.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param list	the list of <code>Object</code> objects to print   */  public static final void toString(StringBuffer output, List list) {    if (list == null) {      output.append("null");      return;    }    output.append("(");    int size = list.size();    output.append(size);    if (listMax == -1 || size <= listMax || size <= (listBorder*2)) {      for (Iterator it = list.iterator(); it.hasNext();) {	output.append(",");	toString(output, it.next());      }    } else {      int border = size / 2;      if (listBorder < border)	border = listBorder;      for (int i = 0; i < border; i ++) {	output.append(",");	toString(output, list.get(i));      }      output.append(",...");      for (int i = border; i > 0; i --) {	output.append(",");	toString(output, list.get(size - i));      }    }    output.append(")");  }  /**   * Provides a string representation of a list of objects.   * Calls <code>toString(StringBuffer, ...)</code>.   *   * @param list	the list of <code>Object</code> objects to print   * @return		a string representation of the list   */  public static final String toString(List list) {    if (list == null)      return "null";    StringBuffer output = new StringBuffer();    toString(output, list);    return output.toString();  }  /**   * Provides a string representation of an unordered Collection of objects.   * This includes HashSets.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param set		the collection to print   */  public static final void toString(StringBuffer output, Collection set) {    if (set == null) {      output.append("null");      return;    }    output.append("(");    int size = set.size();    output.append(size);    if (listMax != -1 && size > listMax)      size = listBorder;    for (Iterator it = set.iterator(); size > 0; size --) {      output.append(",");      toString(output, it.next());    }    output.append(")");  }  /**   * Provides a string representation of an unordered Collection of objects.   * Calls <code>toString(StringBuffer, ...)</code>.   *   * @param list	the collection to print   * @return		a string representation of the list   */  public static final String toString(Collection set) {    if (set == null)      return "null";    StringBuffer output = new StringBuffer();    toString(output, set);    return output.toString();  }  /**   * Provides a string representation of a Map.   * This includes HashTables.   * Uses the <code>listMax</code> and <code>listBorder</code> variables.   *   * @param output	a buffer to print the object into   * @param map		the map to print   */  public static final void toString(StringBuffer output, Map map) {    if (map == null) {      output.append("null");      return;    }    toString(output, map.values());  }  /**   * Provides a string representation of a Map.   * Calls <code>toString(StringBuffer, ...)</code>.   *   * @param map		the map to print   * @return		a string representation of the map   */  public static final String toString(Map map) {    if (map == null)      return "null";    StringBuffer output = new StringBuffer();    toString(output, map);    return output.toString();  }  /**   * Provides a string representation of a Map entry.   *   * @param output	a buffer to print the object into   * @param entry	the map entry to print   */  public static final void toString(StringBuffer output, Map.Entry entry) {    if (entry == null) {      output.append("null");      return;    }    output.append("(");    output.append(entry.getKey());    output.append(",");    output.append(entry.getValue());    output.append(")");  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -