KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > report > LogReportOutputter


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * #SNAPSHOT#
5  */

6 package fr.jayasoft.ivy.report;
7
8 import java.io.File JavaDoc;
9 import java.util.Arrays JavaDoc;
10 import java.util.Collection JavaDoc;
11
12 import fr.jayasoft.ivy.IvyNode;
13 import fr.jayasoft.ivy.util.Message;
14
15 /**
16  * @author Xavier Hanin
17  *
18  */

19 public class LogReportOutputter implements ReportOutputter {
20    
21    public String JavaDoc getName() {
22        return CONSOLE;
23    }
24
25     public void output(ResolveReport report, File JavaDoc destDir) {
26         IvyNode[] evicted = report.getEvictedNodes();
27         if (evicted.length > 0) {
28             Message.info("\t:: evicted modules:");
29             for (int i = 0; i < evicted.length; i++) {
30                 Collection JavaDoc allEvictingNodes = evicted[i].getAllEvictingNodes();
31                 if (allEvictingNodes == null) {
32                     Message.info("\t"+evicted[i]+" transitively in "+Arrays.asList(evicted[i].getEvictedConfs()));
33                 } else if (allEvictingNodes.isEmpty()) {
34                     Message.info("\t"+evicted[i]+" by [] ("+evicted[i].getAllEvictingConflictManagers()+") in "+Arrays.asList(evicted[i].getEvictedConfs()));
35                 } else {
36                     Message.info("\t"+evicted[i]+" by "+allEvictingNodes+" in "+Arrays.asList(evicted[i].getEvictedConfs()));
37                 }
38                 String JavaDoc[] confs = evicted[i].getEvictedConfs();
39                 for (int j = 0; j < confs.length; j++) {
40                     IvyNode.EvictionData evictedData = evicted[i].getEvictedData(confs[j]);
41                     Message.verbose("\t in "+evictedData.getNode()+" with "+evictedData.getConflictManager());
42                 }
43             }
44         }
45
46         char[] sep = new char[69];
47         Arrays.fill(sep, '-');
48         Message.rawinfo("\t"+new String JavaDoc(sep));
49         StringBuffer JavaDoc line = new StringBuffer JavaDoc("\t");
50         append(line, "", 18);
51         append(line, "modules", 31);
52         line.append("|");
53         append(line, "artifacts", 15);
54         line.append("|");
55         Message.rawinfo(line.toString());
56
57         line = new StringBuffer JavaDoc("\t");
58         append(line, "conf", 18);
59         append(line, "number", 7);
60         append(line, "search", 7);
61         append(line, "dwnlded", 7);
62         append(line, "evicted", 7);
63         line.append("|");
64         append(line, "number", 7);
65         append(line, "dwnlded", 7);
66         line.append("|");
67         Message.rawinfo(line.toString());
68         Message.rawinfo("\t"+new String JavaDoc(sep));
69         
70         String JavaDoc[] confs = report.getConfigurations();
71         for (int i = 0; i < confs.length; i++) {
72             output(report.getConfigurationReport(confs[i]));
73         }
74         Message.rawinfo("\t"+new String JavaDoc(sep));
75
76         IvyNode[] unresolved = report.getUnresolvedDependencies();
77         if (unresolved.length > 0) {
78             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
79             Message.warn("\t:: UNRESOLVED DEPENDENCIES ::");
80             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
81         }
82         for (int i = 0; i < unresolved.length; i++) {
83             Message.warn("\t:: "+unresolved[i]+": "+unresolved[i].getProblem().getMessage());
84         }
85         if (unresolved.length > 0) {
86             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
87         }
88
89         ArtifactDownloadReport[] errors = report.getFailedArtifactsReports();
90         if (errors.length > 0) {
91             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
92             Message.warn("\t:: FAILED DOWNLOADS ::");
93             Message.warn("\t:: ^ see resolution messages for details ^ ::");
94             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
95         }
96         for (int i = 0; i < errors.length; i++) {
97             Message.warn("\t:: "+errors[i].getArtifact());
98         }
99         if (errors.length > 0) {
100             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
101         }
102     }
103     
104     public void output(ConfigurationResolveReport report) {
105         StringBuffer JavaDoc line = new StringBuffer JavaDoc("\t");
106         append(line, report.getConfiguration(), 18);
107         append(line, String.valueOf(report.getNodesNumber()), 7);
108         append(line, String.valueOf(report.getSearchedNodes().length), 7);
109         append(line, String.valueOf(report.getDownloadedNodes().length), 7);
110         append(line, String.valueOf(report.getEvictedNodes().length), 7);
111         line.append("|");
112         append(line, String.valueOf(report.getArtifactsNumber()), 7);
113         append(line, String.valueOf(report.getDownloadedArtifactsReports().length), 7);
114         line.append("|");
115
116         Message.rawinfo(line.toString());
117     }
118
119     private void append(StringBuffer JavaDoc line, Object JavaDoc o, int limit) {
120         String JavaDoc v = String.valueOf(o);
121         if (v.length() >= limit) {
122             v = v.substring(0, limit);
123         } else {
124             int missing = limit - v.length();
125             int half = missing / 2;
126             char[] c = new char[limit];
127             Arrays.fill(c, ' ');
128             System.arraycopy(v.toCharArray(), 0, c, missing - half, v.length());
129             v = new String JavaDoc(c);
130         }
131         line.append("|");
132         line.append(v);
133     }
134
135 }
136
Popular Tags