Java Code Examples for java.util.Arrays#deepToString()

The following examples show how to use java.util.Arrays#deepToString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImmutableDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toString() {
    StringBuilder sb = new StringBuilder("{");
    for (int i = 0; i < names.length; i++) {
        if (i > 0)
            sb.append(", ");
        sb.append(names[i]).append("=");
        Object v = values[i];
        if (v != null && v.getClass().isArray()) {
            String s = Arrays.deepToString(new Object[] {v});
            s = s.substring(1, s.length() - 1); // remove [...]
            v = s;
        }
        sb.append(String.valueOf(v));
    }
    return sb.append("}").toString();
}
 
Example 2
Source File: Message.java    From JTelegramBot with MIT License 6 votes vote down vote up
@Override
public String toString()
{
	return "Message{" + "messageId=" + messageId + ", from=" + from + ", date=" + date + ", chat=" + chat +
			", forwardFrom=" + forwardFrom + ", forwardFromChat=" + forwardFromChat + ", forwardDate=" +
			forwardDate + ", replyToMessage=" + replyToMessage + ", editDate=" + editDate + ", text='" +
			text + '\'' + ", entities=" + Arrays.deepToString(entities) + ", audio=" + audio + ", document=" +
			document + ", photo=" + Arrays.deepToString(photo) + ", sticker=" + sticker + ", video=" + video +
			", voice=" + voice + ", caption='" + caption + '\'' + ", contact=" + contact + ", location=" +
			location + ", venue=" + venue + ", newChatMember=" + newChatMember + ", leftChatMember=" +
			leftChatMember + ", newChatTitle='" + newChatTitle + '\'' + ", newChatPhoto=" +
			Arrays.deepToString(newChatPhoto) + ", deleteChatPhoto=" + deleteChatPhoto + ", groupChatCreated=" +
			groupChatCreated + ", superGroupChatCreated=" + superGroupChatCreated + ", channelChatCreated=" +
			channelChatCreated + ", migrateToChatId=" + migrateToChatId + ", migrateFromChatId=" +
			migrateFromChatId + ", pinnedMessage=" + pinnedMessage + '}';
}
 
Example 3
Source File: ImmutableDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toString() {
    StringBuilder sb = new StringBuilder("{");
    for (int i = 0; i < names.length; i++) {
        if (i > 0)
            sb.append(", ");
        sb.append(names[i]).append("=");
        Object v = values[i];
        if (v != null && v.getClass().isArray()) {
            String s = Arrays.deepToString(new Object[] {v});
            s = s.substring(1, s.length() - 1); // remove [...]
            v = s;
        }
        sb.append(String.valueOf(v));
    }
    return sb.append("}").toString();
}
 
Example 4
Source File: ImmutableDescriptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toString() {
    StringBuilder sb = new StringBuilder("{");
    for (int i = 0; i < names.length; i++) {
        if (i > 0)
            sb.append(", ");
        sb.append(names[i]).append("=");
        Object v = values[i];
        if (v != null && v.getClass().isArray()) {
            String s = Arrays.deepToString(new Object[] {v});
            s = s.substring(1, s.length() - 1); // remove [...]
            v = s;
        }
        sb.append(String.valueOf(v));
    }
    return sb.append("}").toString();
}
 
Example 5
Source File: ImmutableDescriptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toString() {
    StringBuilder sb = new StringBuilder("{");
    for (int i = 0; i < names.length; i++) {
        if (i > 0)
            sb.append(", ");
        sb.append(names[i]).append("=");
        Object v = values[i];
        if (v != null && v.getClass().isArray()) {
            String s = Arrays.deepToString(new Object[] {v});
            s = s.substring(1, s.length() - 1); // remove [...]
            v = s;
        }
        sb.append(String.valueOf(v));
    }
    return sb.append("}").toString();
}
 
