1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.doc.merge

File MergeResult.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart3.png
80% of files have more coverage

Code metrics

4
14
8
1
147
57
11
0.79
1.75
8
1.38

Classes

Class Line # Actions
MergeResult 35 14 0% 11 20
0.2307692323.1%
 

Contributing tests

This file is covered by 38 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.doc.merge;
21   
22    import java.util.LinkedList;
23    import java.util.List;
24   
25    import org.xwiki.logging.LogLevel;
26    import org.xwiki.logging.LogQueue;
27    import org.xwiki.logging.event.LogEvent;
28   
29    /**
30    * Report of what happen during merge.
31    *
32    * @version $Id: 1f0eb120729c6cb52fe48820d9b720b7aa924f54 $
33    * @since 3.2M1
34    */
 
35    public class MergeResult
36    {
37    /**
38    * @see #isModified()
39    */
40    private boolean modified;
41   
42    /**
43    * @see #getLog()
44    */
45    private LogQueue log = new LogQueue();
46   
47    /**
48    * @param modified indicate that something has been modified during the merge
49    */
 
50  83 toggle public void setModified(boolean modified)
51    {
52  83 this.modified = modified;
53    }
54   
55    /**
56    * @return true if something has been modified during the merge
57    */
 
58  57 toggle public boolean isModified()
59    {
60  57 return this.modified;
61    }
62   
63    /**
64    * @return the log associated to the merge
65    * @since 4.1RC1
66    */
 
67  262 toggle public LogQueue getLog()
68    {
69  262 return this.log;
70    }
71   
72    // Deprecated
73   
74    /**
75    * @param logLevel the level of the logs to return
76    * @return the exceptions associated to the provided log level
77    */
 
78  0 toggle private List<Exception> getExceptions(LogLevel logLevel)
79    {
80  0 List<Exception> exceptions = new LinkedList<Exception>();
81   
82  0 for (LogEvent logEvent : getLog()) {
83  0 if (logEvent.getLevel() == logLevel) {
84  0 if (logEvent.getThrowable() != null && logEvent.getThrowable() instanceof Exception) {
85  0 exceptions.add(new MergeException(logEvent.getFormattedMessage(), logEvent.getThrowable()));
86    } else {
87  0 exceptions.add(new MergeException(logEvent.getFormattedMessage()));
88    }
89    }
90    }
91   
92  0 return exceptions;
93    }
94   
95    /**
96    * Error raised during the merge.
97    * <p>
98    * Generally collision for which we don't know what do to at all.
99    *
100    * @return the merge errors
101    * @deprecated since 4.1RC1 use {@link #getLog()} instead
102    */
 
103  0 toggle @Deprecated
104    public List<Exception> getErrors()
105    {
106  0 return getExceptions(LogLevel.ERROR);
107    }
108   
109    /**
110    * Warning raised during the merge.
111    * <p>
112    * The difference with error is that in that case a decision which should be good (or at least safe enough) for most
113    * of the case has been made.
114    *
115    * @return the merge warning
116    * @deprecated since 4.1RC1 use {@link #getLog()} instead
117    */
 
118  0 toggle @Deprecated
119    public List<Exception> getWarnings()
120    {
121  0 return getExceptions(LogLevel.WARN);
122    }
123   
124    /**
125    * Add error.
126    *
127    * @param e the error
128    * @deprecated since 4.1RC1 use {@link #getLog()} instead
129    */
 
130  0 toggle @Deprecated
131    public void error(Exception e)
132    {
133  0 getLog().error("", e);
134    }
135   
136    /**
137    * Add warning.
138    *
139    * @param e the warning
140    * @deprecated since 4.1RC1 use {@link #getLog()} instead
141    */
 
142  0 toggle @Deprecated
143    public void warn(Exception e)
144    {
145  0 getLog().warn("", e);
146    }
147    }