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

File Collection.java

 

Coverage histogram

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

Code metrics

6
25
10
1
108
71
14
0.56
2.5
10
1.4

Classes

Class Line # Actions
Collection 27 25 0% 14 6
0.8536585685.4%
 

Contributing tests

This file is covered by 4 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.api;
21   
22    import com.xpn.xwiki.XWikiContext;
23    import com.xpn.xwiki.objects.BaseCollection;
24    import com.xpn.xwiki.objects.BaseProperty;
25    import com.xpn.xwiki.objects.PropertyInterface;
26   
 
27    public abstract class Collection extends Element
28    {
 
29  37187 toggle public Collection(BaseCollection collection, XWikiContext context)
30    {
31  37188 super(collection, context);
32    }
33   
 
34  198782 toggle protected BaseCollection getCollection()
35    {
36  198785 return (BaseCollection) this.element;
37    }
38   
 
39  10817 toggle public Class getxWikiClass()
40    {
41  10817 return new Class(getCollection().getXClass(getXWikiContext()), getXWikiContext());
42    }
43   
 
44  49225 toggle @Override
45    public String getName()
46    {
47  49225 return getCollection().getName();
48    }
49   
 
50  0 toggle public String getPrettyName()
51    {
52  0 return getCollection().getPrettyName();
53    }
54   
 
55  100329 toggle public int getNumber()
56    {
57  100329 return getCollection().getNumber();
58    }
59   
 
60  0 toggle public java.lang.Object[] getPropertyNames()
61    {
62  0 return getCollection().getPropertyNames();
63    }
64   
 
65  7627 toggle public Element[] getProperties()
66    {
67  7627 @SuppressWarnings("unchecked")
68    java.util.Collection<BaseProperty> coll = getCollection().getFieldList();
69  7627 if (coll == null) {
70  0 return null;
71    }
72  7627 Property[] properties = new Property[coll.size()];
73  7627 int i = 0;
74  7627 for (BaseProperty prop : coll) {
75  58910 properties[i++] = new Property(prop, getXWikiContext());
76    }
77  7627 return properties;
78    }
79   
 
80  10518 toggle public Property getProperty(String name)
81    {
82  10517 try {
83  10518 PropertyInterface prop = getCollection().get(name);
84  10515 if (prop == null) {
85  4201 return null;
86    }
87   
88  6313 return new Property((BaseProperty) prop, getXWikiContext());
89    } catch (Exception e) {
90  2 return null;
91    }
92    }
93   
94    /**
95    * @param name the name of the property
96    * @return the value of the passed property
97    * @since 6.2
98    */
 
99  5523 toggle public java.lang.Object getValue(String name)
100    {
101  5523 Property property = getProperty(name);
102  5523 if (property != null) {
103  4252 return property.getValue();
104    }
105   
106  1270 return null;
107    }
108    }