Example 6
Source File: Utils.java    From logger with Apache License 2.0 5 votes vote down vote up
public static String toString(Object object) {
  if (object == null) {
    return "null";
  }
  if (!object.getClass().isArray()) {
    return object.toString();
  }
  if (object instanceof boolean[]) {
    return Arrays.toString((boolean[]) object);
  }
  if (object instanceof byte[]) {
    return Arrays.toString((byte[]) object);
  }
  if (object instanceof char[]) {
    return Arrays.toString((char[]) object);
  }
  if (object instanceof short[]) {
    return Arrays.toString((short[]) object);
  }
  if (object instanceof int[]) {
    return Arrays.toString((int[]) object);
  }
  if (object instanceof long[]) {
    return Arrays.toString((long[]) object);
  }
  if (object instanceof float[]) {
    return Arrays.toString((float[]) object);
  }
  if (object instanceof double[]) {
    return Arrays.toString((double[]) object);
  }
  if (object instanceof Object[]) {
    return Arrays.deepToString((Object[]) object);
  }
  return "Couldn't find a correct type for the object";
}
 
Example 7
Source File: SortedMap2IndexScanController.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {

  if (SanityManager.DEBUG) {
    String string = "\nSortedMap2IndexScanController\tskiplist-congid = "
        + (this.baseContainer != null ? this.baseContainer.getId() : -1)

        /* "\n\trh:" + scan_position.current_rh + */
        + "\n\tinit_scanColumnList = "
        + init_scanColumnList
        + "\n\tinit_scanColumnList.size() = "
        + ((init_scanColumnList != null) ? init_scanColumnList.size() : 0)
        +

        "\n\tinit_startKeyValue = "
        + RowUtil.toString(init_startKeyValue)
        + "\n\tinit_startSearchOperator = "
        + ((init_startSearchOperator == ScanController.GE) ? "GE"
            : ((init_startSearchOperator == ScanController.GT) ? "GT"
                : Integer.toString(init_startSearchOperator)))
        + "\n\tinit_qualifier[]         = "
        + Arrays.deepToString(init_qualifier)
        + "\n\tinit_stopKeyValue = "
        + RowUtil.toString(init_stopKeyValue)
        + "\n\tinit_stopSearchOperator = "
        + ((init_stopSearchOperator == ScanController.GE) ? "GE"
            : ((init_stopSearchOperator == ScanController.GT) ? "GT"
                : Integer.toString(init_stopSearchOperator)));

    return (string);
  }
  else {
    return null;
  }
}
 
Example 8
Source File: ArrayUtil.java    From w2j-cli with MIT License 5 votes vote down vote up
/**
 * 数组或集合转String
 *
 * @param obj 集合或数组对象
 * @return 数组字符串,与集合转字符串格式相同
 */
public static String toString(Object obj){
	if (null == obj) {
		return null;
	}
	if (ArrayUtil.isArray(obj)) {
		try {
			return Arrays.deepToString((Object[]) obj);
		} catch (Exception e) {
			final String className = obj.getClass().getComponentType().getName();
			if ("long".equals(className)) {
				return Arrays.toString((long[]) obj);
			} else if ("int".equals(className)) {
				return Arrays.toString((int[]) obj);
			} else if ("short".equals(className)) {
				return Arrays.toString((short[]) obj);
			} else if ("char".equals(className)) {
				return Arrays.toString((char[]) obj);
			} else if ("byte".equals(className)) {
				return Arrays.toString((byte[]) obj);
			} else if ("boolean".equals(className)) {
				return Arrays.toString((boolean[]) obj);
			} else if ("float".equals(className)) {
				return Arrays.toString((float[]) obj);
			} else if ("double".equals(className)) {
				return Arrays.toString((double[]) obj);
			} else {
				throw new RuntimeException(e);
			}
		}
	}
	return obj.toString();
}
 
Example 9
Source File: CompositeDataSupport.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private String contentString() {
    StringBuilder sb = new StringBuilder("{");
    String sep = "";
    for (Map.Entry<String, Object> entry : contents.entrySet()) {
        sb.append(sep).append(entry.getKey()).append("=");
        String s = Arrays.deepToString(new Object[] {entry.getValue()});
        sb.append(s.substring(1, s.length() - 1));
        sep = ", ";
    }
    sb.append("}");
    return sb.toString();
}
 
