private void addEntries()

in archiva-jarinfo/archiva-jarinfo-lib/src/main/java/org/apache/archiva/jarinfo/model/io/JarDetailsWriter.java [132:172]


    private void addEntries(SimpleXmlWriter xml, List<EntryDetail> entries) throws IOException {
        if (EmptyUtils.isEmpty(entries)) {
            return;
        }

        // Count the dirs / files
        int countDirs = 0;
        int countFiles = 0;

        for (EntryDetail entry : entries) {
            if (entry.isDirectory()) {
                countDirs++;
            } else {
                countFiles++;
            }
        }

        // Open the xml
        xml.elemOpen("entries", new String[][] { {COUNT_DIRS, String.valueOf(countDirs) },
            {COUNT_FILES, String.valueOf(countFiles) }, {COUNT_TOTAL, String.valueOf(countDirs + countFiles) } });

        // Dump the Directory List
        for (EntryDetail entry : entries) {
            if (entry.isDirectory()) {
                xml.elemEmpty(DIRECTORY, new String[][] { {NAME, entry.getName() },
                    {TIMESTAMP, Timestamp.convert(entry.getTimestamp()) } });
            }
        }

        // Dump the File List
        for (EntryDetail entry : entries) {
            if (!entry.isDirectory()) {
                xml.elemOpen(FILE, new String[][] { {NAME, entry.getName() }, {SIZE, String.valueOf(entry.getSize()) },
                    {TIMESTAMP, Timestamp.convert(entry.getTimestamp()) } });
                addHashes(xml, entry.getHashes());
                xml.elemClose();
            }
        }

        xml.elemClose();
    }