Here you can find the source of toString(String[] paramNames, Object[] params)
Parameter | Description |
---|---|
paramNames | the names of parameters. |
params | the values of parameters. |
static String toString(String[] paramNames, Object[] params)
//package com.java2s; /*/*from w w w .ja v a 2 s. c o m*/ Copyright 2014 OPM.gov Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import java.util.List; public class Main { /** * Converts the parameters to string. * * @param paramNames * the names of parameters. * @param params * the values of parameters. * * @return the string */ static String toString(String[] paramNames, Object[] params) { StringBuffer sb = new StringBuffer(" Input parameters: {"); if (params != null) { for (int i = 0; i < params.length; i++) { if (i > 0) { sb.append(", "); } sb.append(paramNames[i]).append(":") .append(toString(params[i])); } } sb.append("}."); return sb.toString(); } /** * Converts the object to string. * * @param obj * the object * * @return the string representation of the object. */ static String toString(Object obj) { if (obj instanceof List<?>) { return toString((List<?>) obj); } return String.valueOf(obj); } /** * Converts the List to a string. * * @param obj * the List. * * @return the string. */ private static String toString(List<?> obj) { StringBuilder sb = new StringBuilder(); sb.append("["); boolean first = true; for (Object element : obj) { if (first) { first = false; } else { sb.append(", "); } sb.append(toString(element)); } sb.append("]"); return sb.toString(); } }