You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2014/02/12 00:13:58 UTC
svn commit: r1567452 [1/2] - in /jspwiki/trunk: ./ jspwiki-war/
jspwiki-war/src/main/java/org/apache/wiki/forms/
jspwiki-war/src/main/java/org/apache/wiki/plugin/
jspwiki-war/src/main/java/org/apache/wiki/rss/
jspwiki-war/src/main/java/org/apache/wiki/...
Author: juanpablo
Date: Tue Feb 11 23:13:58 2014
New Revision: 1567452
URL: http://svn.apache.org/r1567452
Log:
* JSPWIKI-819: Consider replacing ECS with JDOM, thanks to Ichiro Furusato
Added:
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XHTML.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XhtmlUtil.java
jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/ui/admin/
jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/ui/admin/beans/
jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/ui/admin/beans/PluginBeanTest.java
Modified:
jspwiki/trunk/jspwiki-war/pom.xml
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormInput.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormOutput.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormSelect.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/IndexPlugin.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/Feed.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/RSS10Feed.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XmlUtil.java
jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
jspwiki/trunk/pom.xml
Modified: jspwiki/trunk/jspwiki-war/pom.xml
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/pom.xml?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/pom.xml (original)
+++ jspwiki/trunk/jspwiki-war/pom.xml Tue Feb 11 23:13:58 2014
@@ -123,11 +123,6 @@
</dependency>
<dependency>
- <groupId>ecs</groupId>
- <artifactId>ecs</artifactId>
- </dependency>
-
- <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormInput.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormInput.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormInput.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormInput.java Tue Feb 11 23:13:58 2014
@@ -16,24 +16,26 @@
specific language governing permissions and limitations
under the License.
*/
-package org.apache.wiki.forms;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
+package org.apache.wiki.forms;
-import org.apache.ecs.xhtml.input;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.plugin.WikiPlugin;
import org.apache.wiki.preferences.Preferences;
import org.apache.wiki.util.TextUtil;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
/**
* Creates a simple input text field.
*/
-public class FormInput
- extends FormElement
+public class FormInput extends FormElement
{
/** Parameter name for setting the type. Value is <tt>{@value}</tt>. */
public static final String PARAM_TYPE = "type";
@@ -55,24 +57,27 @@ public class FormInput
String size = params.get( PARAM_SIZE );
ResourceBundle rb = Preferences.getBundle( ctx, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
- if( inputName == null )
+ if ( inputName == null ) {
throw new PluginException( rb.getString( "forminput.namemissing" ) );
- if( inputValue == null )
+ }
+ if ( inputValue == null ) {
inputValue = "";
-
+ }
+
// Don't render if no error and error-only-rendering is on.
FormInfo info = getFormInfo( ctx );
Map< String, String > previousValues = null;
- if( info != null )
+ if ( info != null )
{
- if( info.hide() )
+ if ( info.hide() )
{
+// return XhtmlUtil.serialize(XhtmlUtil.element(XHTML.p,rb.getString("forminput.noneedtoshow"))); // nope
return "<p>" + rb.getString( "forminput.noneedtoshow" ) + "</p>";
}
previousValues = info.getSubmission();
}
- if( previousValues == null )
+ if ( previousValues == null )
{
previousValues = new HashMap< String, String >();
}
@@ -80,22 +85,23 @@ public class FormInput
// In order to isolate posted form elements into their own
// map, prefix the variable name here. It will be stripped
// when the handler plugin is executed.
- input field = new input( inputType,
- HANDLERPARAM_PREFIX + inputName,
- inputValue );
-
+
+ Element field = XhtmlUtil.input(inputType,HANDLERPARAM_PREFIX + inputName,inputValue);
+
String checked = params.get("checked");
- field.setChecked( TextUtil.isPositive(checked)
- || "checked".equalsIgnoreCase(checked) );
+ field.setAttribute(XHTML.ATTR_class,
+ String.valueOf(TextUtil.isPositive(checked) || checked.equalsIgnoreCase("checked")));
String oldValue = previousValues.get( inputName );
- if( oldValue != null )
+ if ( oldValue != null )
{
- field.setValue( oldValue );
+ field.setAttribute(XHTML.ATTR_value,oldValue);
}
- if( size != null ) field.setSize( size );
+ if ( size != null ) {
+ field.setAttribute(XHTML.ATTR_size,size);
+ }
- return field.toString(ctx.getEngine().getContentEncoding());
+ return XhtmlUtil.serialize(field); // ctx.getEngine().getContentEncoding()
}
}
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormOutput.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormOutput.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormOutput.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormOutput.java Tue Feb 11 23:13:58 2014
@@ -16,11 +16,8 @@
specific language governing permissions and limitations
under the License.
*/
-package org.apache.wiki.forms;
-import java.text.MessageFormat;
-import java.util.Map;
-import java.util.ResourceBundle;
+package org.apache.wiki.forms;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.engine.PluginManager;
@@ -30,10 +27,14 @@ import org.apache.wiki.plugin.DefaultPlu
import org.apache.wiki.preferences.Preferences;
import org.apache.wiki.util.FormUtil;
+import java.text.MessageFormat;
+import java.util.Map;
+import java.util.ResourceBundle;
+
/**
*/
public class FormOutput
- extends FormElement
+ extends FormElement
{
/**
* Executes the FormHandler specified in a Form 'output' plugin,
@@ -53,7 +54,6 @@ public class FormOutput
* @param ctx {@inheritDoc}
* @param params {@inheritDoc}
* @return {@inheritDoc}
- * @throws {@inheritDoc}
*/
public String execute( WikiContext ctx, Map< String, String > params )
throws PluginException
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormSelect.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormSelect.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormSelect.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormSelect.java Tue Feb 11 23:13:58 2014
@@ -16,23 +16,23 @@
specific language governing permissions and limitations
under the License.
*/
-package org.apache.wiki.forms;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
+package org.apache.wiki.forms;
-import org.apache.ecs.ConcreteElement;
-import org.apache.ecs.xhtml.option;
-import org.apache.ecs.xhtml.select;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.plugin.WikiPlugin;
import org.apache.wiki.preferences.Preferences;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
/**
* Creates a Form select field.
- *
*/
public class FormSelect
extends FormElement
@@ -49,35 +49,38 @@ public class FormSelect
ResourceBundle rb = Preferences.getBundle( ctx, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
Map< String, String > previousValues = null;
- if( info != null )
+ if ( info != null )
{
- if( info.hide() )
+ if ( info.hide() )
{
return "<p>" + rb.getString( "forminput.noneedtoshow" ) + "</p>";
}
previousValues = info.getSubmission();
}
- if( previousValues == null )
+ if ( previousValues == null )
{
previousValues = new HashMap< String, String >();
}
- ConcreteElement field = buildSelect( params, previousValues, rb );
+ Element field = buildSelect( params, previousValues, rb );
// We should look for extra params, e.g. width, ..., here.
- return field.toString( ctx.getEngine().getContentEncoding() );
+ return XhtmlUtil.serialize(field); // ctx.getEngine().getContentEncoding()
}
/**
* Builds a Select element.
*/
- private select buildSelect( Map< String, String > pluginParams, Map< String, String > ctxValues, ResourceBundle rb )
- throws PluginException
+ private Element buildSelect(
+ Map<String,String> pluginParams,
+ Map<String,String> ctxValues,
+ ResourceBundle rb )
+ throws PluginException
{
String inputName = pluginParams.get( PARAM_INPUTNAME );
- if( inputName == null ) {
+ if ( inputName == null ) {
throw new PluginException( rb.getString( "formselect.namemissing" ) );
}
@@ -88,30 +91,30 @@ public class FormSelect
// some input application the default value.
//
String optionSeparator = pluginParams.get( "separator" );
- if( optionSeparator == null ) {
+ if ( optionSeparator == null ) {
optionSeparator = ctxValues.get( "separator." + inputName);
}
- if( optionSeparator == null ) {
+ if ( optionSeparator == null ) {
optionSeparator = ctxValues.get( "select.separator" );
}
- if( optionSeparator == null ) {
+ if ( optionSeparator == null ) {
optionSeparator = ";";
}
String optionSelector = pluginParams.get( "selector" );
- if( optionSelector == null ) {
+ if ( optionSelector == null ) {
optionSelector = ctxValues.get( "selector." + inputName );
}
- if( optionSelector == null ) {
+ if ( optionSelector == null ) {
optionSelector = ctxValues.get( "select.selector" );
}
- if( optionSelector == null ) {
+ if ( optionSelector == null ) {
optionSelector = "*";
}
- if( optionSelector.equals( optionSeparator ) ) {
+ if ( optionSelector.equals( optionSeparator ) ) {
optionSelector = null;
}
- if( inputValue == null ) {
+ if ( inputValue == null ) {
inputValue = "";
}
@@ -119,8 +122,8 @@ public class FormSelect
// that the plugin or something else has given us a better
// list to display.
boolean contextValueOverride = false;
- if( previousValue != null ) {
- if( previousValue.indexOf( optionSeparator ) != -1 ) {
+ if ( previousValue != null ) {
+ if ( previousValue.indexOf( optionSeparator ) != -1 ) {
inputValue = previousValue;
previousValue = null;
} else {
@@ -134,7 +137,7 @@ public class FormSelect
String[] options = inputValue.split( optionSeparator );
int previouslySelected = -1;
- option[] optionElements = new option[options.length];
+ Element[] optionElements = new Element[options.length];
//
// Figure out which one of the options to select: prefer the one
@@ -145,26 +148,34 @@ public class FormSelect
int indicated = -1;
options[i] = options[i].trim();
- if( optionSelector != null && options[i].startsWith( optionSelector ) ) {
+ if ( optionSelector != null && options[i].startsWith( optionSelector ) ) {
options[i] = options[i].substring( optionSelector.length() );
indicated = i;
}
- if( previouslySelected == -1 ) {
- if( !contextValueOverride && indicated > 0 ) {
+ if ( previouslySelected == -1 ) {
+ if ( !contextValueOverride && indicated > 0 ) {
previouslySelected = indicated;
- } else if( previousValue != null && options[i].equals( previousValue ) ) {
+ } else if ( previousValue != null && options[i].equals( previousValue ) ) {
previouslySelected = i;
}
}
- optionElements[i] = new option( options[i] );
- optionElements[i].addElement( options[i] );
+ // huh?
+// optionElements[i] = new option( options[i] );
+// optionElements[i].addElement( options[i] );
+
+ optionElements[i] = XhtmlUtil.element(XHTML.option,options[i]);
}
- if( previouslySelected > -1 ) {
- optionElements[previouslySelected].setSelected(true);
+ if ( previouslySelected > -1 ) {
+ optionElements[previouslySelected].setAttribute(XHTML.ATTR_selected,"true");
}
- return new select( HANDLERPARAM_PREFIX + inputName, optionElements );
+ Element select = XhtmlUtil.element(XHTML.select);
+ select.setAttribute(XHTML.ATTR_name,HANDLERPARAM_PREFIX + inputName);
+ for ( Element option : optionElements ) {
+ select.addContent(option);
+ }
+ return select;
}
}
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java Tue Feb 11 23:13:58 2014
@@ -16,25 +16,25 @@
specific language governing permissions and limitations
under the License.
*/
-package org.apache.wiki.forms;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
+package org.apache.wiki.forms;
-import org.apache.ecs.ConcreteElement;
-import org.apache.ecs.xhtml.textarea;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.plugin.WikiPlugin;
import org.apache.wiki.preferences.Preferences;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
/**
* Creates a Form text area element. You may specify the size of the textarea
* by using the {@link #PARAM_COLS} and {@link #PARAM_ROWS} to signify the width
- * and height of the area.
- *
+ * and height of the area.
*/
public class FormTextarea extends FormElement
{
@@ -53,53 +53,61 @@ public class FormTextarea extends FormEl
Map< String, String > previousValues = null;
ResourceBundle rb = Preferences.getBundle( ctx, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
- if( info != null ) {
- if( info.hide() ) {
+ if ( info != null ) {
+ if ( info.hide() ) {
return "<p>" + rb.getString( "formclose.noneedtoshow" ) + "</p>";
}
previousValues = info.getSubmission();
}
- if( previousValues == null ) {
+ if ( previousValues == null ) {
previousValues = new HashMap< String, String >();
}
- ConcreteElement field = null;
-
- field = buildTextArea( params, previousValues, rb );
+ Element field = buildTextArea( params, previousValues, rb );
// We should look for extra params, e.g. width, ..., here.
- return field.toString( ctx.getEngine().getContentEncoding() );
+ return XhtmlUtil.serialize(field); // ctx.getEngine().getContentEncoding()
}
- private textarea buildTextArea( Map< String, String > params, Map< String, String > previousValues, ResourceBundle rb )
- throws PluginException
+ private Element buildTextArea(
+ Map<String,String> params,
+ Map<String,String> previousValues,
+ ResourceBundle rb )
+ throws PluginException
{
- String inputName = params.get( PARAM_INPUTNAME );
- String rows = params.get( PARAM_ROWS );
- String cols = params.get( PARAM_COLS );
+ String inputName = params.get(PARAM_INPUTNAME);
+ String rows = params.get(PARAM_ROWS);
+ String cols = params.get(PARAM_COLS);
- if( inputName == null ) {
+ if ( inputName == null ) {
throw new PluginException( rb.getString( "formtextarea.namemissing" ) );
}
// In order to isolate posted form elements into their own
// map, prefix the variable name here. It will be stripped
// when the handler plugin is executed.
- textarea field = new textarea( HANDLERPARAM_PREFIX + inputName, rows, cols);
-
- if( previousValues != null )
+ Element field = XhtmlUtil.element(XHTML.textarea);
+ field.setAttribute(XHTML.ATTR_name,HANDLERPARAM_PREFIX + inputName);
+ if ( rows != null ) {
+ field.setAttribute(XHTML.ATTR_rows,rows);
+ }
+ if ( cols != null ) {
+ field.setAttribute(XHTML.ATTR_cols,cols);
+ }
+
+ if ( previousValues != null )
{
String oldValue = previousValues.get( inputName );
- if( oldValue != null )
+ if ( oldValue != null )
{
- field.addElement( oldValue );
+ field.addContent(oldValue);
}
else
{
- oldValue = params.get( PARAM_VALUE );
- if( oldValue != null ) {
- field.addElement( oldValue );
+ oldValue = params.get(PARAM_VALUE);
+ if ( oldValue != null ) {
+ field.addContent(oldValue);
}
}
}
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java Tue Feb 11 23:13:58 2014
@@ -16,33 +16,10 @@
specific language governing permissions and limitations
under the License.
*/
-package org.apache.wiki.plugin;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
+package org.apache.wiki.plugin;
import org.apache.commons.lang.ClassUtils;
-import org.apache.ecs.xhtml.b;
-import org.apache.ecs.xhtml.div;
-import org.apache.ecs.xhtml.li;
-import org.apache.ecs.xhtml.pre;
-import org.apache.ecs.xhtml.ul;
import org.apache.log4j.Logger;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.MatchResult;
@@ -64,9 +41,30 @@ import org.apache.wiki.preferences.Prefe
import org.apache.wiki.util.ClassUtil;
import org.apache.wiki.util.FileUtil;
import org.apache.wiki.util.TextUtil;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
import org.apache.wiki.util.XmlUtil;
import org.jdom2.Element;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
/**
* Manages plugin classes. There exists a single instance of PluginManager
* per each instance of WikiEngine, that is, each JSPWiki instance.
@@ -189,7 +187,7 @@ public class DefaultPluginManager extend
super( engine );
String packageNames = props.getProperty( PROP_SEARCHPATH );
- if( packageNames != null ) {
+ if ( packageNames != null ) {
StringTokenizer tok = new StringTokenizer( packageNames, "," );
while( tok.hasMoreTokens() ) {
@@ -271,26 +269,28 @@ public class DefaultPluginManager extend
/**
* Outputs a HTML-formatted version of a stack trace.
*/
- private String stackTrace( Map< String, String > params, Throwable t ) {
- div d = new div();
- d.setClass( "debug" );
- d.addElement( "Plugin execution failed, stack trace follows:" );
+ private String stackTrace( Map<String,String> params, Throwable t )
+ {
+ Element div = XhtmlUtil.element(XHTML.div,"Plugin execution failed, stack trace follows:");
+ div.setAttribute(XHTML.ATTR_class,"debug");
+
+
StringWriter out = new StringWriter();
- t.printStackTrace( new PrintWriter( out ) );
- d.addElement( new pre( out.toString() ) );
- d.addElement( new b( "Parameters to the plugin" ) );
-
- ul list = new ul();
- for( Iterator<Map.Entry< String, String > > i = params.entrySet().iterator(); i.hasNext(); ) {
- Map.Entry< String, String > e = i.next();
- String key = e.getKey();
+ t.printStackTrace(new PrintWriter(out));
+ div.addContent(XhtmlUtil.element(XHTML.pre,out.toString()));
+ div.addContent(XhtmlUtil.element(XHTML.b,"Parameters to the plugin"));
- list.addElement( new li( key + "'='" + e.getValue() ) );
+ Element list = XhtmlUtil.element(XHTML.ul);
+
+ for( Iterator<Map.Entry<String,String>> i = params.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry<String,String> e = i.next();
+ String key = e.getKey();
+ list.addContent(XhtmlUtil.element(XHTML.li,key + "'='" + e.getValue()));
}
- d.addElement( list );
-
- return d.toString();
+ div.addContent(list);
+
+ return XhtmlUtil.serialize(div);
}
/**
@@ -678,6 +678,7 @@ public class DefaultPluginManager extend
* @throws InstantiationException If the class cannot be instantiated-
* @throws IllegalAccessException If the class cannot be accessed.
*/
+
public WikiPlugin newPluginInstance(List<String> searchPath, List<String> externalJars) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
if( m_clazz == null ) {
m_clazz = ClassUtil.findClass(searchPath, externalJars ,m_className);
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/IndexPlugin.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/IndexPlugin.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/IndexPlugin.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/IndexPlugin.java Tue Feb 11 23:13:58 2014
@@ -16,110 +16,119 @@
specific language governing permissions and limitations
under the License.
*/
-package org.apache.wiki.plugin;
-
-import java.util.*;
-import java.util.regex.Pattern;
+package org.apache.wiki.plugin;
-import org.apache.ecs.Element;
-import org.apache.ecs.xhtml.div;
-import org.apache.ecs.xhtml.span;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.exceptions.ProviderException;
import org.apache.wiki.api.plugin.WikiPlugin;
+import org.apache.wiki.plugin.AbstractReferralPlugin;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+import org.jdom2.output.Format;
+import org.jdom2.output.XMLOutputter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
/**
- * A plugin that creates an index of pages according to a certain pattern.
- * <br>The default is to include all pages.
+ * A WikiPlugin that creates an index of pages according to a certain pattern.
+ * <br />
+ * The default is to include all pages.
* <p>
- * This is a complete rewrite of the old IndexPlugin under an Apache license.
- * <p>Parameters (From AbstractReferralPlugin) : </p>
+ * This is a rewrite of the earlier JSPWiki IndexPlugin using JDOM2.
+ 8 </p>
+ * <p>
+ * Parameters (from AbstractReferralPlugin):
+ * </p>
* <ul>
* <li><b>include</b> - A regexp pattern for marking which pages should be included.</li>
* <li><b>exclude</b> - A regexp pattern for marking which pages should be excluded.</li>
* </ul>
+ *
+ * @author Ichiro Furusato
*/
-public class IndexPlugin extends AbstractReferralPlugin implements WikiPlugin
+public class IndexPlugin extends AbstractReferralPlugin implements WikiPlugin
{
- private static Logger log = Logger.getLogger( IndexPlugin.class );
+ private static Logger log = Logger.getLogger(IndexPlugin.class);
+
+ private Namespace xmlns_XHTML = Namespace.getNamespace("http://www.w3.org/1999/xhtml");
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
- public String execute( WikiContext context, Map<String, String> params ) throws PluginException
+ public String execute( WikiContext context, Map<String,String> params ) throws PluginException
{
- String include = params.get( PARAM_INCLUDE );
- String exclude = params.get( PARAM_EXCLUDE );
-
- List<String> pages;
- div masterDiv = new div();
- masterDiv.setClass( "index" );
-
- div indexDiv = new div();
+ String include = params.get(PARAM_INCLUDE);
+ String exclude = params.get(PARAM_EXCLUDE);
- masterDiv.addElement( indexDiv );
- indexDiv.setClass( "header" );
- try
- {
- pages = listPages( context, include, exclude );
- context.getEngine().getPageSorter().sort( pages );
-
+ Element masterDiv = getElement("div","index");
+ Element indexDiv = getElement("div","header");
+ masterDiv.addContent(indexDiv);
+ try {
+ List<String> pages = listPages(context,include,exclude);
+ context.getEngine().getPageSorter().sort(pages);
char initialChar = ' ';
-
- div currentDiv = new div();
-
- for( String name : pages )
- {
- if( name.charAt( 0 ) != initialChar )
- {
- if( initialChar != ' ' ) indexDiv.addElement( " - " );
- initialChar = name.charAt( 0 );
-
- masterDiv.addElement( makeHeader(initialChar) );
-
- currentDiv = new div();
- currentDiv.setClass("body");
- masterDiv.addElement( currentDiv );
-
- indexDiv.addElement( "<a href='#"+initialChar+"'>"+initialChar+"</a>" );
+ Element currentDiv = new Element("div",xmlns_XHTML);
+ for ( String name : pages ) {
+ if ( name.charAt(0) != initialChar ) {
+ if ( initialChar != ' ' ) {
+ indexDiv.addContent(" - ");
+ }
+ initialChar = name.charAt(0);
+ masterDiv.addContent(makeHeader(String.valueOf(initialChar)));
+ currentDiv = getElement("div","body");
+ masterDiv.addContent(currentDiv);
+ indexDiv.addContent(getLink("#"+initialChar,String.valueOf(initialChar)));
+ } else {
+ currentDiv.addContent(", ");
}
- else
- {
- currentDiv.addElement( ", " );
- }
-
- String link = "<a href='"+
- context.getURL( WikiContext.VIEW, name )+
- "'>"+name+"</a>";
-
- currentDiv.addElement( link );
+ currentDiv.addContent(getLink(context.getURL(WikiContext.VIEW,name),name));
}
- }
- catch( ProviderException e )
- {
- log.warn("Could not load page index",e);
+
+ } catch( ProviderException e ) {
+ log.warn("could not load page index",e);
throw new PluginException( e.getMessage() );
}
-
- return masterDiv.toString();
+ // serialize to raw format string (no changes to whitespace)
+ XMLOutputter out = new XMLOutputter(Format.getRawFormat());
+ return out.outputString(masterDiv);
}
+
+
+ private Element getLink( String href, String content )
+ {
+ Element a = new Element("a",xmlns_XHTML);
+ a.setAttribute("href",href);
+ a.addContent(content);
+ return a;
+ }
+
- /**
- * Create the DOM for a heading
- * @param initialChar
- * @return A span element.
- */
- private Element makeHeader( char initialChar )
+ private Element makeHeader( String initialChar )
{
- span s = new span();
- s.setClass( "section" );
- s.addElement( "<a name='"+initialChar+"'>"+initialChar+"</a>" );
+ Element span = getElement("span","section");
+ Element a = new Element("a",xmlns_XHTML);
+ a.setAttribute("id",initialChar);
+ a.addContent(initialChar);
+ span.addContent(a);
+ return span;
+ }
- return s;
+
+ private Element getElement( String gi, String classValue )
+ {
+ Element elt = new Element(gi,xmlns_XHTML);
+ elt.setAttribute("class",classValue);
+ return elt;
}
+
/**
* Grabs a list of all pages and filters them according to the include/exclude patterns.
@@ -131,27 +140,25 @@ public class IndexPlugin extends Abstra
* @throws ProviderException
*/
private List<String> listPages( WikiContext context, String include, String exclude )
- throws ProviderException
+ throws ProviderException
{
- Pattern includePtrn = include != null ? Pattern.compile( include ) : Pattern.compile(".*");
- Pattern excludePtrn = exclude != null ? Pattern.compile( exclude ) : Pattern.compile("\\p{Cntrl}"); // There are no control characters in page names
-
- ArrayList<String> result = new ArrayList<String>();
-
- Collection pages = context.getEngine().getReferenceManager().findCreated();
-
- for( Iterator i = pages.iterator(); i.hasNext(); )
- {
+ Pattern includePtrn = include != null
+ ? Pattern.compile( include )
+ : Pattern.compile(".*");
+ Pattern excludePtrn = exclude != null
+ ? Pattern.compile( exclude )
+ : Pattern.compile("\\p{Cntrl}"); // there are no control characters in page names
+ List<String> result = new ArrayList<String>();
+ @SuppressWarnings("unchecked")
+ Collection<String> pages = (Collection<String>)context.getEngine().getReferenceManager().findCreated();
+ for ( Iterator<String> i = pages.iterator(); i.hasNext(); ) {
String pageName = (String) i.next();
-
- if( excludePtrn.matcher( pageName ).matches() ) continue;
- if( includePtrn.matcher( pageName ).matches() )
- {
+ if ( excludePtrn.matcher( pageName ).matches() ) continue;
+ if ( includePtrn.matcher( pageName ).matches() ) {
result.add( pageName );
}
}
-
return result;
}
-}
+}
\ No newline at end of file
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java Tue Feb 11 23:13:58 2014
@@ -20,9 +20,13 @@ package org.apache.wiki.plugin;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Map;
-import org.apache.ecs.xhtml.*;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
@@ -34,55 +38,50 @@ import org.apache.wiki.i18n.Internationa
import org.apache.wiki.preferences.Preferences;
import org.apache.wiki.preferences.Preferences.TimeFormat;
import org.apache.wiki.util.TextUtil;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
/**
* Returns the Recent Changes in the wiki being a date-sorted list of page names.
*
- * <p>Parameters : </p>
+ * <p>Parameters: </p>
* <ul>
* <li><b>since</b> - show changes from the last n days, for example since=5 shows only the pages that were changed in the last five days</li>
* <li><b>format</b> - (full|compact) : if "full", then display a long version with all possible info. If "compact", then be as compact as possible.</li>
* <li><b>timeFormat</b> - the time format to use, the default is "HH:mm:ss"</li>
* <li><b>dateFormat</b> - the date format to use, the default is "dd.MM.yyyy"</li>
* </ul>
- *
*/
-public class RecentChangesPlugin extends AbstractReferralPlugin implements WikiPlugin
-{
+public class RecentChangesPlugin extends AbstractReferralPlugin implements WikiPlugin {
+
+ private static final Logger log = Logger.getLogger(RecentChangesPlugin.class);
+
/** Parameter name for the separator format. Value is <tt>{@value}</tt>. */
- public static final String PARAM_FORMAT = "format";
+ public static final String PARAM_FORMAT = "format";
/** Parameter name for the separator timeFormat. Value is <tt>{@value}</tt>. */
public static final String PARAM_TIME_FORMAT = "timeFormat";
/** Parameter name for the separator dateFormat. Value is <tt>{@value}</tt>. */
public static final String PARAM_DATE_FORMAT = "dateFormat";
/** How many days we show by default. */
- private static final int DEFAULT_DAYS = 100*365;
+ private static final int DEFAULT_DAYS = 100*365;
public static final String DEFAULT_TIME_FORMAT ="HH:mm:ss";
public static final String DEFAULT_DATE_FORMAT ="dd.MM.yyyy";
- private static Logger log = Logger.getLogger( RecentChangesPlugin.class );
-
- private boolean isSameDay( Date a, Date b )
- {
- Calendar aa = Calendar.getInstance(); aa.setTime(a);
- Calendar bb = Calendar.getInstance(); bb.setTime(b);
-
- return aa.get( Calendar.YEAR ) == bb.get( Calendar.YEAR ) &&
- aa.get( Calendar.DAY_OF_YEAR ) == bb.get( Calendar.DAY_OF_YEAR );
- }
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
public String execute( WikiContext context, Map<String, String> params )
throws PluginException
{
int since = TextUtil.parseIntParameter( params.get( "since" ), DEFAULT_DAYS );
- int spacing = 4;
+ String spacing = "4";
boolean showAuthor = true;
boolean showChangenote = true;
- int tablewidth = 4;
+ String tablewidth = "4";
WikiEngine engine = context.getEngine();
@@ -91,10 +90,10 @@ public class RecentChangesPlugin extends
//
if( "compact".equals( params.get(PARAM_FORMAT) ) )
{
- spacing = 0;
+ spacing = "0";
showAuthor = false;
showChangenote = false;
- tablewidth = 2;
+ tablewidth = "2";
}
Calendar sincedate = new GregorianCalendar();
@@ -103,21 +102,22 @@ public class RecentChangesPlugin extends
log.debug("Calculating recent changes from "+sincedate.getTime());
// FIXME: Should really have a since date on the getRecentChanges method.
- Collection changes = engine.getRecentChanges();
+ Collection<WikiPage> changes = engine.getRecentChanges();
super.initialize( context, params );
- changes = super.filterCollection( changes );
+ changes = super.filterCollection(changes);
- if( changes != null )
+ if ( changes != null )
{
Date olddate = new Date(0);
DateFormat fmt = getDateFormat( context, params );
DateFormat tfmt = getTimeFormat( context, params );
- table rt = new table();
- rt.setCellPadding(spacing).setClass("recentchanges");
-
- for( Iterator i = changes.iterator(); i.hasNext(); )
+ Element rt = XhtmlUtil.element(XHTML.table);
+ rt.setAttribute(XHTML.ATTR_class,"recentchanges");
+ rt.setAttribute(XHTML.ATTR_cellpadding,spacing);
+
+ for( Iterator<WikiPage> i = changes.iterator(); i.hasNext(); )
{
WikiPage pageref = (WikiPage) i.next();
@@ -130,51 +130,57 @@ public class RecentChangesPlugin extends
if( !isSameDay( lastmod, olddate ) )
{
- tr row = new tr();
- td col = new td();
+ Element row = XhtmlUtil.element(XHTML.tr);
+ Element col = XhtmlUtil.element(XHTML.td);
+ col.setAttribute(XHTML.ATTR_colspan,tablewidth);
+ col.setAttribute(XHTML.ATTR_class,"date");
+ col.addContent(XhtmlUtil.element(XHTML.b,fmt.format(lastmod)));
- col.setColSpan(tablewidth).setClass("date");
- col.addElement( new b().addElement(fmt.format(lastmod)) );
-
- rt.addElement(row);
- row.addElement(col);
+ rt.addContent(row);
+ row.addContent(col);
olddate = lastmod;
}
- String link = context.getURL( pageref instanceof Attachment ? WikiContext.ATTACH : WikiContext.VIEW,
+ String href = context.getURL( pageref instanceof Attachment ? WikiContext.ATTACH : WikiContext.VIEW,
pageref.getName() ) ;
- a linkel = new a(link,engine.beautifyTitle(pageref.getName()));
+ Element link = XhtmlUtil.link(href,engine.beautifyTitle(pageref.getName()));
- tr row = new tr();
+ Element row = XhtmlUtil.element(XHTML.tr);
+ Element col = XhtmlUtil.element(XHTML.td);
+ col.setAttribute(XHTML.ATTR_width,"30%");
+ col.addContent(link);
- td col = new td().setWidth("30%").addElement(linkel);
-
//
// Add the direct link to the attachment info.
//
if( pageref instanceof Attachment )
{
- linkel = new a().setHref(context.getURL(WikiContext.INFO,pageref.getName()));
- linkel.setClass("infolink");
- linkel.addElement( new img().setSrc(context.getURL(WikiContext.NONE, "images/attachment_small.png")));
-
- col.addElement( linkel );
+ link = XhtmlUtil.link(context.getURL(WikiContext.INFO,pageref.getName()),null);
+ link.setAttribute(XHTML.ATTR_class,"infolink");
+
+ Element img = XhtmlUtil.img(context.getURL(WikiContext.NONE,"images/attachment_small.png"),null);
+ link.addContent(img);
+
+ col.addContent(link);
}
- row.addElement(col);
- rt.addElement(row);
+ row.addContent(col);
+ rt.addContent(row);
if( pageref instanceof Attachment )
{
- row.addElement( new td(tfmt.format(lastmod)).setClass("lastchange") );
+ Element td = XhtmlUtil.element(XHTML.td,tfmt.format(lastmod));
+ td.setAttribute(XHTML.ATTR_class,"lastchange");
+ row.addContent(td);
}
else
{
- td infocol = (td) new td().setClass("lastchange");
- infocol.addElement( new a(context.getURL(WikiContext.DIFF, pageref.getName(), "r1=-1"),tfmt.format(lastmod)) );
- row.addElement(infocol);
+ Element infocol = XhtmlUtil.element(XHTML.td);
+ infocol.setAttribute(XHTML.ATTR_class,"lastchange");
+ infocol.addContent(XhtmlUtil.link(context.getURL(WikiContext.DIFF, pageref.getName(), "r1=-1"),tfmt.format(lastmod)));
+ row.addContent(infocol);
}
//
@@ -185,35 +191,36 @@ public class RecentChangesPlugin extends
{
String author = pageref.getAuthor();
- td authorinfo = new td();
- authorinfo.setClass("author");
+ Element authorinfo = XhtmlUtil.element(XHTML.td);
+ authorinfo.setAttribute(XHTML.ATTR_class,"author");
if( author != null )
{
if( engine.pageExists(author) )
{
- authorinfo.addElement( new a(context.getURL(WikiContext.VIEW, author),author) );
+ authorinfo.addContent(XhtmlUtil.link(context.getURL(WikiContext.VIEW, author),author));
}
else
{
- authorinfo.addElement(author);
+ authorinfo.addContent(author);
}
}
else
{
- authorinfo.addElement( Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE )
+ authorinfo.addContent( Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE )
.getString( "common.unknownauthor" ) );
}
- row.addElement( authorinfo );
+ row.addContent(authorinfo);
}
// Change note
if( showChangenote )
{
String changenote = (String)pageref.getAttribute(WikiPage.CHANGENOTE);
-
- row.addElement( new td(changenote != null ? changenote : "").setClass("changenote") );
+ Element td_changenote = XhtmlUtil.element(XHTML.td,changenote);
+ td_changenote.setAttribute(XHTML.ATTR_class,"changenote");
+ row.addContent(td_changenote);
}
// Revert note
@@ -224,15 +231,21 @@ public class RecentChangesPlugin extends
}
*/
}
-
- rt.setPrettyPrint(true);
- return rt.toString();
- }
-
+ return XhtmlUtil.serialize(rt,true);
+ }
return "";
}
+ private boolean isSameDay( Date a, Date b )
+ {
+ Calendar aa = Calendar.getInstance(); aa.setTime(a);
+ Calendar bb = Calendar.getInstance(); bb.setTime(b);
+
+ return aa.get( Calendar.YEAR ) == bb.get( Calendar.YEAR )
+ && aa.get( Calendar.DAY_OF_YEAR ) == bb.get( Calendar.DAY_OF_YEAR );
+ }
+
// TODO: Ideally the default behavior should be to return the default format for the default
// locale, but that is at odds with the 1st version of this plugin. We seek to preserve the
@@ -254,24 +267,20 @@ public class RecentChangesPlugin extends
{
String formatString = get(params, DEFAULT_DATE_FORMAT, PARAM_DATE_FORMAT);
- if( "".equals(formatString.trim() ) )
+ if( formatString.trim().equals("") )
{
return Preferences.getDateFormat( context, TimeFormat.DATE );
}
return new SimpleDateFormat( formatString );
-
}
-
- private String get(Map<String, String> params, String defaultValue, String paramName)
+ private String get( Map<String, String> params, String defaultValue, String paramName )
{
String value = params.get(paramName);
- return null == value ? defaultValue : value;
+ return value == null ? defaultValue : value;
}
-}
-
-
+}
\ No newline at end of file
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java Tue Feb 11 23:13:58 2014
@@ -18,16 +18,6 @@
*/
package org.apache.wiki.plugin;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.ecs.xhtml.b;
-import org.apache.ecs.xhtml.table;
-import org.apache.ecs.xhtml.td;
-import org.apache.ecs.xhtml.th;
-import org.apache.ecs.xhtml.tr;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
@@ -35,6 +25,14 @@ import org.apache.wiki.api.exceptions.Pl
import org.apache.wiki.api.exceptions.ProviderException;
import org.apache.wiki.api.plugin.WikiPlugin;
import org.apache.wiki.search.SearchResult;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
/**
* The "Search" plugin allows you to access the JSPWiki search routines and show the displays in an array on your page.
@@ -71,21 +69,22 @@ public class Search implements WikiPlugi
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
public String execute( WikiContext context, Map<String, String> params ) throws PluginException
{
int maxItems = Integer.MAX_VALUE;
- Collection results = null;
+ Collection<SearchResult> results = null;
String queryString = params.get( PARAM_QUERY );
String set = params.get( PARAM_SET );
String max = params.get( PARAM_MAX );
- if( set == null ) set = DEFAULT_SETNAME;
- if( max != null ) maxItems = Integer.parseInt( max );
+ if ( set == null ) set = DEFAULT_SETNAME;
+ if ( max != null ) maxItems = Integer.parseInt( max );
- if( queryString == null )
+ if ( queryString == null )
{
- results = (Collection)context.getVariable( set );
+ results = (Collection<SearchResult>)context.getVariable( set );
}
else
{
@@ -102,63 +101,78 @@ public class Search implements WikiPlugi
String res = "";
- if( results != null )
+ if ( results != null )
{
- res = renderResults( results, context, maxItems );
+ res = renderResults(results,context,maxItems);
}
return res;
}
- private Collection doBasicQuery( WikiContext context, String query )
+ private Collection<SearchResult> doBasicQuery( WikiContext context, String query )
throws ProviderException, IOException
{
log.debug("Searching for string "+query);
- Collection list = context.getEngine().findPages( query );
+ @SuppressWarnings("unchecked")
+ Collection<SearchResult> list = context.getEngine().findPages( query );
return list;
}
- private String renderResults( Collection results, WikiContext context, int maxItems )
+ private String renderResults( Collection<SearchResult> results, WikiContext context, int maxItems )
{
WikiEngine engine = context.getEngine();
- table t = new table();
- t.setBorder(0);
- t.setCellPadding(4);
-
- tr row = new tr();
- t.addElement( row );
- row.addElement( new th().setWidth("30%").setAlign("left").addElement("Page") );
- row.addElement( new th().setAlign("left").addElement("Score"));
-
+ Element table = XhtmlUtil.element(XHTML.table);
+ table.setAttribute(XHTML.ATTR_border,"0");
+ table.setAttribute(XHTML.ATTR_cellpadding,"4");
+
+ Element row = XhtmlUtil.element(XHTML.tr);
+ table.addContent(row);
+
+ Element th1 = XhtmlUtil.element(XHTML.th,"Page");
+ th1.setAttribute(XHTML.ATTR_width,"30%");
+ th1.setAttribute(XHTML.ATTR_align,"left");
+ row.addContent(th1);
+
+ Element th2 = XhtmlUtil.element(XHTML.th,"Score");
+ th2.setAttribute(XHTML.ATTR_align,"left");
+ row.addContent(th2);
+
int idx = 0;
- for( Iterator i = results.iterator(); i.hasNext() && idx++ <= maxItems; )
+ for ( Iterator<SearchResult> i = results.iterator(); i.hasNext() && idx++ <= maxItems; )
{
- SearchResult sr = (SearchResult) i.next();
- row = new tr();
+ SearchResult sr = i.next();
+ row = XhtmlUtil.element(XHTML.tr);
+
+ Element name = XhtmlUtil.element(XHTML.td);
+ name.setAttribute(XHTML.ATTR_width,"30%");
- td name = new td().setWidth("30%");
- name.addElement( "<a href=\""+
- context.getURL( WikiContext.VIEW, sr.getPage().getName() )+
- "\">"+engine.beautifyTitle(sr.getPage().getName())+"</a>");
- row.addElement( name );
+ name.addContent( XhtmlUtil.link(context.getURL( WikiContext.VIEW, sr.getPage().getName()),
+ engine.beautifyTitle(sr.getPage().getName())) );
+
+ row.addContent(name);
- row.addElement( new td().addElement(""+sr.getScore()));
+ row.addContent(XhtmlUtil.element(XHTML.td,""+sr.getScore()));
- t.addElement( row );
+ table.addContent(row);
}
- if( results.isEmpty() )
+ if ( results.isEmpty() )
{
- row = new tr();
+ row = XhtmlUtil.element(XHTML.tr);
+
+ Element td = XhtmlUtil.element(XHTML.td);
+ td.setAttribute(XHTML.ATTR_colspan,"2");
+ Element b = XhtmlUtil.element(XHTML.b,"No results");
+ td.addContent(b);
- row.addElement( new td().setColSpan(2).addElement( new b().addElement("No results")));
+ row.addContent(td);
- t.addElement(row);
+ table.addContent(row);
}
- return t.toString();
+ return XhtmlUtil.serialize(table);
}
}
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/Feed.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/Feed.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/Feed.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/Feed.java Tue Feb 11 23:13:58 2014
@@ -23,10 +23,10 @@ import java.util.List;
import javax.servlet.ServletContext;
+import org.apache.commons.lang.StringEscapeUtils;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.api.exceptions.NoSuchVariableException;
-import org.apache.wiki.util.TextUtil;
/**
* Represents an abstract feed.
@@ -191,15 +191,7 @@ public abstract class Feed {
* @param s The String to format. Null is safe.
* @return A formatted string.
*/
- // FIXME: Should probably be replaced by a library method.
- public static String format(String s) {
- if (s != null) {
- s = TextUtil.replaceString(s, "&", "&");
- s = TextUtil.replaceString(s, "<", "<");
- s = TextUtil.replaceString(s, ">", ">");
-
- return s.trim();
- }
- return null;
+ public static String format( String s ) {
+ return StringEscapeUtils.escapeXml( s );
}
}
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/RSS10Feed.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/RSS10Feed.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/RSS10Feed.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/rss/RSS10Feed.java Tue Feb 11 23:13:58 2014
@@ -20,13 +20,14 @@ package org.apache.wiki.rss;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Iterator;
-
-import org.apache.ecs.xml.XML;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiPage;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+import org.jdom2.Namespace;
+
/**
* Provides an implementation of an RSS 1.0 feed. In addition, this class is
@@ -34,149 +35,123 @@ import org.apache.wiki.WikiPage;
* <A HREF="http://usemod.com/cgi-bin/mb.pl?ModWiki">UseMod:ModWiki</A>.
*/
public class RSS10Feed extends Feed {
+
+ private static final Namespace NS_XMNLS = Namespace.getNamespace( "http://purl.org/rss/1.0/" );
+ private static final Namespace NS_RDF = Namespace.getNamespace( "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" );
+ private static final Namespace NS_DC = Namespace.getNamespace( "dc", "http://purl.org/dc/elements/1.1/" );
+ private static final Namespace NS_WIKI = Namespace.getNamespace( "wiki", "http://purl.org/rss/1.0/modules/wiki/" );
+
/**
* Create an RSS 1.0 feed for a given context.
*
* @param context {@inheritDoc}
*/
- public RSS10Feed(WikiContext context) {
- super(context);
+ public RSS10Feed( WikiContext context ) {
+ super( context );
}
- private XML getRDFItems() {
- XML items = new XML("items");
-
- XML rdfseq = new XML("rdf:Seq");
-
- for (Iterator i = m_entries.iterator(); i.hasNext(); ) {
- Entry e = (Entry) i.next();
+ private Element getRDFItems() {
+ Element items = new Element( "items", NS_XMNLS );
+ Element rdfseq = new Element( "Seq", NS_RDF );
+ for( Entry e : m_entries ) {
String url = e.getURL();
-
- rdfseq.addElement(new XML("rdf:li").addAttribute("rdf:resource", url));
+ rdfseq.addContent( new Element( "li", NS_RDF ).setAttribute( "resource", url, NS_RDF ) );
}
-
- items.addElement(rdfseq);
+ items.addContent( rdfseq );
return items;
}
- private void addItemList(XML root) {
+ private void addItemList( Element root ) {
SimpleDateFormat iso8601fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
-
WikiEngine engine = m_wikiContext.getEngine();
- for (Iterator i = m_entries.iterator(); i.hasNext(); ) {
- Entry e = (Entry) i.next();
+ for( Entry entry : m_entries ) {
+ String url = entry.getURL();
- String url = e.getURL();
-
- XML item = new XML("item");
- item.addAttribute("rdf:about", url);
-
- item.addElement(new XML("title").addElement(format(e.getTitle())));
-
- item.addElement(new XML("link").addElement(url));
-
- XML content = new XML("description");
+ Element item = new Element( "item", NS_XMNLS );
+ item.setAttribute( "about", url, NS_RDF );
+ item.addContent( new Element( "title", NS_XMNLS ).addContent( entry.getTitle() ) );
+ item.addContent( new Element( "link", NS_XMNLS ).addContent( url ) );
+ Element content = new Element( "description", NS_XMNLS );
// TODO: Add a size limiter here
- content.addElement(format(e.getContent()));
-
- item.addElement(content);
+ content.addContent( entry.getContent() );
+ item.addContent( content );
- WikiPage p = e.getPage();
-
- if (p.getVersion() != -1) {
- item.addElement(new XML("wiki:version").addElement(Integer.toString(p.getVersion())));
+ WikiPage p = entry.getPage();
+ if( p.getVersion() != -1 ) {
+ item.addContent( new Element( "version", NS_WIKI ).addContent( Integer.toString( p.getVersion() ) ) );
}
- if (p.getVersion() > 1) {
- item.addElement(new XML("wiki:diff").addElement(engine.getURL(WikiContext.DIFF,
- p.getName(),
- "r1=-1",
- true)));
+ if( p.getVersion() > 1 ) {
+ item.addContent( new Element( "diff", NS_WIKI )
+ .addContent( engine.getURL( WikiContext.DIFF, p.getName(), "r1=-1", true ) ) );
}
-
//
// Modification date.
- //
Calendar cal = Calendar.getInstance();
cal.setTime(p.getLastModified());
- cal.add(Calendar.MILLISECOND,
- -(cal.get(Calendar.ZONE_OFFSET) +
- (cal.getTimeZone().inDaylightTime(p.getLastModified()) ? cal.get(Calendar.DST_OFFSET) : 0)));
+ cal.add( Calendar.MILLISECOND,
+ - ( cal.get( Calendar.ZONE_OFFSET ) +
+ ( cal.getTimeZone().inDaylightTime( p.getLastModified() ) ? cal.get( Calendar.DST_OFFSET )
+ : 0 ) ) );
- item.addElement(new XML("dc:date").addElement(iso8601fmt.format(cal.getTime())));
+ item.addContent( new Element( "date", NS_DC ).addContent( iso8601fmt.format( cal.getTime() ) ) );
//
// Author
- String author = e.getAuthor();
- if (author == null) {
+ String author = entry.getAuthor();
+ if( author == null ) {
author = "unknown";
}
- XML contributor = new XML("dc:creator");
-
- item.addElement(contributor);
+ Element contributor = new Element( "creator", NS_DC );
+ item.addContent( contributor );
/*
- XML description = new XML("rdf:Description");
- if( m_wikiContext.getEngine().pageExists(author) )
- {
- description.addAttribute( "link", engine.getURL( WikiContext.VIEW,
- author,
- null,
- true ) );
+ Element description = new Element("Description", NS_RDF);
+ if( m_wikiContext.getEngine().pageExists(author) ) {
+ description.setAttribute( "link", engine.getURL( WikiContext.VIEW, author, null, true ), NS_XMNLS );
}
- description.addElement( new XML("value").addElement( format(author) ) );
- contributor.addElement( description );
+ description.addContent( new Element("value", NS_XMNLS).addContent( author) );
+ contributor.addContent( description );
*/
- // Not too many aggregators seem to like this. Therefore we're
- // just adding the name here.
-
- contributor.addElement(format(author));
+ // Not too many aggregators seem to like this. Therefore we're just adding the name here.
+ contributor.addContent( author );
+ //
// PageHistory
+ item.addContent( new Element( "history", NS_WIKI )
+ .addContent( engine.getURL( WikiContext.INFO, p.getName(), null, true ) ) );
- item.addElement(new XML("wiki:history").addElement(engine.getURL(WikiContext.INFO,
- p.getName(),
- null,
- true)));
-
- //
- // Add to root
//
-
- root.addElement(item);
+ // Add to root
+ root.addContent( item );
}
}
- private XML getChannelElement() {
- XML channel = new XML("channel");
-
- channel.addAttribute("rdf:about", m_feedURL);
+ private Element getChannelElement() {
+ Element channel = new Element( "channel", NS_XMNLS );
+ channel.setAttribute( "about", m_feedURL, NS_RDF )
+ .addContent( new Element( "link", NS_XMNLS ).addContent( m_feedURL ) );
- channel.addElement(new XML("link").addElement(m_feedURL));
-
- if (m_channelTitle != null) {
- channel.addElement(new XML("title").addElement(format(m_channelTitle)));
+ if( m_channelTitle != null ) {
+ channel.addContent( new Element( "title", NS_XMNLS ).addContent( m_channelTitle ) );
}
- if (m_channelDescription != null) {
- channel.addElement(new XML("description").addElement(format(m_channelDescription)));
+ if( m_channelDescription != null ) {
+ channel.addContent( new Element( "description", NS_XMNLS ).addContent( m_channelDescription ) );
}
- if (m_channelLanguage != null) {
- channel.addElement(new XML("dc:language").addElement(m_channelLanguage));
+ if( m_channelLanguage != null ) {
+ channel.addContent( new Element( "language", NS_DC ).addContent( m_channelLanguage ) );
}
-
- channel.setPrettyPrint(true);
-
- channel.addElement(getRDFItems());
+ channel.addContent( getRDFItems() );
return channel;
}
@@ -186,20 +161,15 @@ public class RSS10Feed extends Feed {
*/
@Override
public String getString() {
- XML root = new XML("rdf:RDF");
-
- root.addAttribute("xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
- root.addAttribute("xmlns", "http://purl.org/rss/1.0/");
- root.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
- root.addAttribute("xmlns:wiki", "http://purl.org/rss/1.0/modules/wiki/");
-
- root.addElement(getChannelElement());
-
- addItemList(root);
-
- root.setPrettyPrint(true);
+ Element root = new Element( "RDF", NS_RDF );
+ root.addContent( getChannelElement() );
+ root.addNamespaceDeclaration( NS_XMNLS );
+ root.addNamespaceDeclaration( NS_RDF );
+ root.addNamespaceDeclaration( NS_DC );
+ root.addNamespaceDeclaration( NS_WIKI );
+ addItemList( root );
- return root.toString();
+ return XhtmlUtil.serialize( root, true );
}
}
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java?rev=1567452&r1=1567451&r2=1567452&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java Tue Feb 11 23:13:58 2014
@@ -19,89 +19,86 @@
package org.apache.wiki.ui.admin.beans;
import java.util.Collection;
-import java.util.Iterator;
import javax.management.NotCompliantMBeanException;
-import org.apache.ecs.xhtml.*;
+import org.apache.commons.lang.StringUtils;
import org.apache.wiki.Release;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.api.engine.PluginManager;
import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo;
import org.apache.wiki.ui.admin.SimpleAdminBean;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+import org.jdom2.output.Format;
-public class PluginBean extends SimpleAdminBean
-{
+public class PluginBean extends SimpleAdminBean {
+
private WikiEngine m_engine;
+
+ private static final String VER_WARNING = "<span class='warning'>This module is not compatible with this version of JSPWiki.</span>";
+
+ /** to print <td></td> instead of <td /> */
+ private static final Format EXPAND_EMPTY_NODES = Format.getCompactFormat().setExpandEmptyElements( true );
- public PluginBean(WikiEngine engine) throws NotCompliantMBeanException
- {
+ public PluginBean( WikiEngine engine ) throws NotCompliantMBeanException {
m_engine = engine;
}
- public String[] getAttributeNames()
- {
+ public String[] getAttributeNames() {
return new String[0];
}
- public String[] getMethodNames()
- {
+ public String[] getMethodNames() {
return new String[0];
}
- public String getTitle()
- {
+ public String getTitle() {
return "Plugins";
}
- public int getType()
- {
+ public int getType() {
return CORE;
}
@SuppressWarnings("unchecked")
- public String doGet(WikiContext context)
- {
+ public String doGet(WikiContext context) {
PluginManager pm = m_engine.getPluginManager();
- Collection<WikiPluginInfo> plugins = pm.modules();
-
- div root = new div();
-
- root.addElement( new h4("Plugins") );
-
- table tb = new table().setBorder(1);
- root.addElement(tb);
-
- tr head = new tr();
- head.addElement( new th("Name") );
- head.addElement( new th("Alias") );
- head.addElement( new th("Author") );
- head.addElement( new th("Notes") );
-
- tb.addElement(head);
-
- for( Iterator<WikiPluginInfo> i = plugins.iterator(); i.hasNext(); )
- {
- tr row = new tr();
- tb.addElement( row );
-
- WikiPluginInfo info = i.next();
-
- row.addElement( new td(info.getName()) );
- row.addElement( new td(info.getAlias()) );
- row.addElement( new td(info.getAuthor()) );
-
- String verWarning = "";
- if( !(Release.isNewerOrEqual(info.getMinVersion()) && Release.isOlderOrEqual(info.getMaxVersion())) )
- {
- verWarning = "<span class='warning'>This module is not compatible with this version of JSPWiki.</span>";
- }
-
- row.addElement( new td(verWarning) );
+ Collection< WikiPluginInfo > plugins = pm.modules();
+
+ Element root = XhtmlUtil.element( XHTML.div );
+ Element tb = XhtmlUtil.element( XHTML.table ).setAttribute( "border", "1" );
+
+ root.addContent( XhtmlUtil.element( XHTML.h4 ).addContent( "Plugins") )
+ .addContent( tb );
+
+ Element trHead = XhtmlUtil.element( XHTML.tr );
+ trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) )
+ .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Alias" ) )
+ .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Author" ) )
+ .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Notes" ) );
+
+ tb.addContent( trHead );
+
+ for( WikiPluginInfo info : plugins ) {
+ Element tr = XhtmlUtil.element( XHTML.tr );
+ tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getName() ) )
+ .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAlias() ) )
+ .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAuthor() ) )
+ .addContent( XhtmlUtil.element( XHTML.td ).addContent( validPluginVersion( info ) ) );
+
+ tb.addContent( tr );
}
- return root.toString();
+ return XhtmlUtil.serialize( root, EXPAND_EMPTY_NODES );
+ }
+
+ String validPluginVersion( WikiPluginInfo info ) {
+ return Release.isNewerOrEqual( info.getMinVersion() ) && Release.isOlderOrEqual( info.getMaxVersion() )
+ ? StringUtils.EMPTY
+ : VER_WARNING;
}
}
Added: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XHTML.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XHTML.java?rev=1567452&view=auto
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XHTML.java (added)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/XHTML.java Tue Feb 11 23:13:58 2014
@@ -0,0 +1,214 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.wiki.util;
+
+/**
+ * Provides constants for the Extensible HyperText Markup Language (XHTML) 1.0.
+ *
+ * @since 2.10
+ */
+public enum XHTML
+{
+ // XHTML element type names ...........................................
+
+ a, abbr, acronym, address, applet, area,
+ b, base, basefont, bdo, big, blockquote, body, br, button,
+ caption, center, cite, code, col, colgroup,
+ dd, del, dfn, dir, div, dl, dt,
+ em,
+ fieldset, font, form, frame, frameset,
+ h1, h2, h3, h4, h5, h6, head, hr, html,
+ i, iframe, img, input, ins, isindex,
+ kbd,
+ label,
+ legend, li, link,
+ map, menu, meta,
+ noframes, noscript,
+ object, ol, optgroup, option,
+ p, param, pre,
+ q,
+ s, samp, script, select, small, span, strike, strong, style, sub, sup,
+ table, tbody, td, textarea, tfoot, th, thead, title, tr, tt,
+ u, ul,
+ var;
+
+
+ /**
+ * Returns the element type name (AKA generic identifier).
+ * This is a convenience method that returns the same value
+ * as <tt>XHTML.<GI>>.name();</tt>.
+ */
+ public String getName()
+ {
+ return this.name();
+ }
+
+
+ // XML Public and Namespace identifiers for XHTML .........................
+
+ /** XML Namespace URI for the Extensible HyperText Markup Language (XHTML). */
+ public static final String XMLNS_xhtml = "http://www.w3.org/1999/xhtml";
+
+ /** A String containing the Formal Public Identifier (FPI) for the XHTML 1.0 Strict DTD. */
+ public static final String STRICT_DTD_PubId = "-//W3C//DTD XHTML 1.0 Strict//EN";
+ /** A String containing a system identifier for the XHTML 1.0 Strict DTD. */
+ public static String STRICT_DTD_SysId = "xhtml1-strict.dtd";
+
+ /** A String containing the Formal Public Identifier (FPI) for the XHTML 1.0 Transitional DTD. */
+ public static final String TRANSITIONAL_DTD_PubId = "-//W3C//DTD XHTML 1.0 Transitional//EN";
+ /** A String containing a system identifier for the XHTML 1.0 Transitional DTD. */
+ public static String TRANSITIONAL_DTD_SysId = "xhtml1-transitional.dtd";
+
+ /** A String containing the Formal Public Identifier (FPI) for the XHTML 1.0 Frameset DTD. */
+ public static final String FRAMESET_DTD_PubId = "-//W3C//DTD XHTML 1.0 Frameset//EN";
+ /** A String containing a system identifier for the XHTML 1.0 Frameset DTD. */
+ public static String FRAMESET_DTD_SysId = "xhtml1-frameset.dtd";
+
+ // CSS strings ........................................................
+
+ /** An identifier for the CSS stylesheet notation using its W3C home page URI. */
+ public static final String CSS_style = "http://www.w3.org/Style/CSS/";
+
+
+ // XHTML common attribute names .......................................
+
+ /** String containing the XHTML 'id' attribute name (i.e., 'id'). */
+ public static final String ATTR_id = "id";
+
+ /** String containing the XHTML 'class' attribute name (i.e., 'class'). */
+ public static final String ATTR_class = "class";
+
+ /** String containing the XHTML 'name' attribute name (i.e., 'name'). */
+ public static final String ATTR_name = "name";
+
+ /** String containing the XHTML 'type' attribute name (i.e., 'type'). */
+ public static final String ATTR_type = "type";
+
+ /** String containing the XHTML 'value' attribute name (i.e., 'value'). */
+ public static final String ATTR_value = "value";
+
+ /** String containing the XHTML 'href' attribute name (i.e., 'href'). */
+ public static final String ATTR_href = "href";
+
+ /** String containing the XHTML 'title' attribute name (i.e., 'title'). */
+ public static final String ATTR_title = "title";
+
+ /** String containing the XHTML 'width' attribute name (i.e., 'width'). */
+ public static final String ATTR_width = "width";
+
+ /** String containing the XHTML 'height' attribute name (i.e., 'height'). */
+ public static final String ATTR_height = "height";
+
+ /** String containing the XHTML 'border' attribute name (i.e., 'border'). */
+ public static final String ATTR_border = "border";
+
+ /** String containing the XHTML 'colspan' attribute name (i.e., 'colspan'). */
+ public static final String ATTR_colspan = "colspan";
+
+ /** String containing the XHTML 'src' attribute name (i.e., 'src'). */
+ public static final String ATTR_src = "src";
+
+ /** String containing the XHTML 'alt' attribute name (i.e., 'alt'). */
+ public static final String ATTR_alt = "alt";
+
+ // okay, maybe not so common
+
+ /** String containing the XHTML 'bgcolor' attribute name (i.e., 'bgcolor'). */
+ public static final String ATTR_bgcolor = "bgcolor";
+
+ /** String containing the XHTML 'checked' attribute name (i.e., 'checked'). */
+ public static final String ATTR_checked = "checked";
+
+ /** String containing the XHTML 'cols' attribute name (i.e., 'cols'). */
+ public static final String ATTR_cols = "cols";
+
+ /** String containing the XHTML 'content' attribute name (i.e., 'content'). */
+ public static final String ATTR_content = "content";
+
+ /** String containing the XHTML 'http-equiv' attribute name (i.e., 'http-equiv'). */
+ public static final String ATTR_httpEquiv = "http-equiv";
+
+ /** String containing the XHTML 'scheme' attribute name (i.e., 'scheme'). */
+ public static final String ATTR_scheme = "scheme";
+
+ /** String containing the XHTML 'rel' attribute name (i.e., 'rel'). */
+ public static final String ATTR_rel = "rel";
+
+ /** String containing the XHTML 'rows' attribute name (i.e., 'rows'). */
+ public static final String ATTR_rows = "rows";
+
+ /** String containing the XHTML 'selected' attribute name (i.e., 'selected'). */
+ public static final String ATTR_selected = "selected";
+
+ /** String containing the XHTML 'size' attribute name (i.e., 'size'). */
+ public static final String ATTR_size = "size";
+
+ /** String containing the XHTML 'style' attribute name (i.e., 'style'). */
+ public static final String ATTR_style = "style";
+
+ /** String containing the XHTML 'align' attribute name (i.e., 'align'). */
+ public static final String ATTR_align = "align";
+
+ /** String containing the XHTML 'cellpadding' attribute name (i.e., 'cellpadding'). */
+ public static final String ATTR_cellpadding = "cellpadding";
+
+ /** String containing the XHTML 'cellspacing' attribute name (i.e., 'cellspacing'). */
+ public static final String ATTR_cellspacing = "cellspacing";
+
+ // XHTML character entities ...........................................
+
+ /**
+ * Returns a String containing the named character entity corresponding to
+ * the character number <tt>num</tt> for the range 160-255. Throws an
+ * ArrayOutOfBoundsException if beyond the prescribed range.
+ */
+ public static String getNamedCharacterEntity( int num )
+ {
+ return CHARACTER_ENTITIES[num-160];
+ }
+
+ /* Conversion table for the XHTML upper ASCII character entities (character numbers 160-255). */
+ private static final String[] CHARACTER_ENTITIES = {
+ "nbsp" /* 160 */, "iexcl" /* 161 */, "cent" /* 162 */, "pound" /* 163 */,
+ "curren" /* 164 */, "yen" /* 165 */, "brvbar" /* 166 */, "sect" /* 167 */,
+ "uml" /* 168 */, "copy" /* 169 */, "ordf" /* 170 */, "laquo" /* 171 */,
+ "not" /* 172 */, "shy" /* 173 */, "reg" /* 174 */, "macr" /* 175 */,
+ "deg" /* 176 */, "plusmn" /* 177 */, "sup2" /* 178 */, "sup3" /* 179 */,
+ "acute" /* 180 */, "micro" /* 181 */, "para" /* 182 */, "middot" /* 183 */,
+ "cedil" /* 184 */, "sup1" /* 185 */, "ordm" /* 186 */, "raquo" /* 187 */,
+ "frac14" /* 188 */, "frac12" /* 189 */, "frac34" /* 190 */, "iquest" /* 191 */,
+ "Agrave" /* 192 */, "Aacute" /* 193 */, "Acirc" /* 194 */, "Atilde" /* 195 */,
+ "Auml" /* 196 */, "Aring" /* 197 */, "AElig" /* 198 */, "Ccedil" /* 199 */,
+ "Egrave" /* 200 */, "Eacute" /* 201 */, "Ecirc" /* 202 */, "Euml" /* 203 */,
+ "Igrave" /* 204 */, "Iacute" /* 205 */, "Icirc" /* 206 */, "Iuml" /* 207 */,
+ "ETH" /* 208 */, "Ntilde" /* 209 */, "Ograve" /* 210 */, "Oacute" /* 211 */,
+ "Ocirc" /* 212 */, "Otilde" /* 213 */, "Ouml" /* 214 */, "times" /* 215 */,
+ "Oslash" /* 216 */, "Ugrave" /* 217 */, "Uacute" /* 218 */, "Ucirc" /* 219 */,
+ "Uuml" /* 220 */, "Yacute" /* 221 */, "THORN" /* 222 */, "szlig" /* 223 */,
+ "agrave" /* 224 */, "aacute" /* 225 */, "acirc" /* 226 */, "atilde" /* 227 */,
+ "auml" /* 228 */, "aring" /* 229 */, "aelig" /* 230 */, "ccedil" /* 231 */,
+ "egrave" /* 232 */, "eacute" /* 233 */, "ecirc" /* 234 */, "euml" /* 235 */,
+ "igrave" /* 236 */, "iacute" /* 237 */, "icirc" /* 238 */, "iuml" /* 239 */,
+ "eth" /* 240 */, "ntilde" /* 241 */, "ograve" /* 242 */, "oacute" /* 243 */,
+ "ocirc" /* 244 */, "otilde" /* 245 */, "ouml" /* 246 */, "divide" /* 247 */,
+ "oslash" /* 248 */, "ugrave" /* 249 */, "uacute" /* 250 */, "ucirc" /* 251 */,
+ "uuml" /* 252 */, "yacute" /* 253 */, "thorn" /* 254 */, "yuml" /* 255 */ };
+
+} // end org.apache.wiki.util.XHTML