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

File BaseStringProperty.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

6
12
6
1
80
44
9
0.75
2
6
1.5

Classes

Class Line # Actions
BaseStringProperty 27 12 0% 9 4
0.833333383.3%
 

Contributing tests

This file is covered by 153 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 com.google.common.base.Objects;
23   
24    /**
25    * Base string XProperty which all types of string XProperties extend. $Id: fa7594a66f6112892a6c6a5ec3c13a7dc17c04c2 $
26    */
 
27    public class BaseStringProperty extends BaseProperty
28    {
29    /** The value of the string. */
30    private String value;
31   
 
32  3339970 toggle @Override
33    public String getValue()
34    {
35    // A null String does not make much sense (the whole property would not be in the xobject in that case) and we
36    // have to make sure something saved as empty string will come back as such in Oracle (which has a very
37    // annoying "empty string is stored as null" behavior)
38  3339984 return this.value != null ? this.value : "";
39    }
40   
 
41  908360 toggle @Override
42    public void setValue(Object value)
43    {
44  908367 setValueDirty(value);
45  908393 this.value = (String) value;
46    }
47   
 
48  275735 toggle @Override
49    public String toText()
50    {
51  275735 return getValue();
52    }
53   
 
54  26554 toggle @Override
55    public boolean equals(Object obj)
56    {
57  26554 if (!super.equals(obj)) {
58  0 return false;
59    }
60   
61  26554 if (!(obj instanceof BaseStringProperty)) {
62  0 return false;
63    }
64   
65  26554 return Objects.equal(this.getValue(), ((BaseStringProperty) obj).getValue());
66    }
67   
 
68  400670 toggle @Override
69    public BaseStringProperty clone()
70    {
71  400677 return (BaseStringProperty) super.clone();
72    }
73   
 
74  400681 toggle @Override
75    protected void cloneInternal(BaseProperty clone)
76    {
77  400683 BaseStringProperty property = (BaseStringProperty) clone;
78  400682 property.setValue(getValue());
79    }
80    }