1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.render

File WikiSubstitution.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
19
15
1
119
80
15
0.79
1.27
15
1

Classes

Class Line # Actions
WikiSubstitution 31 19 0% 15 34
0.00%
 

Contributing tests

No tests hitting this source file were found.

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 com.xpn.xwiki.render;
21   
22    import org.apache.oro.text.regex.MatchResult;
23    import org.apache.oro.text.regex.Pattern;
24    import org.apache.oro.text.regex.PatternMatcher;
25    import org.apache.oro.text.regex.PatternMatcherInput;
26    import org.apache.oro.text.regex.Perl5Matcher;
27    import org.apache.oro.text.regex.Perl5Substitution;
28   
29    import com.xpn.xwiki.util.Util;
30   
 
31    public class WikiSubstitution extends Perl5Substitution
32    {
33   
34    private Pattern pattern;
35   
36    private Util util;
37   
 
38  0 toggle public WikiSubstitution(com.xpn.xwiki.util.Util util)
39    {
40  0 setUtil(util);
41  0 setSubstitution("$&");
42    }
43   
 
44  0 toggle public WikiSubstitution(Util util, String patternparam)
45    {
46  0 setUtil(util);
47  0 setPattern(makePattern(patternparam));
48  0 setSubstitution("$&");
49    }
50   
 
51  0 toggle public WikiSubstitution(Util util, String[] patternparam)
52    {
53  0 this.setPattern(Util.getPatterns().getPattern(makePattern(patternparam)));
54  0 setSubstitution("$&");
55    }
56   
 
57  0 toggle public void setPattern(String patternparam)
58    {
59  0 setPattern(Util.getPatterns().getPattern(makePattern(patternparam)));
60    }
61   
 
62  0 toggle public void setPattern(String patternparam, int options)
63    {
64  0 setPattern(Util.getPatterns().getPattern(makePattern(patternparam), options));
65    }
66   
 
67  0 toggle public String makePattern(String patternparam)
68    {
69  0 return patternparam;
70    }
71   
 
72  0 toggle public String makePattern(String[] patternparam)
73    {
74  0 return patternparam.toString();
75    }
76   
 
77  0 toggle public String substitute(String line)
78    {
79  0 return org.apache.oro.text.regex.Util.substitute(getMatcher(), getPattern(), this, line,
80    org.apache.oro.text.regex.Util.SUBSTITUTE_ALL);
81    }
82   
 
83  0 toggle public Perl5Matcher getMatcher()
84    {
85  0 return this.util.getMatcher();
86    }
87   
 
88  0 toggle public Pattern getPattern()
89    {
90  0 return this.pattern;
91    }
92   
 
93  0 toggle public void setPattern(Pattern pattern)
94    {
95  0 this.pattern = pattern;
96    }
97   
 
98  0 toggle @Override
99    public void appendSubstitution(StringBuffer stringBuffer, MatchResult matchResult, int i,
100    PatternMatcherInput minput, PatternMatcher patternMatcher, Pattern pattern)
101    {
102  0 prepareSubstitution(matchResult);
103  0 super.appendSubstitution(stringBuffer, matchResult, i, minput, patternMatcher, pattern);
104    }
105   
 
106  0 toggle public void prepareSubstitution(MatchResult matchResult)
107    {
108    }
109   
 
110  0 toggle public com.xpn.xwiki.util.Util getUtil()
111    {
112  0 return this.util;
113    }
114   
 
115  0 toggle public void setUtil(com.xpn.xwiki.util.Util util)
116    {
117  0 this.util = util;
118    }
119    }