Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
30   97   10   7.5
8   63   0.33   4
4     2.5  
1    
 
  AttachRadeoxMacroConverter       Line # 40 30 0% 10 0 100% 1.0
 
  (1)
 
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.internal.parser.xwiki10.macro;
21   
22    import java.util.Map;
23   
24    import javax.inject.Named;
25    import javax.inject.Singleton;
26   
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.rendering.parser.xwiki10.FilterContext;
29    import org.xwiki.rendering.parser.xwiki10.macro.AbstractRadeoxMacroConverter;
30    import org.xwiki.rendering.parser.xwiki10.macro.RadeoxMacroParameter;
31    import org.xwiki.rendering.parser.xwiki10.macro.RadeoxMacroParameters;
32   
33    /**
34    * @version $Id: 5cb30ef9d46e378572b2ec5e6447864f59487944 $
35    * @since 1.8M1
36    */
37    @Component
38    @Named("attach")
39    @Singleton
 
40    public class AttachRadeoxMacroConverter extends AbstractRadeoxMacroConverter
41    {
 
42  1 toggle public AttachRadeoxMacroConverter()
43    {
44  1 registerParameter("");
45  1 registerParameter("file");
46  1 registerParameter("document");
47  1 registerParameter("title");
48  1 registerParameter("rel");
49  1 registerParameter("id");
50  1 registerParameter("fromIncludingDoc");
51    }
52   
 
53  5 toggle @Override
54    public String convert(String name, RadeoxMacroParameters parameters, String content, FilterContext filterContext)
55    {
56  5 StringBuffer result = new StringBuffer();
57   
58  5 if (parameters.size() == 1 || (parameters.size() == 2 && parameters.containsKey("document"))) {
59  3 appendSimpleAttach(result, parameters);
60    } else {
61  2 result.append("[[");
62  2 if (parameters.containsKey("file")) {
63  1 result.append(parameters.get(""));
64  1 result.append(">>");
65    }
66  2 appendSimpleAttach(result, parameters);
67  2 result.append("||");
68  2 Map<String, String> parametersClone = convertParameters(parameters);
69  2 parametersClone.remove("");
70  2 parametersClone.remove("document");
71  2 parametersClone.remove("file");
72  2 appendParameters(result, parametersClone);
73  2 result.append("]]");
74    }
75   
76  5 return result.toString();
77    }
78   
 
79  5 toggle private void appendSimpleAttach(StringBuffer result, RadeoxMacroParameters parameters)
80    {
81  5 result.append("attach:");
82   
83  5 RadeoxMacroParameter document = parameters.get("document");
84  5 if (document != null) {
85  1 result.append(document);
86  1 result.append("@");
87    }
88   
89  5 result.append(parameters.containsKey("file") ? parameters.get("file") : parameters.get(""));
90    }
91   
 
92  5 toggle @Override
93    public boolean supportContent()
94    {
95  5 return false;
96    }
97    }