1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.listener.reference

File SpaceResourceReference.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart2.png
81% of files have more coverage

Code metrics

4
7
5
1
90
31
7
1
1.4
5
1.4

Classes

Class Line # Actions
SpaceResourceReference 31 7 0% 7 14
0.12512.5%
 

Contributing tests

This file is covered by 11 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.rendering.listener.reference;
21   
22    import org.apache.commons.lang3.StringUtils;
23   
24    /**
25    * Represents a reference to a Space.
26    *
27    * @version $Id: df4e7748659ffd6ccfde1d4484c9a617db02d77a $
28    * @since 7.4.1
29    * @since 8.0M1
30    */
 
31    public class SpaceResourceReference extends ResourceReference
32    {
33    /**
34    * The name of the parameter representing the Query String.
35    */
36    public static final String QUERY_STRING = "queryString";
37   
38    /**
39    * The name of the parameter representing the Anchor.
40    */
41    public static final String ANCHOR = "anchor";
42   
43    /**
44    * @param reference see {@link #getReference()}
45    */
 
46  15 toggle public SpaceResourceReference(String reference)
47    {
48  15 super(reference, ResourceType.SPACE);
49    }
50   
51    /**
52    * @return the query string for specifying parameters that will be used in the rendered URL or null if no query
53    * string has been specified. Example: {@code mydata1=5&mydata2=Hello}
54    */
 
55  0 toggle public String getQueryString()
56    {
57  0 return getParameter(QUERY_STRING);
58    }
59   
60    /**
61    * @param queryString see {@link #getQueryString()}
62    */
 
63  0 toggle public void setQueryString(String queryString)
64    {
65  0 if (!StringUtils.isEmpty(queryString)) {
66  0 setParameter(QUERY_STRING, queryString);
67    }
68    }
69   
70    /**
71    * @return the anchor name pointing to an anchor defined in the referenced space's WebHome doucment or null if no
72    * anchor has been specified (in which case the reference points to the top of the space's WebHome
73    * document). Note that in XWiki anchors are automatically created for titles. Example:
74    * "TableOfContentAnchor"
75    */
 
76  0 toggle public String getAnchor()
77    {
78  0 return getParameter(ANCHOR);
79    }
80   
81    /**
82    * @param anchor see {@link #getAnchor()}
83    */
 
84  0 toggle public void setAnchor(String anchor)
85    {
86  0 if (!StringUtils.isEmpty(anchor)) {
87  0 setParameter(ANCHOR, anchor);
88    }
89    }
90    }