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

File UserResourceReference.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart4.png
78% of files have more coverage

Code metrics

4
7
5
1
88
31
7
1
1.4
5
1.4

Classes

Class Line # Actions
UserResourceReference 30 7 0% 7 10
0.37537.5%
 

Contributing tests

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