예제 #1
0
 private void _deepToString(
     Object[] objsArray, StringBuilder buffer, Set<Object[]> alreadyFormatted) {
   if (objsArray == null) {
     buffer.append(NULL);
     return;
   }
   alreadyFormatted.add(objsArray);
   buffer.append('[');
   int length = objsArray.length;
   for (int i = 0; i < length; i++) {
     if (i != 0) buffer.append(", ");
     Object element = objsArray[i];
     if (element == null) {
       buffer.append(NULL);
       continue;
     }
     if (!CollectionUtils.isArray(element.getClass())) { // Objetos normales
       buffer.append(Strings.quote(element.toString()));
       continue;
     }
     // Aqui es un array pero no se sabe si es de objetos primitivos o objetos normales
     if (!CollectionUtils.isObjectsArray(element.getClass())) { // Array de objetos primitivos
       buffer.append(_formatPrimitivesArray(element));
       continue;
     }
     if (alreadyFormatted.contains(element)) {
       buffer.append("[...]");
       continue;
     }
     // Aqui seguro que es un array de objetos
     _deepToString((Object[]) element, buffer, alreadyFormatted);
   }
   buffer.append(']');
   alreadyFormatted.remove(objsArray);
 }
예제 #2
0
 public String format(Object o) {
   if (o == null) return null;
   if (!CollectionUtils.isArray(o.getClass())) return null;
   if (CollectionUtils.isObjectsArray(o.getClass())) return _formatObjectsArray((Object[]) o);
   return _formatPrimitivesArray(o);
 }