Java List Print printList(List l)

Here you can find the source of printList(List l)

Description

print List

License

Open Source License

Declaration

public static String printList(List l) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006 - 2011 SJRJ.//from w ww . j  av a  2s  .c  om
 * 
 *     This file is part of SIGA.
 * 
 *     SIGA is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     SIGA is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with SIGA.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

import java.util.Iterator;
import java.util.List;

public class Main {
    public static String printList(List l) {
        Iterator i = l.iterator();
        if (!i.hasNext())
            return "[]";

        StringBuilder sb = new StringBuilder();
        sb.append("[\n");
        for (;;) {
            Object e = i.next();
            sb.append(e == l ? "(this Collection)" : e);
            if (!i.hasNext())
                return sb.append("]\n").toString();
            sb.append(", ");
        }
    }

    public static String toString(Object o) {
        return "";
    }

    private static void toString(Object o, Class clazz, List list) {
        /*Field f[] = clazz.getDeclaredFields();
        AccessibleObject.setAccessible(f, true);
        for (int i = 0; i < f.length; i++) {
           if (!f[i].getName().equals("grPai")) {
        //            try {
        //               list.add(f[i].getName() + "=" + f[i].get(o));
        //            } catch (IllegalAccessException e) {
        //               e.printStackTrace();
        //            }
           }
        }
        if (clazz.getSuperclass().getSuperclass() != null) {
           System.out.println("*** Classe: " + clazz.getName() + " - " + clazz.getSuperclass().getName());
           toString(o, clazz.getSuperclass(), list);
        }*/
    }
}

Related

  1. printLines(List lines)
  2. printLinkedList(String prefix, LinkedList list)
  3. printList(Collection list)
  4. printList(final List list)
  5. printList(List l)
  6. printList(List results)
  7. printList(List l)
  8. printList(List l)
  9. printList(List list0)