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

File WikiComponentScope.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
7
2
1
77
25
3
0.43
3.5
2
1.5

Classes

Class Line # Actions
WikiComponentScope 32 7 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 21 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;
21   
22    import java.util.HashMap;
23    import java.util.Map;
24   
25    /**
26    * The scope of a {@link WikiComponent}, i.e. whether it's registered for the current user only, for the current wiki
27    * only, or for all the wikis.
28    *
29    * @version $Id: 308a7ed76f9b1377483d624a9102d0a6a704a239 $
30    * @since 4.3M2
31    */
 
32    public enum WikiComponentScope
33    {
34    /**
35    * Component registered for the current user only.
36    */
37    USER,
38   
39    /**
40    * Component registered for the current wiki only.
41    */
42    WIKI,
43   
44    /**
45    * Component registered for all wikis in a farm.
46    */
47    GLOBAL;
48   
49    /**
50    * Mapping between String definition of scope and enums. The strings defined are coming from the scope property of
51    * the Wiki Component Class.
52    */
53    private static final Map<String, WikiComponentScope> MAPPINGS = new HashMap<String, WikiComponentScope>()
54    {
 
55  48 toggle {
56  48 put("wiki", WIKI);
57  48 put("user", USER);
58  48 put("global", GLOBAL);
59    }
60    };
61   
62    /**
63    * Convert between a string representation of a Macro scope and its matching enum. If no matching enum is found then
64    * defaults to Wiki level visibility.
65    *
66    * @param scopeAsString the scope as a string
67    * @return the enum matching the scope defined as a string
68    */
 
69  7148 toggle public static WikiComponentScope fromString(String scopeAsString)
70    {
71  7148 WikiComponentScope scope = WIKI;
72  7148 if (MAPPINGS.containsKey(scopeAsString)) {
73  1575 scope = MAPPINGS.get(scopeAsString);
74    }
75  7148 return scope;
76    }
77    }