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

File Object.java

 

Coverage histogram

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

Code metrics

8
27
10
1
119
79
16
0.59
2.7
10
1.6

Classes

Class Line # Actions
Object 28 27 0% 16 23
0.488888948.9%
 

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.XWikiException;
24    import com.xpn.xwiki.doc.XWikiDocument;
25    import com.xpn.xwiki.objects.BaseObject;
26    import com.xpn.xwiki.objects.BaseObjectReference;
27   
 
28    public class Object extends Collection
29    {
 
30  7401 toggle public Object(BaseObject obj, XWikiContext context)
31    {
32  7401 super(obj, context);
33    }
34   
 
35  3776 toggle protected BaseObject getBaseObject()
36    {
37  3776 return (BaseObject) getCollection();
38    }
39   
 
40  0 toggle public BaseObject getXWikiObject()
41    {
42  0 if (hasProgrammingRights()) {
43  0 return (BaseObject) getCollection();
44    } else {
45  0 return null;
46    }
47    }
48   
 
49  0 toggle public String getGuid()
50    {
51  0 return getBaseObject().getGuid();
52    }
53   
 
54  0 toggle public void setGuid(String guid)
55    {
56  0 getBaseObject().setGuid(guid);
57    }
58   
59    /**
60    * This method's name is misleading since it doesn't return the Object's property value; it"s equivalent to
61    * {@link #display(String, String)} (with {@code type} equals to {@code view}). In order to get the Object's
62    * property value use {@code getProperty(String).getValue()} instead.
63    */
 
64  214 toggle public java.lang.Object get(String name)
65    {
66  214 try {
67  214 XWikiDocument doc = getBaseObject().getOwnerDocument();
68  214 if (doc == null) {
69  0 doc =
70    getXWikiContext().getWiki().getDocument(getBaseObject().getDocumentReference(), getXWikiContext());
71    }
72   
73  214 return doc.display(name, this.getBaseObject(), getXWikiContext());
74    } catch (XWikiException e) {
75  0 return null;
76    }
77    }
78   
 
79  9 toggle public java.lang.Object display(String name, String mode)
80    {
81  9 try {
82  9 XWikiDocument doc = getBaseObject().getOwnerDocument();
83  9 if (doc == null) {
84  0 doc =
85    getXWikiContext().getWiki().getDocument(getBaseObject().getDocumentReference(), getXWikiContext());
86    }
87   
88  9 return doc.display(name, mode, this.getBaseObject(), getXWikiContext());
89    } catch (XWikiException e) {
90  0 return null;
91    }
92    }
93   
 
94  0 toggle @Override
95    public boolean equals(java.lang.Object arg0)
96    {
97  0 if (!(arg0 instanceof Object)) {
98  0 return false;
99    }
100  0 Object o = (Object) arg0;
101  0 return o.getXWikiContext().equals(getXWikiContext()) && this.element.equals(o.element);
102    }
103   
 
104  488 toggle public void set(String fieldname, java.lang.Object value)
105    {
106  488 XWikiContext xcontext = getXWikiContext();
107   
108  488 getBaseObject().set(fieldname, value, xcontext);
109   
110    // Temporary set as author of the document the current script author (until the document is saved)
111  488 getBaseObject().getOwnerDocument().setAuthorReference(xcontext.getAuthorReference());
112    }
113   
 
114  220 toggle @Override
115    public BaseObjectReference getReference()
116    {
117  220 return getBaseObject().getReference();
118    }
119    }