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

File DocumentResourceReference.java

 

Coverage histogram

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

Code metrics

4
7
5
1
88
31
7
1
1.4
5
1.4

Classes

Class Line # Actions
DocumentResourceReference 30 7 0% 7 2
0.87587.5%
 

Contributing tests

This file is covered by 113 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 Document.
26    *
27    * @version $Id: b3ef7deb623c1a96e656ed8910fe22c18531fa1d $
28    * @since 2.5RC1
29    */
 
30    public class DocumentResourceReference 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  636 toggle public DocumentResourceReference(String reference)
46    {
47  636 super(reference, ResourceType.DOCUMENT);
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  6 toggle public String getQueryString()
55    {
56  6 return getParameter(QUERY_STRING);
57    }
58   
59    /**
60    * @param queryString see {@link #getQueryString()}
61    */
 
62  2 toggle public void setQueryString(String queryString)
63    {
64  2 if (!StringUtils.isEmpty(queryString)) {
65  2 setParameter(QUERY_STRING, queryString);
66    }
67    }
68   
69    /**
70    * @return the anchor name pointing to an anchor defined in the referenced document or null if no anchor has been
71    * specified (in which case the reference points to the top of the document). Note that in XWiki anchors are
72    * automatically created for titles. Example: "TableOfContentAnchor"
73    */
 
74  6 toggle public String getAnchor()
75    {
76  6 return getParameter(ANCHOR);
77    }
78   
79    /**
80    * @param anchor see {@link #getAnchor()}
81    */
 
82  78 toggle public void setAnchor(String anchor)
83    {
84  78 if (!StringUtils.isEmpty(anchor)) {
85  78 setParameter(ANCHOR, anchor);
86    }
87    }
88    }