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

File XWikiDefaultPlugin.java

 

Coverage histogram

../../../../img/srcFileCovDistChart1.png
82% of files have more coverage

Code metrics

2
19
22
1
221
118
23
1.21
0.86
22
1.05

Classes

Class Line # Actions
XWikiDefaultPlugin 37 19 0% 23 40
0.0697674457%
 

Contributing tests

This file is covered by 1 test. .

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.plugin;
21   
22    import org.apache.commons.lang3.StringUtils;
23    import org.xwiki.localization.ContextualLocalizationManager;
24   
25    import com.xpn.xwiki.XWikiContext;
26    import com.xpn.xwiki.api.Api;
27    import com.xpn.xwiki.doc.XWikiAttachment;
28    import com.xpn.xwiki.web.Utils;
29   
30    /**
31    * Abstract base plugin implementation.
32    *
33    * @version $Id: 7888c502291313347588bc0f32380b8ab9c90ba7 $
34    * @deprecated the plugin technology is deprecated, consider rewriting as components
35    */
36    @Deprecated
 
37    public class XWikiDefaultPlugin implements XWikiPluginInterface
38    {
39    /**
40    * The plugin name.
41    *
42    * @see #getName()
43    */
44    private String name;
45   
46    private ContextualLocalizationManager localization;
47   
48    /**
49    * The mandatory plugin constructor, this is the method called (through reflection) by the plugin manager.
50    *
51    * @param name the plugin name, usually ignored, since plugins have a fixed name
52    * @param className the name of this class, ignored
53    * @param context the current request context
54    */
 
55  0 toggle public XWikiDefaultPlugin(String name, String className, XWikiContext context)
56    {
57  0 setClassName(className);
58  0 setName(name);
59    }
60   
 
61  6267 toggle @Override
62    public String getName()
63    {
64  6267 return this.name;
65    }
66   
 
67  0 toggle @Override
68    public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
69    {
70    // No public API by default
71  0 return null;
72    }
73   
 
74  0 toggle @Override
75    public void init(XWikiContext context)
76    {
77    // The default is to do nothing
78    }
79   
 
80  8 toggle @Override
81    public void virtualInit(XWikiContext context)
82    {
83    // The default is to do nothing
84    }
85   
 
86  0 toggle @Override
87    public void flushCache(XWikiContext context)
88    {
89  0 flushCache();
90    }
91   
92    /**
93    * Older equivalent of the {@link #flushCache(XWikiContext)} method without a context provided.
94    *
95    * @deprecated use {@link #flushCache(XWikiContext)} instead
96    */
 
97  0 toggle @Deprecated
98    public void flushCache()
99    {
100    // The default is to do nothing
101    }
102   
 
103  0 toggle @Override
104    public void beginParsing(XWikiContext context)
105    {
106    // The default is to do nothing
107    }
108   
 
109  0 toggle @Override
110    public void beginRendering(XWikiContext context)
111    {
112    // The default is to do nothing
113    }
114   
 
115  0 toggle @Override
116    public String commonTagsHandler(String content, XWikiContext context)
117    {
118    // The default is to do nothing, just return back the same content
119  0 return content;
120    }
121   
 
122  0 toggle @Override
123    public String startRenderingHandler(String content, XWikiContext context)
124    {
125    // The default is to do nothing, just return back the same content
126  0 return content;
127    }
128   
 
129  0 toggle @Override
130    public String outsidePREHandler(String line, XWikiContext context)
131    {
132    // The default is to do nothing, just return back the same content
133  0 return line;
134    }
135   
 
136  0 toggle @Override
137    public String insidePREHandler(String line, XWikiContext context)
138    {
139    // The default is to do nothing, just return back the same content
140  0 return line;
141    }
142   
 
143  0 toggle @Override
144    public String endRenderingHandler(String content, XWikiContext context)
145    {
146    // The default is to do nothing, just return back the same content
147  0 return content;
148    }
149   
 
150  0 toggle @Override
151    public void endRendering(XWikiContext context)
152    {
153    // The default is to do nothing
154    }
155   
 
156  0 toggle @Override
157    public String endParsing(String content, XWikiContext context)
158    {
159  0 return content;
160    }
161   
 
162  0 toggle @Override
163    public XWikiAttachment downloadAttachment(XWikiAttachment attachment, XWikiContext context)
164    {
165    // The default is to do nothing, just return the original attachment
166  0 return attachment;
167    }
168   
 
169  0 toggle protected ContextualLocalizationManager getLocalization()
170    {
171  0 if (this.localization == null) {
172  0 this.localization = Utils.getComponent(ContextualLocalizationManager.class);
173    }
174   
175  0 return this.localization;
176    }
177   
 
178  0 toggle protected String localizePlainOrKey(String key, Object... parameters)
179    {
180  0 return StringUtils.defaultString(getLocalization().getTranslationPlain(key, parameters), key);
181    }
182   
183    /**
184    * Set the plugin name. Don't use outside the constructor.
185    *
186    * @param name the new name of the plugin
187    * @deprecated most plugins hard code their names, so this doesn't really work
188    */
 
189  0 toggle @Deprecated
190    public void setName(String name)
191    {
192    // Shouldn't really change the name of the plugin, but for backwards compatibility...
193  0 this.name = name;
194    }
195   
196    /**
197    * Old method that doesn't really work. Don't use.
198    *
199    * @return the name of the plugin
200    * @deprecated use {@link #getName()} instead
201    */
 
202  0 toggle @Deprecated
203    public String getClassName()
204    {
205  0 return this.name;
206    }
207   
208    /**
209    * Old method that doesn't really work. Don't use.
210    *
211    * @param name the new name of the plugin
212    * @deprecated most plugins hard code their names, so this doesn't really work, and changing the classname isn't
213    * really possible
214    */
 
215  0 toggle @Deprecated
216    public void setClassName(String name)
217    {
218    // Shouldn't really change the name of the plugin, but for backwards compatibility...
219  0 this.name = name;
220    }
221    }