1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.component.wiki.internal

File AbstractBaseObjectWikiComponent.java

 

Coverage histogram

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

Code metrics

0
11
7
1
122
55
7
0.64
1.57
7
1

Classes

Class Line # Actions
AbstractBaseObjectWikiComponent 38 11 0% 7 2
0.888888988.9%
 

Contributing tests

This file is covered by 16 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 org.xwiki.component.wiki.internal;
21   
22    import java.lang.reflect.Type;
23   
24    import org.xwiki.component.wiki.WikiComponent;
25    import org.xwiki.component.wiki.WikiComponentScope;
26    import org.xwiki.model.reference.DocumentReference;
27    import org.xwiki.model.reference.EntityReference;
28    import org.xwiki.model.reference.ObjectReference;
29   
30    import com.xpn.xwiki.objects.BaseObject;
31   
32    /**
33    * Base class used by various xobject based implementations of {@link WikiComponent}.
34    *
35    * @version $Id: 15af8c927c9e1fc0ed5f5f13dbb3e11bc5668227 $
36    * @since 10.10RC1
37    */
 
38    public abstract class AbstractBaseObjectWikiComponent implements WikiComponent
39    {
40    /**
41    * Extension scope property.
42    */
43    public static final String XPROPERTY_SCOPE = "scope";
44   
45    /**
46    * @see {@link #getEntityReference()}
47    */
48    protected ObjectReference objectReference;
49   
50    /**
51    * @see {@link #getAuthorReference()}
52    */
53    protected DocumentReference authorReference;
54   
55    /**
56    * @see {@link #getRoleType()}
57    */
58    protected Type roleType;
59   
60    /**
61    * @see {@link #getRoleHint()}
62    */
63    protected String roleHint;
64   
65    /**
66    * @see {@link #getScope()}
67    */
68    protected WikiComponentScope scope = WikiComponentScope.WIKI;
69   
70    /**
71    * @param baseObject the object containing the component definition
72    * @param roleType the role Type implemented
73    * @param roleHint the role hint for this role implementation
74    */
 
75  6330 toggle public AbstractBaseObjectWikiComponent(BaseObject baseObject, Type roleType, String roleHint)
76    {
77  6330 this.objectReference = baseObject.getReference();
78   
79  6330 this.authorReference = baseObject.getOwnerDocument().getAuthorReference();
80   
81  6330 this.roleType = roleType;
82  6330 this.roleHint = roleHint;
83   
84  6330 this.scope = WikiComponentScope.fromString(baseObject.getStringValue(XPROPERTY_SCOPE));
85    }
86   
 
87  16717 toggle @Override
88    public DocumentReference getDocumentReference()
89    {
90  16717 return this.objectReference.getDocumentReference();
91    }
92   
 
93  0 toggle @Override
94    public EntityReference getEntityReference()
95    {
96  0 return this.objectReference;
97    }
98   
 
99  25569 toggle @Override
100    public DocumentReference getAuthorReference()
101    {
102  25569 return this.authorReference;
103    }
104   
 
105  54437 toggle @Override
106    public Type getRoleType()
107    {
108  54438 return this.roleType;
109    }
110   
 
111  427052 toggle @Override
112    public String getRoleHint()
113    {
114  427052 return this.roleHint;
115    }
116   
 
117  897 toggle @Override
118    public WikiComponentScope getScope()
119    {
120  897 return this.scope;
121    }
122    }