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

File Property.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

8
16
5
1
99
42
10
0.62
3.2
5
2

Classes

Class Line # Actions
Property 30 16 0% 10 16
0.4482758644.8%
 

Contributing tests

No tests hitting this source file were found.

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.api;
21   
22    import com.xpn.xwiki.XWikiContext;
23    import com.xpn.xwiki.objects.BaseProperty;
24   
25    /**
26    * Property is a single attribute of an XWiki {@link com.xpn.xwiki.api.Object}.
27    *
28    * @version $Id: d257d9ba675a2ef56c46b43be6b598df15427ae6 $
29    */
 
30    public class Property extends Element
31    {
32    /**
33    * The Constructor.
34    *
35    * @param property the internal {@link com.xpn.xwiki.objects.BaseProperty} to wrap.
36    * @param context the XWikiContext which may be used to get information about the current request.
37    */
 
38  65238 toggle public Property(BaseProperty property, XWikiContext context)
39    {
40  65239 super(property, context);
41    }
42   
43    /**
44    * @return the internal {@link com.xpn.xwiki.objects.BaseProperty} which this Property wraps.
45    */
 
46  130372 toggle protected BaseProperty getBaseProperty()
47    {
48  130376 return (BaseProperty) this.element;
49    }
50   
51    /**
52    * @return the internal {@link com.xpn.xwiki.objects.BaseProperty} which this Property wraps.
53    */
 
54  0 toggle public BaseProperty getProperty()
55    {
56  0 if (hasProgrammingRights()) {
57  0 return (BaseProperty) this.element;
58    } else {
59  0 return null;
60    }
61    }
62   
63    /**
64    * @return the definition of the property
65    * @since 8.3M1
66    */
 
67  0 toggle public PropertyClass getPropertyClass()
68    {
69  0 BaseProperty baseProperty = getBaseProperty();
70   
71  0 com.xpn.xwiki.objects.classes.PropertyClass propertyClass = baseProperty.getPropertyClass(getXWikiContext());
72   
73  0 if (propertyClass != null) {
74  0 return new PropertyClass(propertyClass, getXWikiContext());
75    }
76   
77  0 return null;
78    }
79   
80    /**
81    * @return the actual value of the property, as a String, Number or List.
82    */
 
83  65190 toggle public java.lang.Object getValue()
84    {
85  65188 BaseProperty baseProperty = getBaseProperty();
86   
87  65188 com.xpn.xwiki.objects.classes.PropertyClass propertyClass = baseProperty.getPropertyClass(getXWikiContext());
88   
89    // Avoid dumping password hashes if the user does not have programming rights. This is done only at the
90    // API level, so that java code using core classes will still have access, regardless or rights.
91  65189 if (propertyClass != null && "Password".equals(propertyClass.getClassType())) {
92  2 if (!getXWikiContext().getWiki().getRightService().hasProgrammingRights(getXWikiContext())) {
93  0 return null;
94    }
95    }
96   
97  65186 return getBaseProperty().getValue();
98    }
99    }