Example 10
Source File: VariationsIterator.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public int[] next() {
    // Only first call.
    if (position == -1) {
        position = 0;

        cntOfVectors++;

        return arraycopy(vector);
    }

    if (!updateVector(vector, position)) {
        if (position + 1 == params.length)
            throw new IllegalStateException("[position=" + position + ", vector=" +
                Arrays.toString(vector) + ", params=" + Arrays.deepToString(params));

        position++;

        // Skip params with length 1. We cannot set 1 at this position.
        while (position < params.length && params[position].length < 2)
            position++;

        if (position == params.length)
            throw new IllegalStateException("[position=" + position + ", vector=" +
                Arrays.toString(vector) + ", params=" + Arrays.deepToString(params));

        vector[position] = 1;

        cntOfVectors++;

        return arraycopy(vector);
    }

    cntOfVectors++;

    return arraycopy(vector);
}
 
Example 11
Source File: Expectations.java    From tasmo with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return "Expectation{"
            + "testCase=" + testCase
            + ", viewId=" + viewId
            + ", viewClassName=" + viewClassName
            + ", modelPathId=" + modelPathIdHashcode
            + ", path=" + path
            + ", modelPathInstanceIds=" + Arrays.deepToString(modelPathInstanceIds)
            + ", fieldName=" + fieldName
            + ", value=" + value
            + '}';
}
 
Example 12
Source File: MoreObjects.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a string in the format specified by {@link MoreObjects#toStringHelper(Object)}.
 *
 * <p>After calling this method, you can keep adding more properties to later call toString()
 * again and get a more complete representation of the same object; but properties cannot be
 * removed, so this only allows limited reuse of the helper instance. The helper allows
 * duplication of properties (multiple name/value pairs with the same name can be added).
 */

@Override
public String toString() {
  // create a copy to keep it consistent in case value changes
    boolean omitNullValuesSnapshot = omitNullValues;
    String nextSeparator = "";
    StringBuilder builder = new StringBuilder(32).append(className).append('{');
    for (ValueHolder valueHolder = holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
    Object value = valueHolder.value;
    if (!omitNullValuesSnapshot || value != null) {
        builder.append(nextSeparator);
        nextSeparator = ", ";
        if (valueHolder.name != null) {
        builder.append(valueHolder.name).append('=');
        }
        if (value != null && value.getClass().isArray()) {
                                                                                                             Object[] objectArray = {value};
                                                                                                             String arrayString = Arrays.deepToString(objectArray);
                                                                                                             builder.append(arrayString, 1, arrayString.length() - 1);
        } else {
          builder.append(value);
        }
    }
    }
    return builder.append('}').toString();
}
 
Example 13
Source File: EncodingUtils.java    From flink with Apache License 2.0 4 votes vote down vote up
public static String objectToString(Object object) {
	final String arrayString = Arrays.deepToString(new Object[]{object});
	return arrayString.substring(1, arrayString.length() - 1);
}
 
Example 14
Source File: SumAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Override
public Object processRemove(Object[] data, AggregatorState state) {
    // will not occur
    return new IllegalStateException("Sin cannot process data array, but found " + Arrays.deepToString(data));
}
 
Example 15
Source File: EqualExpectation.java    From livingdoc-core with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString() {
    return isArray(matchee) ? Arrays.deepToString(( Object[] ) matchee) : matchee.toString();
}
 
Example 16
Source File: ConvertUtils.java    From a with GNU General Public License v3.0 4 votes vote down vote up
public static String toString(Object[] objects) {
    return Arrays.deepToString(objects);
}
 
Example 17
Source File: StdDevAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Override
public Object processAdd(Object[] data, AggregatorState state) {
    return new IllegalStateException("stdDev cannot process data array, but found " + Arrays.deepToString(data));
}
 
Example 18
Source File: Tuple.java    From headlong with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return Arrays.deepToString(elements);
}
 
Example 19
Source File: AbstractArrayTypeDescriptor.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public String toString(Object value) {
    return Arrays.deepToString(ArrayUtil.wrapArray(value));
}
 
Example 20
Source File: CDOMTypeRef.java    From pcgen with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Constructs a new CDOMTypeRef for the given Class to be represented by
 * this CDOMTypeRef and the given types.
 * 
 * @param objClass
 *            The Class of the underlying objects contained by this
 *            reference.
 * @param typeArray
 *            An array of the Types of objects this CDOMTypeRef contains.
 */
public CDOMTypeRef(ClassIdentity<T> objClass, String[] typeArray)
{
	super(objClass.getReferenceDescription() + " " + Arrays.deepToString(typeArray));
	types = Arrays.copyOf(typeArray, typeArray.length);
	identity = objClass;
}