1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.doc

File AttachmentDiff.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

12
28
12
1
141
89
18
0.64
2.33
12
1.5

Classes

Class Line # Actions
AttachmentDiff 24 28 0% 18 2
0.9615384396.2%
 

Contributing tests

This file is covered by 7 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;
21   
22    import org.xwiki.diff.Delta;
23   
 
24    public class AttachmentDiff
25    {
26    private String fileName;
27   
28    private Delta.Type type;
29   
30    private XWikiAttachment origAttachment;
31   
32    private XWikiAttachment newAttachment;
33   
34    @Deprecated
35    private String origVersion;
36   
37    @Deprecated
38    private String newVersion;
39   
 
40  4 toggle @Deprecated
41    public AttachmentDiff(String fileName, String origVersion, String newVersion)
42    {
43  2 this(fileName, newVersion == null ? Delta.Type.DELETE : (origVersion == null ? Delta.Type.INSERT
44    : Delta.Type.CHANGE), null, null);
45   
46  4 setOrigVersion(origVersion);
47  4 setNewVersion(newVersion);
48    }
49   
50    /**
51    * @since 5.4M1
52    */
 
53  82 toggle public AttachmentDiff(String fileName, Delta.Type type, XWikiAttachment origAttachment,
54    XWikiAttachment newAttachment)
55    {
56  82 this.fileName = fileName;
57  82 this.type = type;
58  82 this.origAttachment = origAttachment;
59  82 this.newAttachment = newAttachment;
60   
61  82 this.origVersion = origAttachment != null ? origAttachment.getVersion() : null;
62  82 this.newVersion = newAttachment != null ? newAttachment.getVersion() : null;
63    }
64   
 
65  78 toggle public String getFileName()
66    {
67  78 return this.fileName;
68    }
69   
 
70  0 toggle public void setFileName(String fileName)
71    {
72  0 this.fileName = fileName;
73    }
74   
75    /**
76    * @since 5.4M1
77    */
 
78  3 toggle public Delta.Type getType()
79    {
80  3 return this.type;
81    }
82   
83    /**
84    * @since 5.4M1
85    */
 
86  3 toggle public XWikiAttachment getOrigAttachment()
87    {
88  3 return this.origAttachment;
89    }
90   
91    /**
92    * @since 5.4M1
93    */
 
94  3 toggle public XWikiAttachment getNewAttachment()
95    {
96  3 return this.newAttachment;
97    }
98   
 
99  75 toggle @Deprecated
100    public String getOrigVersion()
101    {
102  75 return this.origVersion;
103    }
104   
 
105  4 toggle @Deprecated
106    public void setOrigVersion(String origVersion)
107    {
108  4 this.origVersion = origVersion;
109    }
110   
 
111  10 toggle @Deprecated
112    public String getNewVersion()
113    {
114  10 return this.newVersion;
115    }
116   
 
117  4 toggle @Deprecated
118    public void setNewVersion(String newVersion)
119    {
120  4 this.newVersion = newVersion;
121    }
122   
 
123  4 toggle @Override
124    public String toString()
125    {
126  4 StringBuilder buf = new StringBuilder(this.fileName);
127  4 buf.append(": ");
128  4 if (this.origVersion != null) {
129  2 buf.append(this.origVersion);
130    } else {
131  2 buf.append("()");
132    }
133  4 buf.append(" \u21E8 ");
134  4 if (this.newVersion != null) {
135  2 buf.append(this.newVersion);
136    } else {
137  2 buf.append("()");
138    }
139  4 return buf.toString();
140    }
141    }