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

File ObjectDiff.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
72% of files have more coverage

Code metrics

4
46
22
1
204
143
24
0.52
2.09
22
1.09

Classes

Class Line # Actions
ObjectDiff 28 46 0% 24 29
0.597222259.7%
 

Contributing tests

This file is covered by 24 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.objects;
21   
22    import org.xwiki.model.reference.DocumentReference;
23    import org.xwiki.model.reference.DocumentReferenceResolver;
24    import org.xwiki.model.reference.EntityReferenceSerializer;
25   
26    import com.xpn.xwiki.web.Utils;
27   
 
28    public class ObjectDiff
29    {
30    public static final String ACTION_PROPERTYADDED = "added";
31   
32    public static final String ACTION_PROPERTYCHANGED = "changed";
33   
34    public static final String ACTION_PROPERTYREMOVED = "removed";
35   
36    public static final String ACTION_OBJECTADDED = "object-added";
37   
38    public static final String ACTION_OBJECTREMOVED = "object-removed";
39   
40    private DocumentReferenceResolver<String> currentDocumentReferenceResolver = Utils.getComponent(
41    DocumentReferenceResolver.TYPE_STRING, "current");
42   
43    private EntityReferenceSerializer<String> localEntityReferenceSerializer = Utils.getComponent(
44    EntityReferenceSerializer.TYPE_STRING, "local");
45   
46    private DocumentReference xClassReference;
47   
48    private int number;
49   
50    private String guid;
51   
52    private String propName;
53   
54    private String propType;
55   
56    private Object prevValue;
57   
58    private Object newValue;
59   
60    private String action;
61   
 
62  0 toggle @Deprecated
63    public ObjectDiff(String className, int number, String action, String propName, Object prevValue, Object newValue)
64    {
65  0 this(className, number, "", action, propName, "", prevValue, newValue);
66    }
67   
 
68  0 toggle @Deprecated
69    public ObjectDiff(String className, int number, String guid, String action, String propName, String propType,
70    Object prevValue, Object newValue)
71    {
72  0 this.setClassName(className);
73  0 this.setNumber(number);
74  0 this.setGuid(guid);
75  0 this.setAction(action);
76  0 this.setPropName(propName);
77  0 this.setPropType(propType);
78  0 this.setPrevValue(prevValue);
79  0 this.setNewValue(newValue);
80    }
81   
 
82  2618 toggle public ObjectDiff(DocumentReference xClassReference, int number, String guid, String action, String propName,
83    String propType, Object prevValue, Object newValue)
84    {
85  2618 this.setXClassReference(xClassReference);
86  2618 this.setNumber(number);
87  2618 this.setGuid(guid);
88  2618 this.setAction(action);
89  2618 this.setPropName(propName);
90  2618 this.setPropType(propType);
91  2618 this.setPrevValue(prevValue);
92  2618 this.setNewValue(newValue);
93    }
94   
 
95  8 toggle public String getClassName()
96    {
97  8 DocumentReference xClassReference = getXClassReference();
98   
99  8 return xClassReference != null ? this.localEntityReferenceSerializer.serialize(getXClassReference()) : null;
100    }
101   
 
102  0 toggle public void setClassName(String className)
103    {
104  0 DocumentReference xClassReference =
105  0 className != null ? this.currentDocumentReferenceResolver.resolve(className) : null;
106  0 setXClassReference(xClassReference);
107    }
108   
 
109  5985 toggle public DocumentReference getXClassReference()
110    {
111  5985 return this.xClassReference;
112    }
113   
 
114  2618 toggle public void setXClassReference(DocumentReference xClassReference)
115    {
116  2618 this.xClassReference = xClassReference;
117    }
118   
 
119  5973 toggle public int getNumber()
120    {
121  5973 return this.number;
122    }
123   
 
124  2618 toggle public void setNumber(int number)
125    {
126  2618 this.number = number;
127    }
128   
 
129  0 toggle public String getGuid()
130    {
131  0 return this.guid;
132    }
133   
 
134  2618 toggle public void setGuid(String guid)
135    {
136  2618 this.guid = guid;
137    }
138   
 
139  2773 toggle public String getPropName()
140    {
141  2773 return this.propName;
142    }
143   
 
144  2618 toggle public void setPropName(String propName)
145    {
146  2618 this.propName = propName;
147    }
148   
 
149  4 toggle public String getPropType()
150    {
151  4 return this.propType;
152    }
153   
 
154  2618 toggle public void setPropType(String propType)
155    {
156  2618 this.propType = propType;
157    }
158   
 
159  2 toggle public Object getPrevValue()
160    {
161  2 return this.prevValue;
162    }
163   
 
164  2618 toggle public void setPrevValue(Object prevValue)
165    {
166  2618 this.prevValue = prevValue;
167    }
168   
 
169  2 toggle public Object getNewValue()
170    {
171  2 return this.newValue;
172    }
173   
 
174  2618 toggle public void setNewValue(Object newValue)
175    {
176  2618 this.newValue = newValue;
177    }
178   
 
179  9718 toggle public String getAction()
180    {
181  9718 return this.action;
182    }
183   
 
184  2618 toggle public void setAction(String action)
185    {
186  2618 this.action = action;
187    }
188   
 
189  0 toggle @Override
190    public String toString()
191    {
192  0 StringBuilder buffer = new StringBuilder();
193   
194  0 buffer.append(getClassName());
195  0 buffer.append(".");
196  0 buffer.append(getPropName());
197  0 buffer.append(": ");
198  0 buffer.append(getPrevValue().toString());
199  0 buffer.append(" \u21E8 ");
200  0 buffer.append(getNewValue().toString());
201   
202  0 return buffer.toString();
203    }
204    }