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

File AttachmentResourceReference.java

 

Coverage histogram

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

Code metrics

4
7
5
1
91
31
7
1
1.4
5
1.4

Classes

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

Contributing tests

This file is covered by 19 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 an Attachment.
26    *
27    * @version $Id: 89ae99494cf286a71e0095ba5341facbc4e568ec $
28    * @since 2.5RC1
29    */
 
30    public class AttachmentResourceReference 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    * @since 5.3M2
41    */
42    public static final String ANCHOR = "anchor";
43   
44    /**
45    * @param reference see {@link #getReference()}
46    */
 
47  124 toggle public AttachmentResourceReference(String reference)
48    {
49  124 super(reference, ResourceType.ATTACHMENT);
50    }
51   
52    /**
53    * @return the query string for specifying parameters that will be used in the rendered URL or null if no query
54    * string has been specified. Example: {@code mydata1=5&mydata2=Hello}
55    */
 
56  0 toggle public String getQueryString()
57    {
58  0 return getParameter(QUERY_STRING);
59    }
60   
61    /**
62    * @param queryString see {@link #getQueryString()}
63    */
 
64  0 toggle public void setQueryString(String queryString)
65    {
66  0 if (!StringUtils.isEmpty(queryString)) {
67  0 setParameter(QUERY_STRING, queryString);
68    }
69    }
70   
71    /**
72    * @return the anchor name pointing to an anchor defined in the referenced attachment or null if no anchor has been
73    * specified (in which case the reference points to the top of the attachment).
74    * @since 5.3M2
75    */
 
76  0 toggle public String getAnchor()
77    {
78  0 return getParameter(ANCHOR);
79    }
80   
81    /**
82    * @param anchor see {@link #getAnchor()}
83    * @since 5.3M2
84    */
 
85  1 toggle public void setAnchor(String anchor)
86    {
87  1 if (!StringUtils.isEmpty(anchor)) {
88  1 setParameter(ANCHOR, anchor);
89    }
90    }
91    }