diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8aa49b2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+/bin/
+/target/
+/.settings/
+/.classpath
+/.project
diff --git a/main/trunk/BOILER b/BOILER
similarity index 100%
rename from main/trunk/BOILER
rename to BOILER
diff --git a/main/trunk/Changes.txt b/Changes.txt
similarity index 100%
rename from main/trunk/Changes.txt
rename to Changes.txt
diff --git a/main/trunk/LICENSE b/LICENSE
similarity index 100%
rename from main/trunk/LICENSE
rename to LICENSE
diff --git a/main/trunk/NOTICE b/NOTICE
similarity index 100%
rename from main/trunk/NOTICE
rename to NOTICE
diff --git a/main/trunk/README b/README
similarity index 100%
rename from main/trunk/README
rename to README
diff --git a/main/trunk/Radeox.version b/Radeox.version
similarity index 100%
rename from main/trunk/Radeox.version
rename to Radeox.version
diff --git a/main/trunk/build.xml b/main/trunk/build.xml
deleted file mode 100644
index 2d2776f..0000000
--- a/main/trunk/build.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Radeox]]>
-
- Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its Fraunhofer Institute Computer Architecture and Software Technology (FIRST), Berlin, Germany ]]>
-
-
-
diff --git a/main/trunk/lib/asm-util.jar b/main/trunk/lib/asm-util.jar
deleted file mode 100644
index 8611740..0000000
Binary files a/main/trunk/lib/asm-util.jar and /dev/null differ
diff --git a/main/trunk/lib/asm.jar b/main/trunk/lib/asm.jar
deleted file mode 100644
index 6048fb2..0000000
Binary files a/main/trunk/lib/asm.jar and /dev/null differ
diff --git a/main/trunk/lib/clover.jar b/main/trunk/lib/clover.jar
deleted file mode 100755
index 7ea02cb..0000000
Binary files a/main/trunk/lib/clover.jar and /dev/null differ
diff --git a/main/trunk/lib/commons-logging.jar b/main/trunk/lib/commons-logging.jar
deleted file mode 100644
index b99c937..0000000
Binary files a/main/trunk/lib/commons-logging.jar and /dev/null differ
diff --git a/main/trunk/lib/groovy.jar b/main/trunk/lib/groovy.jar
deleted file mode 100644
index bec7d12..0000000
Binary files a/main/trunk/lib/groovy.jar and /dev/null differ
diff --git a/main/trunk/lib/jakarta-oro.jar b/main/trunk/lib/jakarta-oro.jar
deleted file mode 100644
index ed6c60a..0000000
Binary files a/main/trunk/lib/jakarta-oro.jar and /dev/null differ
diff --git a/main/trunk/lib/jmock.jar b/main/trunk/lib/jmock.jar
deleted file mode 100644
index b1c077c..0000000
Binary files a/main/trunk/lib/jmock.jar and /dev/null differ
diff --git a/main/trunk/lib/junit.jar b/main/trunk/lib/junit.jar
deleted file mode 100755
index 674d71e..0000000
Binary files a/main/trunk/lib/junit.jar and /dev/null differ
diff --git a/main/trunk/lib/junitperf.jar b/main/trunk/lib/junitperf.jar
deleted file mode 100644
index 2d6f3a9..0000000
Binary files a/main/trunk/lib/junitperf.jar and /dev/null differ
diff --git a/main/trunk/lib/picocontainer.jar b/main/trunk/lib/picocontainer.jar
deleted file mode 100644
index 09e378a..0000000
Binary files a/main/trunk/lib/picocontainer.jar and /dev/null differ
diff --git a/main/trunk/src/java/META-INF/manifest.radeox b/main/trunk/src/java/META-INF/manifest.radeox
deleted file mode 100644
index 8bceef8..0000000
--- a/main/trunk/src/java/META-INF/manifest.radeox
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: org.radeox.example.InteractiveExample
-Class-Path: jakarta-oro.jar commons-logging.jar picocontainer.jar
diff --git a/main/trunk/src/java/META-INF/manifest.radeox-api b/main/trunk/src/java/META-INF/manifest.radeox-api
deleted file mode 100644
index e69de29..0000000
diff --git a/main/trunk/src/java/org/radeox/EngineManager.java b/main/trunk/src/java/org/radeox/EngineManager.java
deleted file mode 100644
index 3327139..0000000
--- a/main/trunk/src/java/org/radeox/EngineManager.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.engine.BaseRenderEngine;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.util.Service;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Acess point to dock several different rendering engines into
- * e.g. SnipSnap.
- *
- * SHOULD BE REMOVED.
- * If this functionality is needed, it will be replaced by PicoContainer, Spring, ...
- * (but kept for compatibility)
- *
- *
- * @author Stephan J. Schmidt
- * @version $Id: EngineManager.java,v 1.15 2004/05/26 08:56:20 stephan Exp $
- */
-
-public class EngineManager {
- private static Log log = LogFactory.getLog(EngineManager.class);
-
- public static final String DEFAULT = "radeox";
- private static Map availableEngines = new HashMap();
-
-
- static {
- Iterator iterator = Service.providers(RenderEngine.class);
- while (iterator.hasNext()) {
- try {
- RenderEngine engine = (RenderEngine) iterator.next();
- registerEngine(engine);
- log.debug("Loaded RenderEngine: " + engine.getClass().getName());
- } catch (Exception e) {
- log.warn("EngineManager: unable to load RenderEngine", e);
- }
- }
- }
-
- /**
- * Different RenderEngines can register themselves with the
- * EngineManager factory to be available with EngineManager.getInstance();
- *
- * @param engine RenderEngine instance, e.g. SnipRenderEngine
- */
- public static synchronized void registerEngine(RenderEngine engine) {
- if (null == availableEngines) {
- availableEngines = new HashMap();
- }
- availableEngines.put(engine.getName(), engine);
- }
-
- /**
- * Get an instance of a RenderEngine. This is a factory method.
- *
- * @param name Name of the RenderEngine to get
- * @return engine RenderEngine for the requested name
- */
- public static synchronized RenderEngine getInstance(String name) {
- if (null == availableEngines) {
- availableEngines = new HashMap();
- }
-
- //Logger.debug("Engines: " + availableEngines);
- return (RenderEngine) availableEngines.get(name);
- }
-
- /**
- * Get an instance of a RenderEngine. This is a factory method.
- * Defaults to a default RenderEngine. Currently this is a
- * basic EngineManager with no additional features that is
- * distributed with Radeox.
- *
- * @return engine default RenderEngine
- */
- public static synchronized RenderEngine getInstance() {
- //availableEngines = null;
- if (null == availableEngines) {
- availableEngines = new HashMap();
- }
-
- if (!availableEngines.containsKey(DEFAULT)) {
- RenderEngine engine = new BaseRenderEngine();
- availableEngines.put(engine.getName(), engine);
- }
-
- return (RenderEngine) availableEngines.get(DEFAULT);
- }
-
- public static String getVersion() {
- return "0.5.1";
- }
-}
diff --git a/main/trunk/src/java/org/radeox/api/engine/context/InitialRenderContext.java b/main/trunk/src/java/org/radeox/api/engine/context/InitialRenderContext.java
deleted file mode 100644
index d4a647d..0000000
--- a/main/trunk/src/java/org/radeox/api/engine/context/InitialRenderContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.api.engine.context;
-
-import org.radeox.filter.FilterPipe;
-
-
-/**
- * IntialRenderContext tells a Filter how to behave at initializiation.
- * For example the Filter can read pattern locales for it's pattern
- * matching.
- *
- * @author Stephan J. Schmidt
- * @version $Id: InitialRenderContext.java,v 1.1 2003/10/07 08:20:24 stephan Exp $
- */
-
-public interface InitialRenderContext extends RenderContext {
- public final static String FILTER_PIPE = "InitialRenderContext.filter_pipe";
-
- public void setFilterPipe(FilterPipe fp);
- public FilterPipe getFilterPipe();
-}
diff --git a/main/trunk/src/java/org/radeox/api/engine/context/RenderContext.java b/main/trunk/src/java/org/radeox/api/engine/context/RenderContext.java
deleted file mode 100644
index 7a4385c..0000000
--- a/main/trunk/src/java/org/radeox/api/engine/context/RenderContext.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.api.engine.context;
-
-import org.radeox.api.engine.RenderEngine;
-
-import java.util.Map;
-
-
-/**
- * RenderContext stores basic data for the context
- * the RenderEngine is called in. RenderContext
- * can be used by the Engine in whatever way it likes to.
- * The Radeox RenderEngine uses RenderContext to
- * construct FilterContext.
- *
- * @author Stephan J. Schmidt
- * @version $Id: RenderContext.java,v 1.2 2004/01/30 08:42:56 stephan Exp $
- */
-
-public interface RenderContext {
- public final static String INPUT_BUNDLE_NAME = "RenderContext.input_bundle_name";
- public final static String OUTPUT_BUNDLE_NAME = "RenderContext.output_bundle_name";
- public final static String LANGUAGE_BUNDLE_NAME = "RenderContext.language_bundle_name";
- public final static String LANGUAGE_LOCALE = "RenderContext.language_locale";
- public final static String INPUT_LOCALE = "RenderContext.input_locale";
- public final static String OUTPUT_LOCALE = "RenderContext.output_locale";
- public final static String DEFAULT_FORMATTER = "RenderContext.default_formatter";
-
- /**
- * Returns the RenderEngine handling this request.
- *
- * @return engine RenderEngine handling the request within this context
- */
- public RenderEngine getRenderEngine();
-
- /**
- * Stores the current RenderEngine of the request
- *
- * @param engine Current RenderEnginge
- */
- public void setRenderEngine(RenderEngine engine);
-
- public Object get(String key);
-
- public void set(String key, Object value);
-
- public Map getParameters();
-
- /**
- * Set the parameters for this execution context. These
- * parameters are read when encountering a variable in
- * macros like {search:$query} or by ParamFilter in {$query}.
- * Query is then read from
- * the parameter map before given to the macro
- *
- * @param parameters Map of parameters with name,value pairs
- */
- public void setParameters(Map parameters);
-
- public void setCacheable(boolean cacheable);
-
- public void commitCache();
-
- public boolean isCacheable();
-}
diff --git a/main/trunk/src/java/org/radeox/engine/BaseRenderEngine.java b/main/trunk/src/java/org/radeox/engine/BaseRenderEngine.java
deleted file mode 100644
index f8f40c1..0000000
--- a/main/trunk/src/java/org/radeox/engine/BaseRenderEngine.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.engine;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.engine.context.BaseInitialRenderContext;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.filter.Filter;
-import org.radeox.filter.FilterPipe;
-import org.radeox.filter.context.BaseFilterContext;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.util.Service;
-
-import java.io.*;
-import java.util.Iterator;
-
-/**
- * Base implementation of RenderEngine
- *
- * @author Stephan J. Schmidt
- * @version $Id: BaseRenderEngine.java,v 1.18 2004/05/26 08:56:20 stephan Exp $
- */
-
-public class BaseRenderEngine implements RenderEngine {
- public static final String NAME = "radeox";
-
- private static Log log = LogFactory.getLog(BaseRenderEngine.class);
-
- protected InitialRenderContext initialContext;
- protected FilterPipe fp;
-
- public BaseRenderEngine(InitialRenderContext context) {
- this.initialContext = context;
- init();
- initialContext.setFilterPipe(fp);
- }
-
- public BaseRenderEngine() {
- this(new BaseInitialRenderContext());
- }
-
- public InitialRenderContext getInitialRenderContext() {
- return initialContext;
- }
-
- protected void init() {
- if (null == fp) {
- fp = new FilterPipe(initialContext);
-
- Iterator iterator = Service.providers(Filter.class);
- while (iterator.hasNext()) {
- try {
- Filter filter = (Filter) iterator.next();
- fp.addFilter(filter);
- log.debug("Loaded filter: " + filter.getClass().getName());
- } catch (Exception e) {
- log.warn("BaseRenderEngine: unable to load filter", e);
- }
- }
-
- fp.init();
- //Logger.debug("FilterPipe = "+fp.toString());
- }
- }
-
- /**
- * Name of the RenderEngine. This is used to get a RenderEngine instance
- * with EngineManager.getInstance(name);
- *
- * @return name Name of the engine
- */
- public String getName() {
- return NAME;
- }
-
- /**
- * Render an input with text markup and return a String with
- * e.g. HTML
- *
- * @param content String with the input to render
- * @param context Special context for the filter engine, e.g. with
- * configuration information
- * @return result Output with rendered content
- */
- public String render(String content, RenderContext context) {
- init();
- FilterContext filterContext = new BaseFilterContext();
- filterContext.setRenderContext(context);
- return fp.filter(content, filterContext);
- }
-
- /**
- * Render an input with text markup from a Reader and write the result to a writer
- *
- * @param in Reader to read the input from
- * @param context Special context for the render engine, e.g. with
- * configuration information
- */
- public String render(Reader in, RenderContext context) throws IOException {
- StringBuffer buffer = new StringBuffer();
- BufferedReader inputReader = new BufferedReader(in);
- String line;
- while ((line = inputReader.readLine()) != null) {
- buffer.append(line);
- }
- return render(buffer.toString(), context);
- }
-
- public void render(Writer out, String content, RenderContext context) throws IOException {
- out.write(render(content, context));
- }
-}
diff --git a/main/trunk/src/java/org/radeox/engine/context/BaseInitialRenderContext.java b/main/trunk/src/java/org/radeox/engine/context/BaseInitialRenderContext.java
deleted file mode 100644
index 4dfa231..0000000
--- a/main/trunk/src/java/org/radeox/engine/context/BaseInitialRenderContext.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.engine.context;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.util.i18n.ResourceManager;
-import org.radeox.filter.FilterPipe;
-
-import java.util.Locale;
-
-/**
- * Base impementation for InitialRenderContext
- *
- * @author Stephan J. Schmidt
- * @version $Id: BaseInitialRenderContext.java,v 1.6 2004/04/27 19:30:38 leo Exp $
- */
-
-public class BaseInitialRenderContext extends BaseRenderContext implements InitialRenderContext {
-
- public BaseInitialRenderContext() {
- Locale locale = new Locale("Basic", "basic");
- set(RenderContext.INPUT_LOCALE, locale);
- set(RenderContext.OUTPUT_LOCALE, locale);
- set(RenderContext.INPUT_BUNDLE_NAME, "radeox_markup");
- set(RenderContext.OUTPUT_BUNDLE_NAME, "radeox_markup");
- set(RenderContext.LANGUAGE_BUNDLE_NAME, "radeox_messages");
-
- Locale languageLocale = Locale.getDefault();
- set(RenderContext.LANGUAGE_LOCALE, languageLocale);
- ResourceManager.get().setLocale(languageLocale, null);
-
- set(RenderContext.DEFAULT_FORMATTER, "java");
- }
-
- public void setFilterPipe(FilterPipe fp) {
- set(InitialRenderContext.FILTER_PIPE, fp);
- }
-
- public FilterPipe getFilterPipe() {
- return (FilterPipe) get(InitialRenderContext.FILTER_PIPE);
- }
-
-}
diff --git a/main/trunk/src/java/org/radeox/engine/context/BaseRenderContext.java b/main/trunk/src/java/org/radeox/engine/context/BaseRenderContext.java
deleted file mode 100644
index 2f52045..0000000
--- a/main/trunk/src/java/org/radeox/engine/context/BaseRenderContext.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.engine.context;
-
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.context.RenderContext;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * Base impementation for RenderContext
- *
- * @author Stephan J. Schmidt
- * @version $Id: BaseRenderContext.java,v 1.8 2003/10/07 08:20:24 stephan Exp $
- */
-
-public class BaseRenderContext implements RenderContext {
- private boolean cacheable = true;
- private boolean tempCacheable = false;;
-
- private RenderEngine engine;
- private Map params;
- private Map values;
-
- public BaseRenderContext() {
- values = new HashMap();
- }
-
- public Object get(String key) {
- return values.get(key);
- }
-
- public void set(String key, Object value) {
- values.put(key, value);
- }
-
- public Map getParameters() {
- return params;
- }
-
- public void setParameters(Map parameters) {
- this.params = parameters;
- }
-
- public RenderEngine getRenderEngine() {
- return engine;
- }
-
- public void setRenderEngine(RenderEngine engine) {
- this.engine = engine;
- }
-
- public void setCacheable(boolean cacheable) {
- tempCacheable = cacheable;
- }
-
- public void commitCache() {
- cacheable = cacheable && tempCacheable;
- tempCacheable = false;
- }
-
- public boolean isCacheable() {
- return cacheable;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/example/InteractiveExample.java b/main/trunk/src/java/org/radeox/example/InteractiveExample.java
deleted file mode 100644
index ff57a28..0000000
--- a/main/trunk/src/java/org/radeox/example/InteractiveExample.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.example;
-
-import org.radeox.engine.context.BaseRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.engine.BaseRenderEngine;
-import org.radeox.api.engine.RenderEngine;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.Date;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-/*
- * Interactive example how to use EngineManager
- *
- * @author Stephan J. Schmidt
- * @version $Id: InteractiveExample.java,v 1.8 2004/05/26 08:56:20 stephan Exp $
- */
-
-public class InteractiveExample {
- private static DateFormat perfFormat = new SimpleDateFormat("m'm's's'S'ms'");
-
- public static void main(String[] args) {
- System.err.println("Radeox");
- System.err.println("Copyright 2001-2004 Fraunhofer FIRST.");
- System.err.println("See License Agreement for terms and conditions of use.");
-
- RenderEngine engine = new BaseRenderEngine();
- RenderContext context = new BaseRenderContext();
-
- if(args.length > 0) {
- File inputFile = new File(args[0]);
- if(inputFile.exists()) {
- batch(engine, context, inputFile);
- } else {
- System.err.println("The file '"+args[0]+"' does not exist.");
- }
- } else {
- interactive(engine, context);
- }
-
- }
-
- private static void batch(RenderEngine engine, RenderContext context, File inputFile) {
- StringBuffer input = new StringBuffer();
- try {
- BufferedReader reader = new BufferedReader(new FileReader(inputFile));
- char buffer[] = new char[4096];
- int length = 0;
- while((length = reader.read(buffer)) != -1) {
- input.append(buffer, 0, length);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
- render(engine, context, input.toString());
- }
-
- private static void interactive(RenderEngine engine, RenderContext context) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String line;
- try {
- System.out.print("> ");
- System.out.flush();
- while ((line = reader.readLine()) != null) {
- render(engine, context, line);
- System.out.print("> ");
- System.out.flush();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private static void render(RenderEngine engine,RenderContext context, String input) {
- long start = System.currentTimeMillis();
- String result = engine.render(input, context);
- long length = System.currentTimeMillis() - start;
- System.out.println(result);
- System.out.println("rendered in "+perfFormat.format(new Date(length)));
- }
-}
diff --git a/main/trunk/src/java/org/radeox/example/PicoExample.java b/main/trunk/src/java/org/radeox/example/PicoExample.java
deleted file mode 100644
index a2c5514..0000000
--- a/main/trunk/src/java/org/radeox/example/PicoExample.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.example;
-
-import org.picocontainer.PicoContainer;
-import org.picocontainer.defaults.DefaultPicoContainer;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.engine.BaseRenderEngine;
-import org.radeox.engine.context.BaseInitialRenderContext;
-import org.radeox.engine.context.BaseRenderContext;
-
-import java.util.Locale;
-
-/*
- * Example how to use BaseRenderEngine with Pico
- *
- * @author Stephan J. Schmidt
- * @version $Id: PicoExample.java,v 1.3 2003/12/16 10:26:51 leo Exp $
- */
-
-public class PicoExample {
- public static void main(String[] args) {
- String test = "==SnipSnap== {link:Radeox|http://radeox.org}";
-
- DefaultPicoContainer c = new org.picocontainer.defaults.DefaultPicoContainer();
- try {
- InitialRenderContext initialContext = new BaseInitialRenderContext();
- initialContext.set(RenderContext.INPUT_LOCALE, new Locale("otherwiki", ""));
- c.registerComponentInstance(InitialRenderContext.class, initialContext);
- c.registerComponentImplementation(RenderEngine.class, BaseRenderEngine.class);
- c.getComponentInstances();
- } catch (Exception e) {
- System.err.println("Could not register component: "+e);
- }
-
- PicoContainer container = c;
-
- // no only work with container
-
- // Only ask for RenderEngine, we automatically get an object
- // that implements RenderEngine
- RenderEngine engine = (RenderEngine) container.getComponentInstance(RenderEngine.class);
- RenderContext context = new BaseRenderContext();
- System.out.println(engine.render(test, context));
- }
-}
diff --git a/main/trunk/src/java/org/radeox/filter/FilterPipe.java b/main/trunk/src/java/org/radeox/filter/FilterPipe.java
deleted file mode 100644
index 2f3d289..0000000
--- a/main/trunk/src/java/org/radeox/filter/FilterPipe.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.engine.context.BaseInitialRenderContext;
-import org.radeox.filter.context.FilterContext;
-
-import java.util.*;
-
-/*
- * FilterPipe is a collection of Filters which are
- * applied one by one to an input to generate output
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: FilterPipe.java,v 1.21 2004/06/21 13:08:43 leo Exp $
- */
-
-public class FilterPipe {
- private static Log log = LogFactory.getLog(FilterPipe.class);
-
- public final static String FIRST_IN_PIPE = "all";
- public final static String LAST_IN_PIPE = "none";
- public final static String[] EMPTY_BEFORE = new String[]{};
- public final static String[] NO_REPLACES = new String[]{};
- public final static String[] FIRST_BEFORE = new String[]{FIRST_IN_PIPE};
-
- private InitialRenderContext initialContext;
-
- private List activeFilters = null;
- private Set inactiveFilters = null;
-
- public FilterPipe() {
- this(new BaseInitialRenderContext());
- }
-
- public FilterPipe(InitialRenderContext context) {
- activeFilters = new ArrayList();
- inactiveFilters = new HashSet();
- initialContext = context;
- }
-
- public void init() {
- Iterator iterator = new ArrayList(activeFilters).iterator();
- while (iterator.hasNext()) {
- Filter filter = (Filter) iterator.next();
- String[] replaces = filter.replaces();
- for (int i = 0; i < replaces.length; i++) {
- String replace = replaces[i];
- removeFilter(replace);
- }
- }
- }
-
- public void removeFilter(String filterClass) {
- Iterator iterator = activeFilters.iterator();
- while (iterator.hasNext()) {
- Filter filter = (Filter) iterator.next();
- if (filter.getClass().getName().equals(filterClass)) {
- iterator.remove();
- }
- }
- }
-
- public void activateFilter(String name) {
- synchronized(inactiveFilters) {
- Iterator iterator = inactiveFilters.iterator();
- while (iterator.hasNext()) {
- Filter filter = (Filter) iterator.next();
- if (filter.getClass().getName().startsWith(name)) {
- inactiveFilters.remove(filter);
- }
- }
- }
- }
-
- public void deactivateFilter(String name) {
- Iterator iterator = activeFilters.iterator();
- while (iterator.hasNext()) {
- Filter filter = (Filter) iterator.next();
- if (filter.getClass().getName().startsWith(name)) {
- inactiveFilters.add(filter);
- }
- }
- }
-
- public List getAllFilters() {
- return new ArrayList(activeFilters);
- }
-
- public List getInactiveFilters() {
- return new ArrayList(inactiveFilters);
- }
-
-
- /**
- * Add a filter to the active pipe
- *
- * @param filter Filter to add
- */
- public void addFilter(Filter filter) {
- filter.setInitialContext(initialContext);
-
- int minIndex = Integer.MAX_VALUE;
- String[] before = filter.before();
- for (int i = 0; i < before.length; i++) {
- String s = before[i];
- int index = index(activeFilters, s);
- if (index < minIndex) {
- minIndex = index;
- }
- }
- if (minIndex == Integer.MAX_VALUE) {
- // -1 is more usable for not-found than MAX_VALUE
- minIndex = -1;
- }
-
- if (contains(filter.before(), FIRST_IN_PIPE)) {
- activeFilters.add(0, filter);
- } else if (minIndex != -1) {
- activeFilters.add(minIndex, filter);
- } else {
- activeFilters.add(filter);
- }
- }
-
- public int index(String filterName) {
- return FilterPipe.index(activeFilters, filterName);
- }
-
- public static int index(List list, final String filterName) {
- for (int i = 0; i < list.size(); i++) {
- if (filterName.equals(list.get(i).getClass().getName())) {
- return i;
- }
- }
- return -1;
- }
-
- public static boolean contains(Object[] array, Object value) {
- return (Arrays.binarySearch(array, value) != -1);
- }
-
- /**
- * Filter some input and generate ouput. FilterPipe pipes the
- * string input through every filter in the pipe and returns
- * the resulting string.
- *
- * @param input Input string which should be transformed
- * @param context FilterContext with information about the enviroment
- * @return result Filtered output
- */
- public String filter(String input, FilterContext context) {
- //Logger.debug("FilterPipe.filter: context = "+context);
- String output = input;
- Iterator filterIterator = activeFilters.iterator();
- RenderContext renderContext = context.getRenderContext();
-
- // Apply every filter in activeFilters to input string
- while (filterIterator.hasNext()) {
- Filter f = (Filter) filterIterator.next();
- if (! inactiveFilters.contains(f)) {
- try {
- // assume all filters non cacheable
- if (f instanceof CacheFilter) {
- renderContext.setCacheable(true);
- } else {
- renderContext.setCacheable(false);
- }
- String tmp = f.filter(output, context);
- if (output.equals(tmp)) {
- renderContext.setCacheable(true);
- }
- if (null == tmp) {
- log.warn("FilterPipe.filter: error while filtering: " + f);
- } else {
- output = tmp;
- }
- renderContext.commitCache();
- } catch (Exception e) {
- log.warn("Filtering exception: " + f, e);
- }
- }
- }
- return output;
- }
-
- public Filter getFilter(int index) {
- return (Filter) activeFilters.get(index);
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/filter/LinkTestFilter.java b/main/trunk/src/java/org/radeox/filter/LinkTestFilter.java
deleted file mode 100644
index 23f1ca0..0000000
--- a/main/trunk/src/java/org/radeox/filter/LinkTestFilter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.WikiRenderEngine;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.filter.interwiki.InterWiki;
-import org.radeox.filter.regex.LocaleRegexTokenFilter;
-import org.radeox.regex.MatchResult;
-import org.radeox.util.Encoder;
-import org.radeox.util.StringBufferWriter;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * LinkTestFilter finds [text] in its input and transforms this
- * to ... if the wiki page exists. If not
- * it adds a [create text] to the output.
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: LinkTestFilter.java,v 1.15 2004/04/15 13:56:14 stephan Exp $
- */
-
-public class LinkTestFilter extends LocaleRegexTokenFilter {
- private static Log log = LogFactory.getLog(LinkTestFilter.class);
-
-
- /**
- * The regular expression for detecting WikiLinks.
- * Overwrite in subclass to support other link styles like
- * OldAndUglyWikiLinking :-)
- *
");
- } catch (IOException e) {
- // Do nothing. Give up.
- }
- return;
- }
-
- // trim the name and unescape it
- name = Encoder.unescape(name.trim());
-
- // Is there an alias like [alias|link] ?
- int pipeIndex = name.indexOf('|');
- String alias = "";
- if (-1 != pipeIndex) {
- if (null == getModifier()) {
- alias = name.substring(0, pipeIndex);
- name = name.substring(pipeIndex + 1);
- } else {
- alias = name.substring(pipeIndex + 1);
- name = name.substring(0, pipeIndex);
- }
- }
-
- int hashIndex = name.lastIndexOf('#');
-
- String hash = "";
- if (-1 != hashIndex && hashIndex != name.length() - 1) {
- hash = name.substring(hashIndex + 1);
- name = name.substring(0, hashIndex);
- }
-
- int colonIndex = name.indexOf(':');
- // typed link ?
- if (-1 != colonIndex) {
- // for now throw away the type information
- name = name.substring(colonIndex + 1);
- }
-
- int atIndex = name.lastIndexOf('@');
- // InterWiki link ?
- if (-1 != atIndex) {
- String extSpace = name.substring(atIndex + 1);
- // known extarnal space ?
- InterWiki interWiki = InterWiki.getInstance();
- if (interWiki.contains(extSpace)) {
- String view = name;
- if (-1 != pipeIndex) {
- view = alias;
- }
-
- name = name.substring(0, atIndex);
- try {
- if (-1 != hashIndex) {
- interWiki.expand(writer, extSpace, name, view, hash);
- } else {
- interWiki.expand(writer, extSpace, name, view);
- }
- } catch (IOException e) {
- log.debug("InterWiki " + extSpace + " not found.");
- }
- } else {
- buffer.append("[");
- buffer.append(result.group(1));
- buffer.append("?]");
- }
- } else {
- // internal link
-
- if (wikiEngine.exists(name)) {
- String view = getWikiView(name);
- if (-1 != pipeIndex) {
- view = alias;
- }
- // Do not add hash if an alias was given
- if (-1 != hashIndex) {
- wikiEngine.appendLink(buffer, name, view, hash);
- } else {
- wikiEngine.appendLink(buffer, name, view);
- }
- } else if (wikiEngine.showCreate()) {
- wikiEngine.appendCreateLink(buffer, name, getWikiView(name));
- // links with "create" are not cacheable because
- // a missing wiki could be created
- context.getRenderContext().setCacheable(false);
- } else {
- // cannot display/create wiki, so just display the text
- buffer.append(name);
- }
- }
- } else {
- buffer.append(Encoder.escape(result.group(0)));
- }
- }
- }
-
- /**
- * Returns the view of the wiki name that is shown to the
- * user. Overwrite to support other views for example
- * transform "WikiLinking" to "Wiki Linking".
- * Does nothing by default.
- *
- * @return view The view of the wiki name
- */
-
- protected String getWikiView(String name) {
- return name;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/filter/ListFilter.java b/main/trunk/src/java/org/radeox/filter/ListFilter.java
deleted file mode 100644
index cdeb91c..0000000
--- a/main/trunk/src/java/org/radeox/filter/ListFilter.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.filter.regex.LocaleRegexTokenFilter;
-import org.radeox.regex.MatchResult;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
-
-/*
- * Listfilter checks for lists in in its input. These are
- * transformed to output lists, e.g. in HTML. Recognices
- * different lists like numbered lists, unnumbered lists,
- * greek lists, alpha lists etc.
- *
- * @credits nested list support by Davor Cubranic
- * @author stephan
- * @team sonicteam
- * @version $Id: ListFilter.java,v 1.17 2004/04/15 13:56:14 stephan Exp $
- */
-
-public class ListFilter extends LocaleRegexTokenFilter implements CacheFilter {
- private static Log log = LogFactory.getLog(ListFilter.class);
-
- private final static Map openList = new HashMap();
- private final static Map closeList = new HashMap();
-
- private static final String UL_CLOSE = "";
- private static final String OL_CLOSE = "";
-
- protected String getLocaleKey() {
- return "filter.list";
- }
-
- protected boolean isSingleLine() {
- return false;
- }
-
- public ListFilter() {
- super();
- openList.put(new Character('-'), "
");
- openList.put(new Character('*'), "
");
- openList.put(new Character('#'), "");
- openList.put(new Character('i'), "");
- openList.put(new Character('I'), "");
- openList.put(new Character('a'), "");
- openList.put(new Character('A'), "");
- openList.put(new Character('g'), "");
- openList.put(new Character('h'), "");
- openList.put(new Character('H'), "");
- openList.put(new Character('k'), "");
- openList.put(new Character('K'), "");
- openList.put(new Character('j'), "");
- openList.put(new Character('1'), "");
- closeList.put(new Character('-'), UL_CLOSE);
- closeList.put(new Character('*'), UL_CLOSE);
- closeList.put(new Character('#'), OL_CLOSE);
- closeList.put(new Character('i'), OL_CLOSE);
- closeList.put(new Character('I'), OL_CLOSE);
- closeList.put(new Character('a'), OL_CLOSE);
- closeList.put(new Character('A'), OL_CLOSE);
- closeList.put(new Character('1'), OL_CLOSE);
- closeList.put(new Character('g'), OL_CLOSE);
- closeList.put(new Character('G'), OL_CLOSE);
- closeList.put(new Character('h'), OL_CLOSE);
- closeList.put(new Character('H'), OL_CLOSE);
- closeList.put(new Character('k'), OL_CLOSE);
- closeList.put(new Character('K'), OL_CLOSE);
- closeList.put(new Character('j'), OL_CLOSE);
- };
-
- public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context) {
- try {
- BufferedReader reader = new BufferedReader(new StringReader(result.group(0)));
- //System.err.println("match="+result.group(0));
- addList(buffer, reader);
- } catch (Exception e) {
- log.warn("ListFilter: unable get list content", e);
- }
- }
-
- /**
- * Adds a list to a buffer
- *
- * @param buffer The buffer to write to
- * @param reader Input is read from this Reader
- */
- private void addList(StringBuffer buffer, BufferedReader reader) throws IOException {
- char[] lastBullet = new char[0];
- String line = null;
- while ((line = reader.readLine()) != null) {
- // no nested list handling, trim lines:
- line = line.trim();
- if (line.length() == 0) {
- continue;
- }
-
- int bulletEnd = line.indexOf(' ');
- if (bulletEnd < 1) {
- continue;
- }
- if ( line.charAt(bulletEnd - 1) == '.') {
- bulletEnd--;
- }
- char[] bullet = line.substring(0, bulletEnd).toCharArray();
- // Logger.log("found bullet: ('" + new String(lastBullet) + "') '" + new String(bullet) + "'");
- // check whether we find a new list
- int sharedPrefixEnd;
- for (sharedPrefixEnd = 0; ; sharedPrefixEnd++) {
- if (bullet.length <= sharedPrefixEnd || lastBullet.length <= sharedPrefixEnd ||
- +bullet[sharedPrefixEnd] != lastBullet[sharedPrefixEnd]) {
- break;
- }
- }
-
- for (int i = sharedPrefixEnd; i < lastBullet.length; i++) {
- //Logger.log("closing " + lastBullet[i]);
- buffer.append(closeList.get(new Character(lastBullet[i]))).append("\n");
- }
-
- for (int i = sharedPrefixEnd; i < bullet.length; i++) {
- //Logger.log("opening " + bullet[i]);
- buffer.append(openList.get(new Character(bullet[i]))).append("\n");
- }
- buffer.append("
\n");
- lastBullet = bullet;
- }
-
- for (int i = lastBullet.length - 1; i >= 0; i--) {
- //Logger.log("closing " + lastBullet[i]);
- buffer.append(closeList.get(new Character(lastBullet[i])));
- }
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/filter/MacroFilter.java b/main/trunk/src/java/org/radeox/filter/MacroFilter.java
deleted file mode 100644
index 9dbd271..0000000
--- a/main/trunk/src/java/org/radeox/filter/MacroFilter.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.api.engine.IncludeRenderEngine;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.filter.regex.RegexTokenFilter;
-import org.radeox.regex.MatchResult;
-import org.radeox.macro.Macro;
-import org.radeox.macro.MacroRepository;
-import org.radeox.macro.Repository;
-import org.radeox.macro.parameter.MacroParameter;
-import org.radeox.util.StringBufferWriter;
-
-import java.io.Writer;
-
-/*
- * Class that finds snippets (macros) like
- * {link:neotis|http://www.neotis.de} ---> " + command + ": " + e.getMessage() + "");
- } catch (Throwable e) {
- log.warn("MacroFilter: unable to format macro: " + result.group(1), e);
- buffer.append("
");
- return;
- }
- } else {
- buffer.append("<");
- buffer.append(command.substring(1));
- buffer.append(">");
- }
- } else {
- buffer.append(result.group(0));
- }
- }
-}
diff --git a/main/trunk/src/java/org/radeox/filter/ParamFilter.java b/main/trunk/src/java/org/radeox/filter/ParamFilter.java
deleted file mode 100644
index 85f718e..0000000
--- a/main/trunk/src/java/org/radeox/filter/ParamFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import org.radeox.filter.context.FilterContext;
-import org.radeox.filter.regex.LocaleRegexTokenFilter;
-import org.radeox.regex.MatchResult;
-
-import java.util.Map;
-
-/*
- * ParamFilter replaces parametes from from the MacroFilter in the input.
- * These parameters could be read from an HTTP request and put in
- * MacroFilter.
- * A parameter is replaced in {$paramName}
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: ParamFilter.java,v 1.7 2004/04/15 13:56:14 stephan Exp $
- */
-
-public class ParamFilter extends LocaleRegexTokenFilter {
- public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context) {
- Map param = context.getRenderContext().getParameters();
-
- String name = result.group(1);
- if (param.containsKey(name)) {
- Object value = param.get(name);
- if (value instanceof String[]) {
- buffer.append(((String[]) value)[0]);
- } else {
- buffer.append(value);
- }
- } else {
- buffer.append("<");
- buffer.append(name);
- buffer.append(">");
- }
- }
-
- protected String getLocaleKey() {
- return "filter.param";
- }
-
- protected boolean isSingleLine() {
- return true;
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/filter/interwiki/InterWiki.java b/main/trunk/src/java/org/radeox/filter/interwiki/InterWiki.java
deleted file mode 100644
index d6811a3..0000000
--- a/main/trunk/src/java/org/radeox/filter/interwiki/InterWiki.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.interwiki;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.util.Encoder;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Stores information and links to other wikis forming a
- * InterWiki
- *
- * @author Stephan J. Schmidt
- * @version $Id: InterWiki.java,v 1.6 2004/01/19 11:45:24 stephan Exp $
- */
-
-public class InterWiki {
- private static Log log = LogFactory.getLog(InterWiki.class);
-
- private static InterWiki instance;
- private Map interWiki;
-
- public static synchronized InterWiki getInstance() {
- if (null == instance) {
- instance = new InterWiki();
- }
- return instance;
- }
-
- public InterWiki(InputStream in) {
- try {
- init(in);
- } catch (IOException e) {
- log.warn("Unable to initialize from stream.", e);
- }
- }
-
- public InterWiki() {
- try {
- init(new FileInputStream("conf/intermap.txt"));
- } catch (IOException e) {
- log.warn("Unable to read conf/intermap.txt", e);
- }
- }
-
- public void init(InputStream in ) throws IOException {
- interWiki = new HashMap();
- interWiki.put("LCOM", "http://www.langreiter.com/space/");
- interWiki.put("ESA", "http://earl.strain.at/space/");
- interWiki.put("C2", "http://www.c2.com/cgi/wiki?");
- interWiki.put("WeblogKitchen", "http://www.weblogkitchen.com/wiki.cgi?");
- interWiki.put("Meatball", "http://www.usemod.com/cgi-bin/mb.pl?");
- interWiki.put("SnipSnap", "http://snipsnap.org/space/");
-
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
- String line;
- while ((line = reader.readLine()) != null) {
- int index = line.indexOf(" ");
- interWiki.put(line.substring(0, index), Encoder.escape(line.substring(index + 1)));
- }
- }
-
- public Writer appendTo(Writer writer) throws IOException {
- Iterator iterator = interWiki.entrySet().iterator();
- writer.write("{table}\n");
- writer.write("Wiki|Url\n");
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- writer.write((String) entry.getKey());
- writer.write("|");
- writer.write((String) entry.getValue());
- writer.write("\n");
- }
- writer.write("{table}");
- return writer;
- }
-
- public boolean contains(String external) {
- return interWiki.containsKey(external);
- }
-
- public String getWikiUrl(String wiki, String name) {
- return ((String) interWiki.get(wiki)) + name;
- }
-
- public Writer expand(Writer writer, String wiki, String name, String view, String anchor) throws IOException {
- writer.write("");
- writer.write(view);
- writer.write("");
- return writer;
- }
-
- public Writer expand(Writer writer, String wiki, String name, String view) throws IOException {
- return expand(writer, wiki, name, view, "");
- }
-}
diff --git a/main/trunk/src/java/org/radeox/filter/regex/LocaleRegexReplaceFilter.java b/main/trunk/src/java/org/radeox/filter/regex/LocaleRegexReplaceFilter.java
deleted file mode 100644
index be1c227..0000000
--- a/main/trunk/src/java/org/radeox/filter/regex/LocaleRegexReplaceFilter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.regex;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/*
- * Class that extends RegexReplaceFilter but reads patterns from
- * a locale file instead of hardwired regex
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: LocaleRegexReplaceFilter.java,v 1.6 2003/10/07 08:20:24 stephan Exp $
- */
-
-public abstract class LocaleRegexReplaceFilter extends RegexReplaceFilter {
- private String modifier = null;
-
- protected abstract String getLocaleKey();
-
- public void setModifier(String modifier) {
- this.modifier = modifier;
- }
-
- public String getModifier() {
- return modifier;
- }
-
- protected boolean isSingleLine() {
- return false;
- }
-
- protected ResourceBundle getInputBundle() {
- Locale inputLocale = (Locale) initialContext.get(RenderContext.INPUT_LOCALE);
- String inputName = (String) initialContext.get(RenderContext.INPUT_BUNDLE_NAME);
- return ResourceBundle.getBundle(inputName, inputLocale);
- }
-
- protected ResourceBundle getOutputBundle() {
- String outputName = (String) initialContext.get(RenderContext.OUTPUT_BUNDLE_NAME);
- Locale outputLocale = (Locale) initialContext.get(RenderContext.OUTPUT_LOCALE);
- return ResourceBundle.getBundle(outputName, outputLocale);
- }
-
- public void setInitialContext(InitialRenderContext context) {
- super.setInitialContext(context);
- clearRegex();
-
- ResourceBundle outputMessages = getOutputBundle();
- ResourceBundle inputMessages = getInputBundle();
-
- String match = inputMessages.getString(getLocaleKey() + (modifier != null ? "." + modifier : "") + ".match");
- String print = outputMessages.getString(getLocaleKey() + (modifier != null ? "." + modifier : "") + ".print");
- //System.err.println(getLocaleKey()+": match="+match+" pattern="+print);
- addRegex(match, print, isSingleLine() ? RegexReplaceFilter.SINGLELINE : RegexReplaceFilter.MULTILINE);
- }
-
- private String getKeyModifier() {
- return modifier;
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/filter/regex/LocaleRegexTokenFilter.java b/main/trunk/src/java/org/radeox/filter/regex/LocaleRegexTokenFilter.java
deleted file mode 100644
index 67090d4..0000000
--- a/main/trunk/src/java/org/radeox/filter/regex/LocaleRegexTokenFilter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.regex;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/*
- * Filter that extends RegexTokenFilter but reads regular expressions from
- * a locale
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: LocaleRegexTokenFilter.java,v 1.5 2003/10/07 08:20:24 stephan Exp $
- */
-
-public abstract class LocaleRegexTokenFilter extends RegexTokenFilter {
- protected ResourceBundle inputMessages;
- protected ResourceBundle outputMessages;
- private String modifier;
-
- public void setModifier(String modifier) {
- this.modifier = modifier;
- }
-
- public String getModifier() {
- return modifier;
- }
-
- protected boolean isSingleLine() {
- return false;
- }
-
- protected ResourceBundle getInputBundle() {
- Locale inputLocale = (Locale) initialContext.get(RenderContext.INPUT_LOCALE);
- String inputName = (String) initialContext.get(RenderContext.INPUT_BUNDLE_NAME);
- return ResourceBundle.getBundle(inputName, inputLocale);
- }
-
- protected ResourceBundle getOutputBundle() {
- Locale outputLocale = (Locale) initialContext.get(RenderContext.OUTPUT_LOCALE);
- String outputName = (String) initialContext.get(RenderContext.OUTPUT_BUNDLE_NAME);
- return ResourceBundle.getBundle(outputName, outputLocale);
- }
-
- public void setInitialContext(InitialRenderContext context) {
- super.setInitialContext(context);
- clearRegex();
-
- outputMessages = getOutputBundle();
- inputMessages = getInputBundle();
- String match = inputMessages.getString(getLocaleKey() + (modifier != null ? "." + modifier : "") + ".match");
- addRegex(match, "", isSingleLine() ? RegexReplaceFilter.SINGLELINE : RegexReplaceFilter.MULTILINE);
- }
-
- protected abstract String getLocaleKey();
-}
diff --git a/main/trunk/src/java/org/radeox/filter/regex/RegexFilter.java b/main/trunk/src/java/org/radeox/filter/regex/RegexFilter.java
deleted file mode 100644
index 8107df9..0000000
--- a/main/trunk/src/java/org/radeox/filter/regex/RegexFilter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.regex;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.filter.FilterSupport;
-import org.radeox.filter.context.FilterContext;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/*
- * Class that stores regular expressions, can be subclassed
- * for special Filters
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: RegexFilter.java,v 1.11 2004/04/15 13:56:14 stephan Exp $
- */
-
-public abstract class RegexFilter extends FilterSupport {
- private static Log log = LogFactory.getLog(RegexFilter.class);
-
- protected List pattern = new ArrayList();
- protected List substitute = new ArrayList();
-
- public final static boolean SINGLELINE = false;
- public final static boolean MULTILINE = true;
-
- // TODO future use
- //private RegexService regexService;
-
- public RegexFilter() {
- super();
- }
-
- /**
- * create a new regular expression that takes input as multiple lines
- */
- public RegexFilter(String regex, String substitute) {
- this();
- addRegex(regex, substitute);
- }
-
- /**
- * create a new regular expression and set
- */
- public RegexFilter(String regex, String substitute, boolean multiline) {
- addRegex(regex, substitute, multiline);
- }
-
- public void clearRegex() {
- pattern.clear();
- substitute.clear();
- }
- public void addRegex(String regex, String substitute) {
- addRegex(regex, substitute, MULTILINE);
- }
-
- public void addRegex(String regex, String substitute, boolean multiline) {
- // compiler.compile(regex, (multiline ? Perl5Compiler.MULTILINE_MASK : Perl5Compiler.SINGLELINE_MASK) | Perl5Compiler.READ_ONLY_MASK));
- try {
- org.radeox.regex.Compiler compiler = org.radeox.regex.Compiler.create();
- compiler.setMultiline(multiline);
- this.pattern.add(compiler.compile(regex));
- // Pattern.DOTALL
- this.substitute.add(substitute);
- } catch (Exception e) {
- log.warn("bad pattern: " + regex + " -> " + substitute+" "+e);
- }
- }
-
- public abstract String filter(String input, FilterContext context);
-}
diff --git a/main/trunk/src/java/org/radeox/filter/regex/RegexReplaceFilter.java b/main/trunk/src/java/org/radeox/filter/regex/RegexReplaceFilter.java
deleted file mode 100644
index bd2ce4b..0000000
--- a/main/trunk/src/java/org/radeox/filter/regex/RegexReplaceFilter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.regex;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.regex.Pattern;
-import org.radeox.regex.Matcher;
-
-
-/*
- * Class that applies a RegexFilter, can be subclassed
- * for special Filters. Regular expressions in the input
- * are replaced with strings.
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: RegexReplaceFilter.java,v 1.8 2004/04/15 13:56:14 stephan Exp $
- */
-
-public class RegexReplaceFilter extends RegexFilter {
- private static Log log = LogFactory.getLog(RegexReplaceFilter.class);
-
- public RegexReplaceFilter() {
- super();
- }
-
- public RegexReplaceFilter(String regex, String substitute) {
- super(regex, substitute);
- }
-
- public RegexReplaceFilter(String regex, String substitute, boolean multiline) {
- super(regex, substitute, multiline);
- }
-
- public String filter(String input, FilterContext context) {
- String result = input;
- int size = pattern.size();
- Pattern p;
- String s;
- for (int i = 0; i < size; i++) {
- p = (Pattern) pattern.get(i);
- s = (String) substitute.get(i);
- try {
- Matcher matcher = Matcher.create(result, p);
- result = matcher.substitute(s);
-
- // Util.substitute(matcher, p, new Perl5Substitution(s, interps), result, limit);
- } catch (Exception e) {
- //log.warn("Exception: " + this + ": " + e);
- log.warn("Exception for: " + this+" "+e);
- } catch (Error err) {
- //log.warn("Error: " + this + ": " + err);
- log.warn("Error for: " + this);
- err.printStackTrace();
- }
- }
- return result;
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/filter/regex/RegexTokenFilter.java b/main/trunk/src/java/org/radeox/filter/regex/RegexTokenFilter.java
deleted file mode 100644
index de624f8..0000000
--- a/main/trunk/src/java/org/radeox/filter/regex/RegexTokenFilter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.regex;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.regex.Pattern;
-import org.radeox.regex.Matcher;
-import org.radeox.regex.MatchResult;
-import org.radeox.regex.Substitution;
-
-/*
- * Filter that calls a special handler method handleMatch() for
- * every occurance of a regular expression.
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: RegexTokenFilter.java,v 1.11 2004/04/16 07:47:41 stephan Exp $
- */
-
-public abstract class RegexTokenFilter extends RegexFilter {
-
- private static Log log = LogFactory.getLog(RegexTokenFilter.class);
-
- public RegexTokenFilter() {
- super();
- }
-
- /**
- * create a new regular expression and set
- */
- public RegexTokenFilter(String regex, boolean multiline) {
- super(regex, "", multiline);
- }
-
- /**
- * create a new regular expression and set
- */
- public RegexTokenFilter(String regex) {
- super(regex, "");
- }
-
- protected void setUp(FilterContext context) {
- }
-
- /**
- * Method is called for every occurance of a regular expression.
- * Subclasses have to implement this mehtod.
- *
- * @param buffer Buffer to write replacement string to
- * @param result Hit with the found regualr expression
- * @param context FilterContext for filters
- */
- public abstract void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context);
-
- public String filter(String input, final FilterContext context) {
- setUp(context);
-
- String result = null;
- int size = pattern.size();
- for (int i = 0; i < size; i++) {
- Pattern p = (Pattern) pattern.get(i);
- try {
- Matcher m = Matcher.create(input, p);
- result = m.substitute(new Substitution() {
- public void handleMatch(StringBuffer buffer, MatchResult result) {
- RegexTokenFilter.this.handleMatch(buffer, result, context);
- }
- });
-
- // result = Util.substitute(matcher, p, new ActionSubstitution(s, this, context), result, limit);
- } catch (Exception e) {
- log.warn("Exception: " + this, e);
- } catch (Error err) {
- log.warn("Error: " + this + ": " + err);
- err.printStackTrace();
- }
- input = result;
- }
- return input;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/ApiMacro.java b/main/trunk/src/java/org/radeox/macro/ApiMacro.java
deleted file mode 100644
index 595d5b9..0000000
--- a/main/trunk/src/java/org/radeox/macro/ApiMacro.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.macro.api.ApiDoc;
-import org.radeox.macro.parameter.MacroParameter;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Macro that replaces {api} with external URLS to api
- * documentation
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: ApiMacro.java,v 1.6 2004/04/27 19:30:38 leo Exp $
- */
-
-public class ApiMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.api";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
- String mode;
- String klass;
-
- if (params.getLength() == 1) {
- klass = params.get("0");
- int index = klass.indexOf("@");
- if (index > 0) {
- mode = klass.substring(index + 1);
- klass = klass.substring(0, index);
- } else {
- mode = "java";
- }
- } else if (params.getLength() == 2) {
- mode = params.get("1").toLowerCase();
- klass = params.get("0");
- } else {
- throw new IllegalArgumentException("api macro needs one or two paramaters");
- }
-
- ApiDoc.getInstance().expand(writer, klass, mode);
- return;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/BaseLocaleMacro.java b/main/trunk/src/java/org/radeox/macro/BaseLocaleMacro.java
deleted file mode 100644
index 39bf6bd..0000000
--- a/main/trunk/src/java/org/radeox/macro/BaseLocaleMacro.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.util.i18n.ResourceManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/*
- * Class that implements base functionality to write macros
- * and reads it's name from a locale file
- *
- * @author stephan
- * @version $Id: BaseLocaleMacro.java,v 1.6 2004/04/27 19:30:38 leo Exp $
- */
-
-public abstract class BaseLocaleMacro extends BaseMacro implements LocaleMacro {
- private static Log log = LogFactory.getLog(BaseLocaleMacro.class);
-
- private String name;
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- try {
- return ResourceManager.getBundle((String)initialContext.get(RenderContext.LANGUAGE_BUNDLE_NAME))
- .getString(getLocaleKey()+".description");
- } catch (Exception e) {
- log.warn("missing macro description for "+getLocaleKey());
- return super.getDescription();
- }
- }
-
- public String[] getParamDescription() {
- try {
- return ResourceManager.getBundle((String) initialContext.get(RenderContext.LANGUAGE_BUNDLE_NAME))
- .getString(getLocaleKey() + ".params").split(";");
- } catch (Exception e) {
- return super.getParamDescription();
- }
- }
-
- public void setInitialContext(InitialRenderContext context) {
- super.setInitialContext(context);
- Locale inputLocale = (Locale) context.get(RenderContext.INPUT_LOCALE);
- String inputName = (String) context.get(RenderContext.INPUT_BUNDLE_NAME);
- ResourceBundle inputMessages = ResourceBundle.getBundle(inputName, inputLocale);
-
- name = inputMessages.getString(getLocaleKey()+".name");
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/macro/BaseMacro.java b/main/trunk/src/java/org/radeox/macro/BaseMacro.java
deleted file mode 100644
index 4a03345..0000000
--- a/main/trunk/src/java/org/radeox/macro/BaseMacro.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.macro.parameter.MacroParameter;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Class that implements base functionality to write macros
- *
- * @author stephan
- * @version $Id: BaseMacro.java,v 1.3 2004/04/27 19:30:38 leo Exp $
- */
-
-public abstract class BaseMacro implements Macro {
- protected InitialRenderContext initialContext;
-
- protected String description = " ";
- protected String[] paramDescription = {};
-
- /**
- * Get the name of the macro. This is used to map a macro
- * in the input to the macro which should be called.
- * The method has to be implemented by subclassing classes.
- *
- * @return name Name of the Macro
- */
- public abstract String getName();
-
- /**
- * Get a description of the macro. This description explains
- * in a short way what the macro does
- *
- * @return description A string describing the macro
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Get a description of the paramters of the macro. The method
- * returns an array with an String entry for every parameter.
- * The format is {"1: description", ...} where 1 is the position
- * of the parameter.
- *
- * @return description Array describing the parameters of the macro
- */
- public String[] getParamDescription() {
- return paramDescription;
- }
-
- public void setInitialContext(InitialRenderContext context) {
- this.initialContext = context;
- }
-
- /**
- * Execute the macro. This method is called by MacroFilter to
- * handle macros.
- *
- * @param writer A write where the macro should write its output to
- * @param params Macro parameters with the parameters the macro is called with
- */
- public abstract void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException;
-
- public String toString() {
- return getName();
- }
-
- public int compareTo(Object object) {
- Macro macro = (Macro) object;
- return getName().compareTo(macro.getName());
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/CodeMacro.java b/main/trunk/src/java/org/radeox/macro/CodeMacro.java
deleted file mode 100644
index 29f3f0c..0000000
--- a/main/trunk/src/java/org/radeox/macro/CodeMacro.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.filter.context.BaseFilterContext;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.macro.code.SourceCodeFormatter;
-import org.radeox.macro.parameter.MacroParameter;
-import org.radeox.util.Service;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.*;
-
-/*
- * Macro for displaying programming language source code. CodeMacro knows about
- * different source code formatters which can be plugged into radeox to
- * display more languages. CodeMacro displays Java, Ruby or SQL code.
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: CodeMacro.java,v 1.16 2004/04/27 19:30:38 leo Exp $
- */
-
-public class CodeMacro extends LocalePreserved {
- private static Log log = LogFactory.getLog(CodeMacro.class);
-
- private Map formatters;
- private FilterContext nullContext = new BaseFilterContext();
-
- private String start;
- private String end;
-
- public String getLocaleKey() {
- return "macro.code";
- }
-
- public void setInitialContext(InitialRenderContext context) {
- super.setInitialContext(context);
- Locale outputLocale = (Locale) context.get(RenderContext.OUTPUT_LOCALE);
- String outputName = (String) context.get(RenderContext.OUTPUT_BUNDLE_NAME);
- ResourceBundle outputMessages = ResourceBundle.getBundle(outputName, outputLocale);
-
- start = outputMessages.getString(getLocaleKey() + ".start");
- end = outputMessages.getString(getLocaleKey() + ".end");
- }
-
- public CodeMacro() {
- formatters = new HashMap();
-
- Iterator formatterIt = Service.providers(SourceCodeFormatter.class);
- while (formatterIt.hasNext()) {
- try {
- SourceCodeFormatter formatter = (SourceCodeFormatter) formatterIt.next();
- String name = formatter.getName();
- if (formatters.containsKey(name)) {
- SourceCodeFormatter existing = (SourceCodeFormatter) formatters.get(name);
- if (existing.getPriority() < formatter.getPriority()) {
- formatters.put(name, formatter);
- log.debug("Replacing formatter: " + formatter.getClass() + " (" + name + ")");
- }
- } else {
- formatters.put(name, formatter);
- log.debug("Loaded formatter: " + formatter.getClass() + " (" + name +")");
- }
- } catch (Exception e) {
- log.warn("CodeMacro: unable to load code formatter", e);
- }
- }
-
- addSpecial('[');
- addSpecial(']');
- addSpecial('{');
- addSpecial('}');
- addSpecial('*');
- addSpecial('-');
- addSpecial('#');
- addSpecial('\\');
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
-
- SourceCodeFormatter formatter = null;
-
- if (params.getLength() == 0 || !formatters.containsKey(params.get("0"))) {
- formatter = (SourceCodeFormatter) formatters.get(initialContext.get(RenderContext.DEFAULT_FORMATTER));
- if (null == formatter) {
- log.warn("Formatter not found.");
- formatter = (SourceCodeFormatter) formatters.get("java");
- }
- } else {
- formatter = (SourceCodeFormatter) formatters.get(params.get("0"));
- }
-
- String result = formatter.filter(params.getContent(), nullContext);
-
- writer.write(start);
- writer.write(replace(result.trim()));
- writer.write(end);
- return;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/LinkMacro.java b/main/trunk/src/java/org/radeox/macro/LinkMacro.java
deleted file mode 100644
index 8d2b4a3..0000000
--- a/main/trunk/src/java/org/radeox/macro/LinkMacro.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.api.engine.ImageRenderEngine;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.macro.parameter.MacroParameter;
-import org.radeox.util.Encoder;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Macro for displaying external links with a name. The normal UrlFilter
- * takes the url as a name.
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: LinkMacro.java,v 1.17 2004/05/03 11:12:37 stephan Exp $
- */
-
-public class LinkMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.link";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
-
- RenderContext context = params.getContext();
- RenderEngine engine = context.getRenderEngine();
-
- String text = params.get("text", 0);
- String url = params.get("url", 1);
- String img = params.get("img", 2);
-
- // check for single url argument (text == url)
- if(params.getLength() == 1) {
- url = text;
- text = Encoder.toEntity(text.charAt(0)) + Encoder.escape(text.substring(1));
- }
-
- if (url != null && text != null) {
- writer.write("");
- if (!"none".equals(img) && engine instanceof ImageRenderEngine) {
- writer.write(((ImageRenderEngine) engine).getExternalImageLink());
- }
- writer.write("");
- writer.write(text);
- writer.write("");
- } else {
- throw new IllegalArgumentException("link needs a name and a url as argument: txt="+text+" url="+url);
- }
- return;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/LocalePreserved.java b/main/trunk/src/java/org/radeox/macro/LocalePreserved.java
deleted file mode 100644
index 5292c92..0000000
--- a/main/trunk/src/java/org/radeox/macro/LocalePreserved.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.radeox.macro;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.util.i18n.ResourceManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.
- */
-
-
-public abstract class LocalePreserved extends Preserved implements LocaleMacro {
- private static Log log = LogFactory.getLog(LocalePreserved.class);
-
- private String name;
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- try {
- return ResourceManager.getBundle((String) initialContext.get(RenderContext.LANGUAGE_BUNDLE_NAME))
- .getString(getLocaleKey() + ".description");
- } catch (Exception e) {
- log.warn("missing macro description for " + getLocaleKey());
- return super.getDescription();
- }
- }
-
- public String[] getParamDescription() {
- try {
- return ResourceManager.getBundle((String) initialContext.get(RenderContext.LANGUAGE_BUNDLE_NAME))
- .getString(getLocaleKey() + ".params").split(";");
- } catch (Exception e) {
- return super.getParamDescription();
- }
- }
-
- public void setInitialContext(InitialRenderContext context) {
- super.setInitialContext(context);
- Locale languageLocale = (Locale) context.get(RenderContext.LANGUAGE_LOCALE);
- String languageName = (String) context.get(RenderContext.LANGUAGE_BUNDLE_NAME);
- ResourceBundle messages = ResourceBundle.getBundle(languageName, languageLocale);
-
- Locale inputLocale = (Locale) context.get(RenderContext.INPUT_LOCALE);
- String inputName = (String) context.get(RenderContext.INPUT_BUNDLE_NAME);
- ResourceBundle inputMessages = ResourceBundle.getBundle(inputName, inputLocale);
-
- name = inputMessages.getString(getLocaleKey() + ".name");
-
- try {
- description = messages.getString(getLocaleKey() + ".description");
- } catch (Exception e) {
- log.warn("Cannot read description from properties " + inputName + " for " + getLocaleKey());
- }
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/Macro.java b/main/trunk/src/java/org/radeox/macro/Macro.java
deleted file mode 100644
index 087716c..0000000
--- a/main/trunk/src/java/org/radeox/macro/Macro.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.macro.parameter.MacroParameter;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Class that implements base functionality to write macros
- *
- * @author stephan
- * @version $Id: Macro.java,v 1.8 2003/12/16 17:08:24 stephan Exp $
- */
-
-public interface Macro extends Comparable {
- /**
- * Get the name of the macro. This is used to map a macro
- * in the input to the macro which should be called.
- * The method has to be implemented by subclassing classes.
- *
- * @return name Name of the Macro
- */
- public String getName();
-
- /**
- * Get a description of the macro. This description explains
- * in a short way what the macro does
- *
- * @return description A string describing the macro
- */
- public String getDescription();
-
- /**
- * Get a description of the paramters of the macro. The method
- * returns an array with an String entry for every parameter.
- * The format is {"1: description", ...} where 1 is the position
- * of the parameter.
- *
- * @return description Array describing the parameters of the macro
- */
- public String[] getParamDescription();
-
- public void setInitialContext(InitialRenderContext context);
-
- /**
- * Execute the macro. This method is called by MacroFilter to
- * handle macros.
- *
- * @param writer A write where the macro should write its output to
- * @param params Macro parameters with the parameters the macro is called with
- */
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException;
-}
diff --git a/main/trunk/src/java/org/radeox/macro/MacroListMacro.java b/main/trunk/src/java/org/radeox/macro/MacroListMacro.java
deleted file mode 100644
index 4fdb4bc..0000000
--- a/main/trunk/src/java/org/radeox/macro/MacroListMacro.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.macro.parameter.MacroParameter;
-import org.radeox.util.i18n.ResourceManager;
-import org.radeox.api.engine.context.RenderContext;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/*
- * MacroListMacro displays a list of all known macros of the EngineManager
- * with their name, parameters and a description.
- *
- * @author Matthias L. Jugel
- * @version $Id: MacroListMacro.java,v 1.11 2004/05/11 12:17:21 leo Exp $
- */
-
-public class MacroListMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.macrolist";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
- if (params.getLength() == 0) {
- appendTo(writer, (String)initialContext.get(RenderContext.LANGUAGE_BUNDLE_NAME));
- } else {
- throw new IllegalArgumentException("MacroListMacro: number of arguments does not match");
- }
- }
-
- public Writer appendTo(Writer writer, String bundleName) throws IOException {
- List macroList = MacroRepository.getInstance().getPlugins();
- Collections.sort(macroList);
- Iterator iterator = macroList.iterator();
- writer.write("
");
- return writer;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/MacroRepository.java b/main/trunk/src/java/org/radeox/macro/MacroRepository.java
deleted file mode 100644
index 7551265..0000000
--- a/main/trunk/src/java/org/radeox/macro/MacroRepository.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.api.engine.context.InitialRenderContext;
-
-import java.util.*;
-
-/**
- * Repository for plugins
- *
- * @author Stephan J. Schmidt
- * @version $Id: MacroRepository.java,v 1.9 2003/12/17 13:35:36 stephan Exp $
- */
-
-public class MacroRepository extends PluginRepository {
- private static Log log = LogFactory.getLog(MacroRepository.class);
-
- protected static MacroRepository instance;
- protected List loaders;
-
- public synchronized static MacroRepository getInstance() {
- if (null == instance) {
- instance = new MacroRepository();
- }
- return instance;
- }
-
- private void initialize(InitialRenderContext context) {
- Iterator iterator = list.iterator();
- while (iterator.hasNext()) {
- Macro macro = (Macro) iterator.next();
- macro.setInitialContext(context);
- }
- init();
- }
-
- public void setInitialContext(InitialRenderContext context) {
- initialize(context);
- }
-
- private void init() {
- Map newPlugins = new HashMap();
-
- Iterator iterator = list.iterator();
- while (iterator.hasNext()) {
- Macro macro = (Macro) iterator.next();
- newPlugins.put(macro.getName(), macro);
- }
- plugins = newPlugins;
- }
-
- /**
- * Loads macros from all loaders into plugins.
- */
- private void load() {
- Iterator iterator = loaders.iterator();
- while (iterator.hasNext()) {
- MacroLoader loader = (MacroLoader) iterator.next();
- loader.setRepository(this);
- log.debug("Loading from: " + loader.getClass());
- loader.loadPlugins(this);
- }
- }
-
- public void addLoader(MacroLoader loader) {
- loader.setRepository(this);
- loaders.add(loader);
- plugins = new HashMap();
- list = new ArrayList();
- load();
- }
-
- private MacroRepository() {
- loaders = new ArrayList();
- loaders.add(new MacroLoader());
- load();
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/PluginLoader.java b/main/trunk/src/java/org/radeox/macro/PluginLoader.java
deleted file mode 100644
index a5af55e..0000000
--- a/main/trunk/src/java/org/radeox/macro/PluginLoader.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.util.Service;
-
-import java.util.Iterator;
-
-/**
- * Plugin loader
- *
- * @author Stephan J. Schmidt
- * @version $Id: PluginLoader.java,v 1.6 2004/01/09 12:27:14 stephan Exp $
- */
-
-public abstract class PluginLoader {
- private static Log log = LogFactory.getLog(PluginLoader.class);
-
- protected Repository repository;
-
- public Repository loadPlugins(Repository repository) {
- return loadPlugins(repository, getLoadClass());
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public Iterator getPlugins(Class klass) {
- return Service.providers(klass);
- }
-
- public Repository loadPlugins(Repository repository, Class klass) {
- if (null != repository) {
- /* load all macros found in the services plugin control file */
- Iterator iterator = getPlugins(klass);
- while (iterator.hasNext()) {
- try {
- Object plugin = iterator.next();
- add(repository, plugin);
- log.debug("PluginLoader: Loaded plugin: " + plugin.getClass());
- } catch (Exception e) {
- log.warn("PluginLoader: unable to load plugin", e);
- }
- }
- }
- return repository;
- }
-
- /**
- * Add a plugin to the known plugin map
- *
- * @param plugin Plugin to add
- */
- public abstract void add(Repository repository, Object plugin);
-
- public abstract Class getLoadClass();
-}
diff --git a/main/trunk/src/java/org/radeox/macro/Preserved.java b/main/trunk/src/java/org/radeox/macro/Preserved.java
deleted file mode 100644
index 0b5da21..0000000
--- a/main/trunk/src/java/org/radeox/macro/Preserved.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.radeox.util.Encoder;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * A specialized macro that allows to preserve certain special characters
- * by creating character entities. The subclassing macro may decide whether
- * to call replace() before or after executing the actual macro substitution.
- *
- * @author Matthias L. Jugel
- * @version $Id: Preserved.java,v 1.7 2004/06/08 08:46:18 leo Exp $
- */
-
-public abstract class Preserved extends BaseMacro {
- private Map special = new HashMap();
- private String specialString = "";
-
- /**
- * Encode special character c by replacing with it's hex character entity code.
- */
- protected void addSpecial(char c) {
- addSpecial("" + c, Encoder.toEntity(c));
- }
-
- /**
- * Add a replacement for the special character c which may be a string
- *
- * @param c the character to replace
- * @param replacement the new string
- */
- protected void addSpecial(String c, String replacement) {
- specialString += c;
- special.put(c, replacement);
- }
-
- /**
- * Actually replace specials in source.
- * This method can be used by subclassing macros.
- *
- * @param source String to encode
- *
- * @return encoded Encoded string
- */
- protected String replace(String source) {
- StringBuffer tmp = new StringBuffer();
- StringTokenizer stringTokenizer = new StringTokenizer(source, specialString, true);
- String previous = "";
- while (stringTokenizer.hasMoreTokens()) {
- String current = stringTokenizer.nextToken();
- if (special.containsKey(current) && !previous.endsWith("&")) {
- current = (String) special.get(current);
- }
- tmp.append(current);
- previous = current;
- }
- return tmp.toString();
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/QuoteMacro.java b/main/trunk/src/java/org/radeox/macro/QuoteMacro.java
deleted file mode 100644
index db95a30..0000000
--- a/main/trunk/src/java/org/radeox/macro/QuoteMacro.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.radeox.macro.parameter.MacroParameter;
-import org.radeox.util.i18n.ResourceManager;
-import org.radeox.api.engine.context.RenderContext;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Macro to display quotations from other sources. The
- * output is wrapped usually in
to look like
- * a quotation.
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: QuoteMacro.java,v 1.11 2004/06/08 07:54:36 leo Exp $
- */
-
-public class QuoteMacro extends LocalePreserved {
- private static Log log = LogFactory.getLog(QuoteMacro.class);
-
- public String getLocaleKey() {
- return "macro.quote";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
-
- writer.write("
");
- return writer;
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/macro/table/TableBuilder.java b/main/trunk/src/java/org/radeox/macro/table/TableBuilder.java
deleted file mode 100644
index 4fd1ad9..0000000
--- a/main/trunk/src/java/org/radeox/macro/table/TableBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro.table;
-
-import java.util.StringTokenizer;
-
-/**
- * Built a table from a string
- *
- * @author stephan
- * @version $Id: TableBuilder.java,v 1.3 2003/10/06 08:30:02 stephan Exp $
- */
-
-public class TableBuilder {
- public static Table build(String content) {
- Table table = new Table();
- StringTokenizer tokenizer = new StringTokenizer(content, "|\n", true);
- String lastToken = null;
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- String linkToken = "";
- if(token.indexOf('[') != -1 && token.indexOf(']') == -1) {
- while(token.indexOf(']') == -1 && tokenizer.hasMoreTokens()) {
- linkToken += token;
- token = tokenizer.nextToken();
- }
- token = linkToken + token;
- }
- if ("\n".equals(token)) {
- // Handles "\n" - "|\n"
- if (null == lastToken || "|".equals(lastToken)) {
- table.addCell(" ");
- }
- table.newRow();
- } else if (!"|".equals(token)) {
- table.addCell(token);
- } else if (null == lastToken || "|".equals(lastToken)) {
- // Handles "|" "||"
- table.addCell(" ");
- }
- lastToken = token;
- }
- return table;
- }
-}
diff --git a/main/trunk/src/java/org/radeox/macro/xref/XrefMapper.java b/main/trunk/src/java/org/radeox/macro/xref/XrefMapper.java
deleted file mode 100644
index b49659b..0000000
--- a/main/trunk/src/java/org/radeox/macro/xref/XrefMapper.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro.xref;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * Stores information and links to xref Java source code
- * e.g.
- * http://nanning.sourceforge.net/xref/com/tirsen/nanning/MixinInstance.html#83
- *
- * @author Stephan J. Schmidt
- * @version $Id: XrefMapper.java,v 1.3 2003/06/11 10:04:27 stephan Exp $
- */
-
-public class XrefMapper {
- private static Log log = LogFactory.getLog(XrefMapper.class);
-
- private final static String FILENAME = "conf/xref.txt";
-
- private static XrefMapper instance;
- private Map xrefMap;
-
- public static synchronized XrefMapper getInstance() {
- if (null == instance) {
- instance = new XrefMapper();
- }
- return instance;
- }
-
- public XrefMapper() {
- xrefMap = new HashMap();
-
- boolean fileNotFound = false;
- try {
- BufferedReader br = new BufferedReader(
- new InputStreamReader(
- new FileInputStream(FILENAME)));
- addXref(br);
- } catch (IOException e) {
- log.warn("Unable to read " + FILENAME);
- fileNotFound = true;
- }
-
- if (fileNotFound) {
- BufferedReader br = null;
- try {
- br = new BufferedReader(
- new InputStreamReader(
- XrefMapper.class.getResourceAsStream("/" + FILENAME)
- )
- );
- addXref(br);
- } catch (Exception e) {
- log.warn("Unable to read " + FILENAME);
- }
- }
- }
-
- public void addXref(BufferedReader reader) throws IOException {
- String line;
- while ((line = reader.readLine()) != null) {
- StringTokenizer tokenizer = new StringTokenizer(line, " ");
- String site = tokenizer.nextToken();
- String baseUrl = tokenizer.nextToken();
- xrefMap.put(site.toLowerCase(), baseUrl);
- }
- }
-
- public boolean contains(String external) {
- return xrefMap.containsKey(external);
- }
-
- public Writer expand(Writer writer, String className, String site, int lineNumber) throws IOException {
- site = site.toLowerCase();
- if (xrefMap.containsKey(site)) {
- writer.write(" 0) {
- writer.write("#");
- writer.write("" + lineNumber);
- }
- writer.write("\">");
- writer.write(className);
- writer.write("");
- } else {
- log.debug("Xrefs : " + xrefMap);
- log.warn(site + " not found");
- }
- return writer;
- }
-
- public Writer appendTo(Writer writer) throws IOException {
- writer.write("{table}\n");
- writer.write("Binding|Site\n");
- Iterator iterator = xrefMap.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- writer.write((String) entry.getKey());
- writer.write("|");
- writer.write((String) entry.getValue());
- writer.write("\n");
- }
- writer.write("{table}");
- return writer;
- }
-
-}
diff --git a/main/trunk/src/java/org/radeox/regex/JdkMatcher.java b/main/trunk/src/java/org/radeox/regex/JdkMatcher.java
deleted file mode 100644
index a7d78e4..0000000
--- a/main/trunk/src/java/org/radeox/regex/JdkMatcher.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.regex;
-
-/*
- * Matcher matches regular expressions (Pattern) to input
- * Implementation for regex package in JDK 1.4
- *
- * @author stephan
- * @team sonicteam
- * @version $Id: JdkMatcher.java,v 1.5 2004/04/16 09:10:38 stephan Exp $
- */
-
-public class JdkMatcher extends Matcher {
- private JdkPattern pattern;
- private String input;
- private java.util.regex.Matcher internalMatcher;
-
- public String substitute(Substitution substitution) {
- MatchResult matchResult = new JdkMatchResult(internalMatcher);
-
- StringBuffer buffer = new StringBuffer();
- while (internalMatcher.find()) {
- internalMatcher.appendReplacement(buffer, "");
- substitution.handleMatch(buffer, matchResult);
- }
- internalMatcher.appendTail(buffer);
- return buffer.toString();
- }
-
- public String substitute(String substitution) {
- return internalMatcher.replaceAll(substitution);
- }
-
- protected java.util.regex.Matcher getMatcher() {
- return internalMatcher;
- }
-
- public JdkMatcher(String input, Pattern pattern) {
- this.input = input;
- this.pattern = (JdkPattern) pattern;
- internalMatcher = this.pattern.getPattern().matcher(this.input);
-
- }
-
- public boolean contains() {
- internalMatcher.reset();
- return internalMatcher.find();
- }
-
- public boolean matches() {
- return internalMatcher.matches();
- }
-}
\ No newline at end of file
diff --git a/main/trunk/src/java/org/radeox/util/Encoder.java b/main/trunk/src/java/org/radeox/util/Encoder.java
deleted file mode 100644
index 48ed751..0000000
--- a/main/trunk/src/java/org/radeox/util/Encoder.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.util;
-
-import org.radeox.regex.Pattern;
-import org.radeox.regex.Matcher;
-import org.radeox.regex.Substitution;
-import org.radeox.regex.MatchResult;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/*
- * Escapes and encodes Strings for web usage
- *
- * @author stephan
- * @version $Id: Encoder.java,v 1.8 2004/09/06 19:25:33 leo Exp $
- */
-
-public class Encoder {
- private final static String DELIMITER = "&\"'<>[]";
- private final static Map ESCAPED_CHARS = new HashMap();
- // private final static Pattern entityPattern = Pattern.compile("&(#?[0-9a-fA-F]+);");
-
- static {
- ESCAPED_CHARS.put("&", toEntity('&'));
- ESCAPED_CHARS.put("\"", toEntity('"'));
- ESCAPED_CHARS.put("'", toEntity('\''));
- ESCAPED_CHARS.put(">", toEntity('>'));
- ESCAPED_CHARS.put("<", toEntity('<'));
- ESCAPED_CHARS.put("[", toEntity('['));
- ESCAPED_CHARS.put("]", toEntity(']'));
- }
-
- /**
- * Encoder special characters that may occur in a HTML so it can be displayed
- * safely.
- * @param str the original string
- * @return the escaped string
- */
- public static String escape(String str) {
- StringBuffer result = new StringBuffer();
- StringTokenizer tokenizer = new StringTokenizer(str, DELIMITER, true);
- while(tokenizer.hasMoreTokens()) {
- String currentToken = tokenizer.nextToken();
- if(ESCAPED_CHARS.containsKey(currentToken)) {
- result.append(ESCAPED_CHARS.get(currentToken));
- } else {
- result.append(currentToken);
- }
- }
- return result.toString();
- }
-
- public static String unescape(String str) {
- StringBuffer result = new StringBuffer();
-
- org.radeox.regex.Compiler compiler = org.radeox.regex.Compiler.create();
- Pattern entityPattern = compiler.compile("&(#?[0-9a-fA-F]+);");
-
- Matcher matcher = Matcher.create(str, entityPattern);
- result.append(matcher.substitute(new Substitution() {
- public void handleMatch(StringBuffer buffer, MatchResult result) {
- buffer.append(toChar(result.group(1)));
- }
- }));
- return result.toString();
- }
-
- public static String toEntity(int c) {
- return "" + c + ";";
- }
-
- public static char toChar(String number) {
- return (char) Integer.decode(number.substring(1)).intValue();
- }
-}
diff --git a/main/trunk/src/java/org/radeox/util/Service.java b/main/trunk/src/java/org/radeox/util/Service.java
deleted file mode 100644
index b5d0431..0000000
--- a/main/trunk/src/java/org/radeox/util/Service.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.radeox.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * After the Service class from Sun and the Apache project.
- * With help from FrŽdŽric Miserey.
- *
- * credits FrŽdŽric Miserey, Joseph Oettinger
- *
- * @author Matthias L. Jugel
- * @version $id$
- */
-public class Service {
-
- public static final int RESOURCE = 0;
- public static final int CLASS = 1;
- public static final int INSTANCE = 2;
-
- static HashMap services = new HashMap();
-
- public static synchronized Iterator providerNames(Class cls) {
- return providers(cls, Service.RESOURCE);
- }
-
- public static synchronized Iterator providerClasses(Class cls) {
- return providers(cls, false);
- }
-
- public static synchronized Iterator providers(Class cls) {
- return providers(cls, true);
- }
-
- public static synchronized Iterator providers(Class cls, boolean instantiate) {
- return providers(cls, instantiate ? Service.INSTANCE : Service.CLASS);
- }
-
- public static synchronized Iterator providers(Class cls, int providerKind) {
- ClassLoader classLoader = cls.getClassLoader();
- String providerFile = "META-INF/services/" + cls.getName();
-
- // check whether we already loaded the provider classes
- List providers = (List) services.get(providerFile);
- if (providers != null) {
- return providers.iterator();
- }
-
- // create new list of providers
- providers = new ArrayList();
- services.put(providerFile, providers);
-
- try {
- // get all files with the name providerFile out of all jar files
- Enumeration providerFiles = classLoader.getResources(providerFile);
-
- if (providerFiles.hasMoreElements()) {
- // cycle through the provider files and load classes
- while (providerFiles.hasMoreElements()) {
- try {
- URL url = (URL) providerFiles.nextElement();
- Reader reader = new InputStreamReader(url.openStream(), "UTF-8");
- switch (providerKind) {
- case Service.RESOURCE:
- loadResources(reader, classLoader, providers);
- break;
- case Service.CLASS:
- loadClasses(reader, classLoader, providers);
- break;
- case Service.INSTANCE:
- loadInstances(reader, classLoader, providers);
- break;
- }
- } catch (Exception ex) {
- //ex.printStackTrace();
- // Just try the next file...
- }
- }
- } else {
- // Workaround for broken classloaders, e.g. Orion
- InputStream is = classLoader.getResourceAsStream(providerFile);
- if (is == null) {
- providerFile = providerFile.substring(providerFile.lastIndexOf('.') + 1);
- is = classLoader.getResourceAsStream(providerFile);
- }
- if (is != null) {
- Reader reader = new InputStreamReader(is, "UTF-8");
- loadInstances(reader, classLoader, providers);
- }
- }
- } catch (IOException ioe) {
- //ioe.printStackTrace();
- // ignore exception
- }
- return providers.iterator();
- }
-
- private static void loadResources(Reader input, ClassLoader classLoader, List providers) throws IOException {
- BufferedReader reader = new BufferedReader(input);
-
- String line = reader.readLine();
- while (line != null) {
- providers.add(line);
- line = reader.readLine();
- }
- }
-
- private static void loadClasses(Reader input, ClassLoader classLoader, List classes) throws IOException {
- Iterator classesIt = readLines(input).iterator();
- while (classesIt.hasNext()) {
- String className = (String) classesIt.next();
- try {
- classes.add(classLoader.loadClass(className));
- } catch (ClassNotFoundException e) {
- // ignore silently
- }
- }
- }
-
- private static void loadInstances(Reader input, ClassLoader classLoader, List providers) throws IOException {
- Iterator classesIt = readLines(input).iterator();
- while (classesIt.hasNext()) {
- String className = (String) classesIt.next();
- int modifierIndex = className.indexOf('_');
- String modifier = null;
- if (modifierIndex != -1) {
- modifier = className.substring(modifierIndex + 1);
- className = className.substring(0, modifierIndex);
- }
-
- try {
- Class klass = classLoader.loadClass(className);
- Object obj = klass.newInstance();
- if (null != modifier) {
- Method setModifierMethod = klass.getMethod("setModifier", new Class[]{String.class});
- setModifierMethod.invoke(obj, new Object[]{modifier});
-// System.out.println("Loading modified version of '"+className+"' ("+modifier+")");
- }
- // stick it into our vector...
- providers.add(obj);
- } catch (NoSuchMethodException e) {
- // ignore silently
- } catch (InvocationTargetException e) {
- // ignore silently
- } catch (ClassNotFoundException e) {
- // ignore silently
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- //Logger.debug("Service: loaded "+ obj.getClass().getName());
- }
- }
-
- /**
- * Read all lines from the reader and filter out comment lines starting
- * with a hash mark (#)
- *
- * @param input the stream reader to contain lines
- * @return a list containing all significant lines
- * @throws IOException if the reader was interrupted
- */
- private static List readLines(Reader input) throws IOException {
- List linesList = new ArrayList();
-
- BufferedReader reader = new BufferedReader(input);
- String line;
- while ((line = reader.readLine()) != null) {
- try {
- // strip comments out of the stream
- int idx = line.indexOf('#');
- if (idx != -1) {
- line = line.substring(0, idx);
- }
-
- // Trim whitespace
- line = line.trim();
-
- // store line if there is still more than spaces on it
- if (line.length() > 0) {
- linesList.add(line);
- }
- } catch (Exception ex) {
- //ex.printStackTrace();
- // Just try the next line
- }
- }
- return linesList;
- }
-
-}
diff --git a/main/trunk/src/java/org/radeox/util/StringBufferWriter.java b/main/trunk/src/java/org/radeox/util/StringBufferWriter.java
deleted file mode 100644
index e05645b..0000000
--- a/main/trunk/src/java/org/radeox/util/StringBufferWriter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.util;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * The same as StringWriter, but takes an existing StringBuffer in its
- * constructor.
- *
- * @author Stephan J. Schmidt
- * @version $Id: StringBufferWriter.java,v 1.2 2003/02/06 13:41:42 leo Exp $
- */
-
-public class StringBufferWriter extends Writer {
-
- private StringBuffer buffer;
-
- public StringBufferWriter(StringBuffer buffer) {
- this.buffer = buffer;
- this.lock = buffer;
- }
-
- public StringBufferWriter() {
- this.buffer = new StringBuffer();
- this.lock = buffer;
- }
-
- public StringBufferWriter(int initialSize) {
- if (initialSize < 0) {
- throw new IllegalArgumentException("Negative buffer size");
- }
- buffer = new StringBuffer(initialSize);
- lock = buffer;
- }
-
- public void write(int c) {
- buffer.append((char) c);
- }
-
- public void write(char cbuf[], int off, int len) {
- if ((off < 0) || (off > cbuf.length) || (len < 0) ||
- ((off + len) > cbuf.length) || ((off + len) < 0)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- buffer.append(cbuf, off, len);
- }
-
- public void write(String str) {
- buffer.append(str);
- }
-
-
- public void write(String str, int off, int len) {
- buffer.append(str.substring(off, off + len));
- }
-
- public String toString() {
- return buffer.toString();
- }
-
- public StringBuffer getBuffer() {
- return buffer;
- }
-
- public void flush() {
- }
-
- public void close() throws IOException {
- }
-}
diff --git a/main/trunk/src/java/org/radeox/util/i18n/ResourceManager.java b/main/trunk/src/java/org/radeox/util/i18n/ResourceManager.java
deleted file mode 100644
index b3205da..0000000
--- a/main/trunk/src/java/org/radeox/util/i18n/ResourceManager.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.util.i18n;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-/**
- * A Resource Manager implementation to aid the use of locales.
- * It works similar to what the bundle tag in jstl fmt taglibs does but adapted
- * for use withing a threaded java environment.
- *
- * @author Matthias L. Jugel
- * @version $Id: ResourceManager.java,v 1.5 2004/06/08 07:54:37 leo Exp $
- */
-public class ResourceManager {
- private static Log log = LogFactory.getLog(ResourceManager.class);
-
- private static ThreadLocal instance = new ThreadLocal() {
- protected synchronized Object initialValue() {
- return new ResourceManager();
- }
- };
-
- /**
- * Thread re-use makes your life hard. If you suspect leakage of locale
- * and bundles into other threads, using forceGet() may be a good choice.
- * @return a new instance of the ResourceManager
- */
- public static ResourceManager forceGet() {
- instance.set(null);
- return get();
- }
-
- /**
- * Get a new thread-local instance of the ResourceManager
- * If you are having problems with bundles beeing the same for different
- * threads and locales, try forceGet()
- * @return the thread-local ResourceManager
- */
- public static ResourceManager get() {
- ResourceManager resourceManager = (ResourceManager) instance.get();
- if(null == resourceManager) {
- resourceManager = new ResourceManager();
- instance.set(resourceManager);
- }
- return resourceManager;
- }
-
- /**
- * Get ResourceBundle using the base name provided. The bundle is located
- * using previously given locale settings.
- * @param baseName the bundle base name
- * @return the bundle
- */
- public static ResourceBundle getBundle(String baseName) {
- return ResourceManager.get().getResourceBundle(baseName);
- }
-
- /**
- * Get the locale of the loaded bundle. This is the actual locale of the
- * bundle, not the locale requested.
- * @param baseName the bundle base name
- * @return the locale of the bundle
- */
- public static Locale getLocale(String baseName) {
- return ResourceManager.get().getResourceBundle(baseName).getLocale();
- }
-
- public static String getString(String baseName, String key) {
- try {
- ResourceBundle bundle = getBundle(baseName);
- return bundle.getString(key);
- } catch (Exception e) {
- log.warn("missing resource for bundle '"+baseName+"', key '"+key+"'", e);
- return "???"+key+"???";
- }
- }
-
- private Locale locale = null;
- private Enumeration fallback = null;
- private Map resourceBundles = new HashMap();
-
- /**
- * Set the locale and potential fallbacks for this thread.
- * @param locale the requested locale
- * @param fallback a set of fallback locales, i.e. request.getLocales()
- */
- public void setLocale(Locale locale, Enumeration fallback) {
- this.locale = locale;
- this.fallback = fallback;
- }
-
- /**
- * Get the bundle that is active for this thread. This is done by loading
- * either the specified locale based resource bundle and, if that fails, by
- * looping through the fallback locales to locate a usable bundle.
- *
- * @return the resource bundle
- */
- public ResourceBundle getResourceBundle(String baseName) {
-// System.out.println(this + " " + this.locale+" ("+resourceBundles.size()+")");
- ResourceBundle bundle = (ResourceBundle) resourceBundles.get(baseName);
- if(null == bundle) {
- resourceBundles.put(baseName, bundle = findBundle(baseName));
- }
- return bundle;
- }
-
- /**
- * Find a resource bundle by looking up using the locales. This is done by loading
- * either the specified locale based resource bundle and, if that fails, by
- * looping through the fallback locales to locate a usable bundle.
- */
- private ResourceBundle findBundle(String baseName) {
- ResourceBundle resourceBundle = null;
-
- // first try to load the resource bundle with the specified locale
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (null != locale) {
- try {
- resourceBundle = ResourceBundle.getBundle(baseName, locale, cl);
- } catch (Exception e) {
- log.fatal("unable to load a default bundle: "+baseName+"_"+locale);
- }
- // check that the requested main locale matches the resource bundle's,
- // since we get the system fallback locale if no match is found
- if(!resourceBundle.getLocale().equals(locale)) {
- resourceBundle = null;
- }
- }
-
- // loop through the fall back locales until a bundle is found
- if (null == resourceBundle) {
- if(null != fallback) {
- while(fallback.hasMoreElements()) {
- Locale testLocale = (Locale) fallback.nextElement();
- log.debug("looking up locale "+testLocale);
- ResourceBundle testBundle = ResourceBundle.getBundle(baseName, testLocale, cl);
- String language = testBundle.getLocale().getLanguage();
- String country = testBundle.getLocale().getCountry();
-
- if (testBundle.getLocale().equals(testLocale)) {
- resourceBundle = testBundle;
- log.debug("found bundle for locale " +baseName+"_"+ testBundle.getLocale());
- break;
- } else if (testLocale.getLanguage().equals(language)) {
- if (testLocale.getCountry().equals(country)) {
- // language and country match which is good, keep looking for variant too
- resourceBundle = testBundle;
- log.debug("potential bundle: " + baseName + "_" + testBundle.getLocale());
- continue;
- } else {
- // only accept this if there is no better previous lookup
- if (null == resourceBundle) {
- resourceBundle = testBundle;
- log.debug("potential bundle: " + baseName+"_"+testBundle.getLocale());
- }
- continue;
- }
- }
- }
- }
-
- // make sure the resource bundle is loaded (should not happen)
- if (null == resourceBundle) {
- resourceBundle = ResourceBundle.getBundle(baseName);
- if (null != resourceBundle) {
- log.debug("system locale bundle taken: " + baseName + "_" + resourceBundle.getLocale());
- }
- }
- }
-
- return resourceBundle;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/AllTests.java b/main/trunk/src/test/org/radeox/AllTests.java
deleted file mode 100644
index 199e9a0..0000000
--- a/main/trunk/src/test/org/radeox/AllTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.radeox.filter.AllFilterTests;
-import org.radeox.groovy.AllGroovyTests;
-import org.radeox.macro.AllMacroTests;
-import org.radeox.regex.AllRegexTests;
-
-public class AllTests extends TestCase {
- public AllTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite s = new TestSuite();
- s.addTest(AllFilterTests.suite());
- s.addTest(AllMacroTests.suite());
- s.addTest(AllGroovyTests.suite());
- s.addTest(AllRegexTests.suite());
- s.addTestSuite(BaseRenderEngineTest.class);
- return s;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/PerformanceTests.java b/main/trunk/src/test/org/radeox/PerformanceTests.java
deleted file mode 100644
index cc8c586..0000000
--- a/main/trunk/src/test/org/radeox/PerformanceTests.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox;
-
-import com.clarkware.junitperf.TimedTest;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.engine.BaseRenderEngine;
-import org.radeox.engine.context.BaseRenderContext;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class PerformanceTests {
- public static void main(String[] args) throws IOException {
- TestRunner.run(suite());
- }
-
- public static Test suite() throws IOException {
- // get test markup from text file
- File wikiTxt = new File("wiki.txt");
- BufferedReader reader = new BufferedReader(new FileReader(wikiTxt.getCanonicalFile()));
- StringBuffer input = new StringBuffer();
- String tmp;
- while ((tmp = reader.readLine()) != null) {
- input.append(tmp);
- }
- RenderEngine engine = new BaseRenderEngine();
- System.err.println(engine.render("__initialized__", new BaseRenderContext()));
-
- TestSuite s = new TestSuite();
- long maxElapsedTime = 30 * 1000; // 30s
- StringBuffer testString = new StringBuffer();
- for (int i = 0; i < 10; i++) {
- testString.append(input);
- Test renderEngineTest = new RenderEnginePerformanceTest(testString.toString());
- Test timedTest = new TimedTest(renderEngineTest, maxElapsedTime, false);
- s.addTest(timedTest);
- }
- return s;
- }
-
-
-}
\ No newline at end of file
diff --git a/main/trunk/src/test/org/radeox/RegexpTest.java b/main/trunk/src/test/org/radeox/RegexpTest.java
deleted file mode 100644
index 9cd0303..0000000
--- a/main/trunk/src/test/org/radeox/RegexpTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox;
-
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.engine.BaseRenderEngine;
-import org.radeox.engine.context.BaseRenderContext;
-
-import java.io.*;
-
-public class RegexpTest {
- public static void main(String[] args) {
-
- String file = args.length > 0 ? args[0] : "conf/wiki.txt";
- try {
- System.setOut(new PrintStream(System.out, true, "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- // this should never happen
- }
-
- StringBuffer tmp = new StringBuffer();
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
- char[] buffer = new char[1024];
- int n = 0;
- while ((n = reader.read(buffer)) != -1) {
- tmp.append(buffer, 0, n);
- }
- } catch (Exception e) {
- System.err.println("File not found: "+e.getMessage());
- }
-
- String content = tmp.toString();
-
- try {
- PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
- out.println(content);
- out.flush();
-
- RenderContext context = new BaseRenderContext();
- RenderEngine engine = new BaseRenderEngine();
-
- long now = System.currentTimeMillis();
- String output = engine.render(content, context);
- long dif = System.currentTimeMillis() - now;
-
- System.err.println("time spent: "+dif+"ms");
- out.println(output);
- out.flush();
- out.close();
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/main/trunk/src/test/org/radeox/filter/AllFilterTests.java b/main/trunk/src/test/org/radeox/filter/AllFilterTests.java
deleted file mode 100644
index 719ba7e..0000000
--- a/main/trunk/src/test/org/radeox/filter/AllFilterTests.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AllFilterTests extends TestCase {
- public AllFilterTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite s = new TestSuite();
- s.addTestSuite(BasicRegexTest.class);
- s.addTestSuite(ItalicFilterTest.class);
- s.addTestSuite(BoldFilterTest.class);
- s.addTestSuite(KeyFilterTest.class);
- s.addTestSuite(NewlineFilterTest.class);
- s.addTestSuite(LineFilterTest.class);
- s.addTestSuite(TypographyFilterTest.class);
- s.addTestSuite(HtmlRemoveFilterTest.class);
- s.addTestSuite(StrikeThroughFilterTest.class);
- s.addTestSuite(UrlFilterTest.class);
- s.addTestSuite(ParamFilterTest.class);
- s.addTestSuite(FilterPipeTest.class);
- s.addTestSuite(EscapeFilterTest.class);
- s.addTestSuite(InterWikiTest.class);
- s.addTestSuite(LinkTestFilterTest.class);
- s.addTestSuite(WikiLinkFilterTest.class);
- s.addTestSuite(SmileyFilterTest.class);
- s.addTestSuite(ListFilterTest.class);
- s.addTestSuite(HeadingFilterTest.class);
- return s;
- }
-
-}
diff --git a/main/trunk/src/test/org/radeox/filter/BasicRegexTest.java b/main/trunk/src/test/org/radeox/filter/BasicRegexTest.java
deleted file mode 100644
index be22cb5..0000000
--- a/main/trunk/src/test/org/radeox/filter/BasicRegexTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.radeox.engine.context.BaseRenderContext;
-import org.radeox.engine.context.BaseInitialRenderContext;
-import org.radeox.filter.context.BaseFilterContext;
-import org.radeox.filter.context.FilterContext;
-import org.radeox.filter.regex.RegexReplaceFilter;
-import org.radeox.filter.regex.RegexTokenFilter;
-import org.radeox.regex.MatchResult;
-import org.radeox.regex.Pattern;
-import org.radeox.regex.Matcher;
-import org.radeox.filter.HeadingFilter;
-import org.radeox.filter.Filter;
-import org.radeox.macro.code.XmlCodeFilter;
-
-import java.text.MessageFormat;
-
-public class BasicRegexTest extends TestCase {
- private static String BOLD_TEST_REGEX = "(^|>|[[:space:]]+)__(.*?)__([[:space:]]+|<|$)";
- private org.radeox.regex.Compiler compiler;
-
- public BasicRegexTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- compiler = org.radeox.regex.Compiler.create();
- compiler.setMultiline(true);
- }
-
- public static Test suite() {
- return new TestSuite(BasicRegexTest.class);
- }
-
- // filter.heading.match=^[[:space:]]*(1(\\.1)*)[[:space:]]+(.*?)$
- //filter.heading.print=
{1}
-
- public void testStartEnd() {
- Pattern p = compiler.compile("^A.*B$");
- Matcher m = Matcher.create("A1234567B", p);
- assertTrue("^...$ pattern found", m.matches());
- }
-
- public void testHeading() {
- FilterContext context = new BaseFilterContext();
- context.setRenderContext(new BaseRenderContext());
- Filter filter = new HeadingFilter();
- filter.setInitialContext(new BaseInitialRenderContext());
- assertEquals("Heading replaced", "
", filter.filter("1 testHand", context));
- }
-
- public void testWordBorders() {
- Pattern p = compiler.compile("\\bxsl\\b");
- Matcher m = Matcher.create("test xsl test", p);
- assertTrue("Word found", m.contains());
- m = Matcher.create("testxsltest", p);
- assertTrue("Word not found", !m.contains());
- }
-
- public void testByHandUrl() {
- //([^\"'=]|^)
-// Pattern p = Pattern.compile("((http|ftp)s?://(%[[:digit:]A-Fa-f][[:digit:]A-Fa-f]|[-_.!~*';/?:@#&=+$,[:alnum:]])+)", Pattern.MULTILINE);
- Pattern p = compiler.compile("(http|ftp)s?://([-_.!~*';/?:@#&=+$,\\p{Alnum}])+");
- Matcher m = Matcher.create("http://snipsnap.org", p);
- assertTrue("A Url found", m.matches());
- }
-
- public void testXmlCodeFilter() {
- Pattern p = compiler.compile("\"(([^\"\\\\]|\\.)*)\"");
- Matcher m = Matcher.create("", p);
-
- assertEquals("Quote replaced", "\"attr\"/>", m.substitute("\"$1\""));
-
- XmlCodeFilter xmlCodeFilter = new XmlCodeFilter();
- FilterContext context = new BaseFilterContext();
- context.setRenderContext(new BaseRenderContext());
- assertEquals("XmlCodeFilter works", "\"attr\">text", xmlCodeFilter.filter("text", context));
- }
-
- public void testBackreference() {
- java.util.regex.Pattern p = java.util.regex.Pattern.compile("\\{([^:}]+)(?::([^\\}]*))?\\}(.*?)\\{\\1\\}", java.util.regex.Pattern.MULTILINE);
- java.util.regex.Matcher matcher = p.matcher("{code:xml}text{code}");
- assertTrue("A Backreference Regex found", matcher.find());
- assertNotNull("Content not null", matcher.group(3));
- assertEquals("Content found", "text", matcher.group(3));
- }
-
- public void testRegexBasic() {
- Pattern p = compiler.compile("A");
- Matcher m = Matcher.create("AB", p);
-
- assertTrue("A Regex found", m.contains());
- }
-
- public void testMultiline() {
- compiler.setMultiline(false);
- Pattern p = compiler.compile("A.*B");
- Matcher m = Matcher.create("A123\n456B", p);
-
- assertTrue("Multiline Regex found", m.matches());
- }
-
- public void testByHandBold() {
- Pattern p = compiler.compile(BOLD_TEST_REGEX);
- Matcher m = Matcher.create("__test__", p);
-
- assertEquals("Bold replaced by hand", "test", m.substitute("$1$2$3"));
- }
-
- public void testRegexFilterBold() {
- RegexReplaceFilter filter = new RegexReplaceFilter();
- filter.addRegex(BOLD_TEST_REGEX, "$1$2$3");
- FilterContext context = new BaseFilterContext();
- context.setRenderContext(new BaseRenderContext());
- assertEquals("Bold replaced with RegexFilter", "test", filter.filter("__test__", context));
-
- }
-}
diff --git a/main/trunk/src/test/org/radeox/filter/TypographyFilterTest.java b/main/trunk/src/test/org/radeox/filter/TypographyFilterTest.java
deleted file mode 100644
index a268b78..0000000
--- a/main/trunk/src/test/org/radeox/filter/TypographyFilterTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.radeox.filter.TypographyFilter;
-
-public class TypographyFilterTest extends FilterTestSupport {
-
- protected void setUp() throws Exception {
- filter = new TypographyFilter();
- super.setUp();
- }
-
- public static Test suite() {
- return new TestSuite(FilterTestSupport.class);
- }
-
- public void testElipsis() {
- assertEquals("Test … Text", filter.filter("Test ... Text", context));
- }
-
- public void testNotAfter() {
- assertEquals("...Text", filter.filter("...Text", context));
- }
-
- public void testEndOfLine() {
- assertEquals("Text…", filter.filter("Text...", context));
- }
-
- public void test4Dots() {
- assertEquals("Test .... Text", filter.filter("Test .... Text", context));
- }
-
- public void testLineStart() {
- assertEquals("… Text", filter.filter("... Text", context));
- }
-
- public void testLineEnd() {
- assertEquals("Test …", filter.filter("Test ...", context));
- }
-
-}
diff --git a/main/trunk/src/test/org/radeox/filter/mock/MockInterWikiRenderEngine.java b/main/trunk/src/test/org/radeox/filter/mock/MockInterWikiRenderEngine.java
deleted file mode 100644
index 8b4db46..0000000
--- a/main/trunk/src/test/org/radeox/filter/mock/MockInterWikiRenderEngine.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.mock;
-
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.WikiRenderEngine;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.api.engine.context.InitialRenderContext;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.io.Reader;
-
-public class MockInterWikiRenderEngine implements RenderEngine, WikiRenderEngine {
-
- public InitialRenderContext getInitialRenderContext() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean exists(String name) {
- return false;
- }
-
- public boolean showCreate() {
- return false;
- }
-
- public void appendLink(StringBuffer buffer, String name, String view, String anchor) {
- }
-
- public void appendLink(StringBuffer buffer, String name, String view) {
- }
-
- public void appendCreateLink(StringBuffer buffer, String name, String view) {
- }
-
- public String getName() {
- return "mock-wiki";
- }
-
- public String render(String content, RenderContext context) {
- return null;
- }
-
- public void render(Writer out, String content, RenderContext context) throws IOException {
- }
-
- public String render(Reader in, RenderContext context) throws IOException {
- return null;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/filter/mock/MockWikiRenderEngine.java b/main/trunk/src/test/org/radeox/filter/mock/MockWikiRenderEngine.java
deleted file mode 100644
index 494c8f8..0000000
--- a/main/trunk/src/test/org/radeox/filter/mock/MockWikiRenderEngine.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.filter.mock;
-
-import org.radeox.api.engine.RenderEngine;
-import org.radeox.api.engine.WikiRenderEngine;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.util.Encoder;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.io.Reader;
-
-public class MockWikiRenderEngine implements RenderEngine, WikiRenderEngine {
-
- public InitialRenderContext getInitialRenderContext() {
- return null;
- }
-
- public boolean exists(String name) {
- return name.equals("SnipSnap") || name.equals("stephan");
- }
-
- public boolean showCreate() {
- return true;
- }
-
- public void appendLink(StringBuffer buffer, String name, String view, String anchor) {
- buffer.append("link:"+name+"|"+view+"#"+anchor);
- }
-
- public void appendLink(StringBuffer buffer, String name, String view) {
- buffer.append("link:" + name + "|" +view);
- }
-
- public void appendCreateLink(StringBuffer buffer, String name, String view) {
- buffer.append("'").append(name).append("' - ");
- buffer.append("'").append(Encoder.escape(name)).append("'");
- }
-
- public String getName() {
- return "mock-wiki";
- }
-
- public String render(String content, RenderContext context) {
- return null;
- }
-
- public void render(Writer out, String content, RenderContext context) throws IOException {
- }
-
-
- public String render(Reader in, RenderContext context) throws IOException {
- return null;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/groovy/AllGroovyTests.java b/main/trunk/src/test/org/radeox/groovy/AllGroovyTests.java
deleted file mode 100644
index 6bd2b37..0000000
--- a/main/trunk/src/test/org/radeox/groovy/AllGroovyTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.groovy;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AllGroovyTests extends TestCase {
- public AllGroovyTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite s = new TestSuite();
- s.addTestSuite(RadeoxTemplateEngineTest.class);
- return s;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/macro/AllMacroTests.java b/main/trunk/src/test/org/radeox/macro/AllMacroTests.java
deleted file mode 100644
index ece7b62..0000000
--- a/main/trunk/src/test/org/radeox/macro/AllMacroTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.radeox.macro.code.AllCodeMacroTests;
-
-public class AllMacroTests extends TestCase {
- public AllMacroTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite s = new TestSuite();
- s.addTestSuite(ApiMacroTest.class);
- s.addTestSuite(ApiDocMacroTest.class);
- s.addTestSuite(AsinMacroTest.class);
- s.addTestSuite(FilePathMacroTest.class);
- s.addTestSuite(IsbnMacroTest.class);
- s.addTestSuite(LinkMacroTest.class);
- s.addTestSuite(ParamMacroTest.class);
- s.addTestSuite(TableMacroTest.class);
- s.addTestSuite(XrefMacroTest.class);
- s.addTestSuite(MailToMacroTest.class);
- s.addTestSuite(RfcMacroTest.class);
- s.addTestSuite(BaseMacroParameterTest.class);
-// s.addTestSuite(YipeeTest.class);
-
- s.addTest(AllCodeMacroTests.suite());
- return s;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/macro/ApiDocMacroTest.java b/main/trunk/src/test/org/radeox/macro/ApiDocMacroTest.java
deleted file mode 100644
index ba9a5de..0000000
--- a/main/trunk/src/test/org/radeox/macro/ApiDocMacroTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ApiDocMacroTest extends MacroTestSupport {
- public ApiDocMacroTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(ApiDocMacroTest.class);
- }
-
- public void testApi() {
- String result = engine.render("{api-docs}", context);
- // This must be moved to IoC to better test ApiDoc directly.
- assertEquals("ApiDocs are rendered",
- "
",
- result);
- }
-
-
-}
diff --git a/main/trunk/src/test/org/radeox/macro/ParamMacroTest.java b/main/trunk/src/test/org/radeox/macro/ParamMacroTest.java
deleted file mode 100644
index 9093781..0000000
--- a/main/trunk/src/test/org/radeox/macro/ParamMacroTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class ParamMacroTest extends MacroTestSupport {
-
- public ParamMacroTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(ParamMacroTest.class);
- }
-
- public void testParamMacro() {
- Map params = new HashMap();
- params.put("user","stephan");
- context.setParameters(params);
- String result = engine.render("{hello:$user}", context);
- assertEquals("Hello stephan", result);
- }
-}
diff --git a/main/trunk/src/test/org/radeox/macro/YipeeTest.java b/main/trunk/src/test/org/radeox/macro/YipeeTest.java
deleted file mode 100644
index cd2d8e6..0000000
--- a/main/trunk/src/test/org/radeox/macro/YipeeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.macro;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class YipeeTest extends MacroTestSupport {
- public YipeeTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(YipeeTest.class);
- }
-
- public void testYipee() {
- String result = engine.render("{yipee}", context);
- assertEquals("Yipee ay ey", result);
- }
-}
diff --git a/main/trunk/src/test/org/radeox/regex/AllRegexTests.java b/main/trunk/src/test/org/radeox/regex/AllRegexTests.java
deleted file mode 100644
index cb94ad2..0000000
--- a/main/trunk/src/test/org/radeox/regex/AllRegexTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.regex;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AllRegexTests extends TestCase {
- public AllRegexTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite s = new TestSuite();
- s.addTest(OroMatcherTest.suite());
- return s;
- }
-}
diff --git a/main/trunk/src/test/org/radeox/regex/OroMatcherTest.java b/main/trunk/src/test/org/radeox/regex/OroMatcherTest.java
deleted file mode 100644
index d93b730..0000000
--- a/main/trunk/src/test/org/radeox/regex/OroMatcherTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
- * Fraunhofer Institute Computer Architecture and Software Technology
- * (FIRST), Berlin, Germany
- *
- * Licensed 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.radeox.regex;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class OroMatcherTest extends TestCase {
-
- public static Test suite() {
- return new TestSuite(OroMatcherTest.class);
- }
-
- public void testSubstituteWithoutVariables() {
- OroCompiler compiler = new OroCompiler();
- Pattern pattern = compiler.compile("A");
- OroMatcher matcher = new OroMatcher("A", pattern);
- String substituted = matcher.substitute("B");
- assertEquals("Correct substitution without variables.", "B", substituted);
- }
-
- public void testSubstituteWithVariables() {
- OroCompiler compiler = new OroCompiler();
- Pattern pattern = compiler.compile("(A)");
- OroMatcher matcher = new OroMatcher("BAB", pattern);
- String substituted = matcher.substitute("C$1C");
- assertEquals("Correct substitution with variables.", "BCACB", substituted);
- }
-
- public void testSubstitutionWithSubstitution() {
- OroCompiler compiler = new OroCompiler();
- Pattern pattern = compiler.compile("(A)");
- OroMatcher matcher = new OroMatcher("BABAB", pattern);
- String substituted = matcher.substitute(new Substitution() {
- public void handleMatch(StringBuffer buffer, MatchResult result) {
- String match = result.group(1);
- buffer.append(match.toLowerCase());
- }
- });
- assertEquals("Correct substitution with substitution.", "BaBaB", substituted);
- }
-}
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..15ef2ee
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,161 @@
+
+ 4.0.0
+ radeox
+ radeox
+ 1.3.2-verbis
+ radeox
+
+ src/main/java
+ src/test/java
+
+
+ src/main/resources/META-INF
+ META-INF
+
+
+ src/main/resources/conf
+
+ **/*.txt
+ **/*.properties
+
+
+
+
+
+ maven-compiler-plugin
+ 3.7.0
+
+
+ default-compile
+ compile
+
+ compile
+
+
+ true
+ 1.8
+ 1.8
+
+
+
+ default-testCompile
+ test-compile
+
+ testCompile
+
+
+ true
+ 1.8
+ 1.8
+
+
+
+
+ 1.8
+ 1.8
+
+
+
+ maven-jar-plugin
+ 2.3.1
+
+
+ default-jar
+ package
+
+ jar
+
+
+
+
+
+
+ true
+ org.radeox.example.InteractiveExample
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.5.3
+
+
+
+
+ iso-8859-1
+
+
+
+ commons-logging
+ commons-logging
+ 1.1
+
+
+ org.jmock
+ jmock
+ 2.4.0
+ test
+
+
+ org.jmock
+ jmock-junit3
+ 2.4.0
+ test
+
+
+ org.jmock
+ jmock-cglib
+ 1.0.0.RC1
+ test
+
+
+ org.jmock
+ jmock-legacy
+ 2.4.0
+ test
+
+
+ oro
+ oro
+ 2.0.8
+
+
+ org.apache.commons
+ commons-lang3
+ 3.12.0
+
+
+ picocontainer
+ picocontainer
+ 1.1
+
+
+ xstream
+ xstream
+
+
+ xpp3
+ xpp3
+
+
+
+
+ groovy
+ groovy-all
+ 1.1-rc-1
+
+
+ com.google.guava
+ guava
+ 31.0.1-jre
+
+
+ junitperf
+ junitperf
+ 1.8
+ test
+
+
+
\ No newline at end of file
diff --git a/src/main/java/log4j.properties b/src/main/java/log4j.properties
new file mode 100644
index 0000000..d128b43
--- /dev/null
+++ b/src/main/java/log4j.properties
@@ -0,0 +1,9 @@
+log4j.rootLogger=WARN, A1
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+
+# Print the date in ISO 8601 format
+#log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+
+log4j.logger.org.radeox=WARN
diff --git a/src/main/java/org/radeox/EngineManager.java b/src/main/java/org/radeox/EngineManager.java
new file mode 100644
index 0000000..502cd37
--- /dev/null
+++ b/src/main/java/org/radeox/EngineManager.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.engine.BaseRenderEngine;
+import org.radeox.util.Service;
+
+/**
+ * Acess point to dock several different rendering engines into e.g. SnipSnap.
+ *
+ * SHOULD BE REMOVED. If this functionality is needed, it will be replaced by
+ * PicoContainer, Spring, ... (but kept for compatibility)
+ *
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: EngineManager.java,v 1.15 2004/05/26 08:56:20 stephan Exp $
+ */
+public class EngineManager
+{
+ private static final Log LOG = LogFactory.getLog(EngineManager.class);
+ private static final Map AVAILABLE_ENGINES = new HashMap<>();
+
+ private EngineManager()
+ {
+ // utility class
+ }
+
+ static
+ {
+ final Iterator iterator = Service.providers(RenderEngine.class);
+ while(iterator.hasNext())
+ {
+ try
+ {
+ final RenderEngine engine = iterator.next();
+ registerEngine(engine);
+ LOG.debug(
+ "Loaded RenderEngine: " + engine.getClass().getName());
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("EngineManager: unable to load RenderEngine", e);
+ }
+ }
+ }
+
+ /**
+ * Different RenderEngines can register themselves with the EngineManager
+ * factory to be available with EngineManager.getInstance();
+ *
+ * @param engine RenderEngine instance, e.g. SnipRenderEngine
+ */
+ public static synchronized void registerEngine(final RenderEngine engine)
+ {
+ AVAILABLE_ENGINES.put(engine.getName(), engine);
+ }
+
+ /**
+ * Get an instance of a RenderEngine. This is a factory method.
+ *
+ * @param name Name of the RenderEngine to get
+ * @return engine RenderEngine for the requested name
+ */
+ public static synchronized RenderEngine getInstance(final String name)
+ {
+ return AVAILABLE_ENGINES.get(name);
+ }
+
+ /**
+ * Get an instance of a RenderEngine. This is a factory method. Defaults to
+ * a default RenderEngine. Currently this is a basic EngineManager with no
+ * additional features that is distributed with Radeox.
+ *
+ * @return engine default RenderEngine
+ */
+ public static synchronized RenderEngine getInstance()
+ {
+ return AVAILABLE_ENGINES.computeIfAbsent(BaseRenderEngine.NAME,
+ f -> new BaseRenderEngine());
+ }
+
+ public static String getVersion()
+ {
+ return "0.5.1";
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/api/engine/ImageRenderEngine.java b/src/main/java/org/radeox/api/engine/ImageRenderEngine.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/api/engine/ImageRenderEngine.java
rename to src/main/java/org/radeox/api/engine/ImageRenderEngine.java
diff --git a/main/trunk/src/java/org/radeox/api/engine/IncludeRenderEngine.java b/src/main/java/org/radeox/api/engine/IncludeRenderEngine.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/api/engine/IncludeRenderEngine.java
rename to src/main/java/org/radeox/api/engine/IncludeRenderEngine.java
diff --git a/main/trunk/src/java/org/radeox/api/engine/RenderEngine.java b/src/main/java/org/radeox/api/engine/RenderEngine.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/api/engine/RenderEngine.java
rename to src/main/java/org/radeox/api/engine/RenderEngine.java
diff --git a/main/trunk/src/java/org/radeox/api/engine/WikiRenderEngine.java b/src/main/java/org/radeox/api/engine/WikiRenderEngine.java
similarity index 64%
rename from main/trunk/src/java/org/radeox/api/engine/WikiRenderEngine.java
rename to src/main/java/org/radeox/api/engine/WikiRenderEngine.java
index e30343c..7c24e46 100644
--- a/main/trunk/src/java/org/radeox/api/engine/WikiRenderEngine.java
+++ b/src/main/java/org/radeox/api/engine/WikiRenderEngine.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.radeox.api.engine;
/**
@@ -25,22 +24,22 @@
* @author Stephan J. Schmidt
* @version $Id: WikiRenderEngine.java,v 1.1 2003/10/07 08:20:24 stephan Exp $
*/
+public interface WikiRenderEngine
+{
+ /**
+ * Test for the existence of a wiki page.
+ *
+ * @param name Name of an Wiki Page
+ * @return result True if wiki page exists
+ */
+ public boolean exists(String name);
-public interface WikiRenderEngine {
- /**
- * Test for the existence of a wiki page
- *
- * @param name Name of an Wiki Page
- * @return result True if wiki page exists
- */
-
- public boolean exists(String name);
+ public boolean showCreate();
- public boolean showCreate();
+ public void appendLink(StringBuffer buffer, String name, String view, String anchor);
- public void appendLink(StringBuffer buffer, String name, String view, String anchor);
+ public void appendLink(StringBuffer buffer, String name, String view);
- public void appendLink(StringBuffer buffer, String name, String view);
+ public void appendCreateLink(StringBuffer buffer, String name, String view);
- public void appendCreateLink(StringBuffer buffer, String name, String view);
}
diff --git a/src/main/java/org/radeox/api/engine/context/InitialRenderContext.java b/src/main/java/org/radeox/api/engine/context/InitialRenderContext.java
new file mode 100644
index 0000000..6fb93c7
--- /dev/null
+++ b/src/main/java/org/radeox/api/engine/context/InitialRenderContext.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.api.engine.context;
+
+import java.util.Locale;
+
+import org.radeox.engine.context.BaseInitialRenderContextBuilder;
+import org.radeox.filter.FilterPipe;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * IntialRenderContext tells a Filter how to behave at initializiation. For
+ * example the Filter can read pattern locales for it's pattern matching.
+ *
+ * @author Stephan J. Schmidt
+ * @author Marcin Golebski
+ */
+public interface InitialRenderContext extends RenderContext
+{
+ public void setFilterPipe(FilterPipe fp);
+
+ public FilterPipe getFilterPipe();
+
+ /**
+ * Returns the name of the bundle of localized messages.
+ *
+ * @return name of the bundle
+ */
+ String getLanguageBuldleName();
+
+ Locale getInputLocale();
+
+ Locale getOutputLocale();
+
+ String getInputBundleName();
+
+ String getOutputBundleName();
+
+ BaseResourceBundle getBundle(Locale locale, String bundleName);
+
+ public static BaseInitialRenderContextBuilder builder()
+ {
+ return new BaseInitialRenderContextBuilder();
+ }
+
+ public static InitialRenderContext defaultContext()
+ {
+ return builder().build();
+ }
+
+}
diff --git a/src/main/java/org/radeox/api/engine/context/RenderContext.java b/src/main/java/org/radeox/api/engine/context/RenderContext.java
new file mode 100644
index 0000000..bc11206
--- /dev/null
+++ b/src/main/java/org/radeox/api/engine/context/RenderContext.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.api.engine.context;
+
+import java.util.Locale;
+import java.util.function.Function;
+
+import org.radeox.api.engine.RenderEngine;
+
+/**
+ * RenderContext stores basic data for the context the RenderEngine is called in.
+ *
+ * RenderContext can be used by the Engine in whatever way it likes to. The
+ * Radeox RenderEngine uses RenderContext to construct FilterContext.
+ *
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: RenderContext.java,v 1.2 2004/01/30 08:42:56 stephan Exp $
+ */
+public interface RenderContext
+{
+ /**
+ * Returns the RenderEngine handling this request.
+ *
+ * @return engine RenderEngine handling the request within this context
+ */
+ RenderEngine getRenderEngine();
+
+ /**
+ * Stores the current RenderEngine of the request.
+ *
+ * @param engine Current RenderEnginge
+ */
+ void setRenderEngine(RenderEngine engine);
+
+ Object get(String key);
+
+ Object computeIfAbsent(String key, Function mappingFunction);
+
+ void set(String key, Object value);
+
+ void setCacheable(boolean cacheable);
+
+ void commitCache();
+
+ boolean isCacheable();
+
+ Locale getLocale();
+
+ void setLocale(Locale locale);
+}
diff --git a/src/main/java/org/radeox/engine/BaseRenderEngine.java b/src/main/java/org/radeox/engine/BaseRenderEngine.java
new file mode 100644
index 0000000..487276c
--- /dev/null
+++ b/src/main/java/org/radeox/engine/BaseRenderEngine.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.engine;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.filter.Filter;
+import org.radeox.filter.FilterPipe;
+import org.radeox.filter.context.BaseFilterContext;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.util.Service;
+
+/**
+ * Base implementation of RenderEngine.
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: BaseRenderEngine.java,v 1.18 2004/05/26 08:56:20 stephan Exp $
+ */
+public class BaseRenderEngine implements RenderEngine
+{
+ public static final String NAME = "radeox";
+
+ private static final Log LOG = LogFactory.getLog(BaseRenderEngine.class);
+
+ protected InitialRenderContext initialContext;
+ protected FilterPipe fp;
+
+ public BaseRenderEngine(final InitialRenderContext context)
+ {
+ this.initialContext = context;
+ init();
+ initialContext.setFilterPipe(fp);
+ }
+
+ public BaseRenderEngine()
+ {
+ this(InitialRenderContext.defaultContext());
+ }
+
+ @Override
+ public InitialRenderContext getInitialRenderContext()
+ {
+ return initialContext;
+ }
+
+ private void init()
+ {
+ fp = new FilterPipe(initialContext);
+ final Iterator iterator = Service.providers(Filter.class);
+ while(iterator.hasNext())
+ {
+ try
+ {
+ final Filter filter = iterator.next();
+ fp.addFilter(filter);
+ LOG.debug("Loaded filter: " + filter.getClass().getName());
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("BaseRenderEngine: unable to load filter", e);
+ }
+ }
+ fp.init();
+ }
+
+ /**
+ * Name of the RenderEngine. This is used to get a RenderEngine instance
+ * with EngineManager.getInstance(name);
+ *
+ * @return name Name of the engine
+ */
+ @Override
+ public String getName()
+ {
+ return NAME;
+ }
+
+ /**
+ * Render an input with text markup and return a String with e.g. HTML
+ *
+ * @param content String with the input to render
+ * @param context Special context for the filter engine, e.g. with
+ * configuration information
+ * @return result Output with rendered content
+ */
+ @Override
+ public String render(final String content, final RenderContext context)
+ {
+ final FilterContext filterContext = new BaseFilterContext();
+ filterContext.setRenderContext(context);
+ return fp.filter(content, filterContext);
+ }
+
+ /**
+ * Render an input with text markup from a Reader and write the result to a
+ * writer.
+ *
+ * @param in Reader to read the input from
+ * @param context Special context for the render engine, e.g. with
+ * configuration information
+ */
+ @Override
+ public String render(final Reader in, final RenderContext context)
+ throws IOException
+ {
+ final StringBuilder buffer = new StringBuilder();
+ final BufferedReader inputReader = new BufferedReader(in);
+ String line;
+ while((line = inputReader.readLine()) != null)
+ {
+ buffer.append(line);
+ }
+ return render(buffer.toString(), context);
+ }
+
+ @Override
+ public void render(final Writer out, final String content,
+ final RenderContext context) throws IOException
+ {
+ out.write(render(content, context));
+ }
+
+}
diff --git a/src/main/java/org/radeox/engine/context/BaseInitialRenderContext.java b/src/main/java/org/radeox/engine/context/BaseInitialRenderContext.java
new file mode 100644
index 0000000..fe23c7b
--- /dev/null
+++ b/src/main/java/org/radeox/engine/context/BaseInitialRenderContext.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.engine.context;
+
+import java.util.Locale;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.filter.FilterPipe;
+import org.radeox.util.i18n.BaseResourceBundle;
+import org.radeox.util.i18n.ResourceManager;
+
+/**
+ * Base impementation for InitialRenderContext.
+ *
+ * @author Stephan J. Schmidt
+ * @author Marcin Golebski
+ * @version $Id: BaseInitialRenderContext.java,v 1.6 2004/04/27 19:30:38 leo Exp $
+ */
+public class BaseInitialRenderContext extends BaseRenderContext implements InitialRenderContext
+{
+ private final ConcurrentHashMap resourceManagers;
+
+ private final String languageBuldleName;
+ private final Locale inputLocale;
+ private final Locale outputLocale;
+ private final String inputBundleName;
+ private final String outputBundleName;
+
+ private FilterPipe fp;
+
+ BaseInitialRenderContext(final String languageBuldleName,
+ final Locale inputLocale, final Locale outputLocale,
+ final String inputBundleName, final String outputBundleName)
+ {
+ this.resourceManagers = new ConcurrentHashMap<>();
+ this.languageBuldleName = languageBuldleName;
+ this.inputLocale = inputLocale;
+ this.outputLocale = outputLocale;
+ this.inputBundleName = inputBundleName;
+ this.outputBundleName = outputBundleName;
+ }
+
+ @Override
+ public void setFilterPipe(final FilterPipe fp)
+ {
+ this.fp = fp;
+ }
+
+ @Override
+ public FilterPipe getFilterPipe()
+ {
+ return fp;
+ }
+
+ @Override
+ public String getLanguageBuldleName()
+ {
+ return languageBuldleName;
+ }
+
+ @Override
+ public Locale getInputLocale()
+ {
+ return inputLocale;
+ }
+
+ @Override
+ public Locale getOutputLocale()
+ {
+ return outputLocale;
+ }
+
+ @Override
+ public String getInputBundleName()
+ {
+ return inputBundleName;
+ }
+
+ @Override
+ public String getOutputBundleName()
+ {
+ return outputBundleName;
+ }
+
+ /**
+ * Get a new thread-local instance of the ResourceManager If you are having
+ * problems with bundles beeing the same for different threads and locales,
+ * try forceGet()
+ *
+ * @return the thread-local ResourceManager
+ */
+ private ResourceManager get(final Locale locale)
+ {
+ return resourceManagers.computeIfAbsent(locale, ResourceManager::new);
+ }
+
+ /**
+ * Get ResourceBundle using the base name provided. The bundle is located
+ * using previously given locale settings.
+ *
+ * @param baseName the bundle base name
+ * @return the bundle
+ */
+ @Override
+ public BaseResourceBundle getBundle(final Locale locale, final String baseName)
+ {
+ return get(locale).getResourceBundle(baseName);
+ }
+
+}
diff --git a/src/main/java/org/radeox/engine/context/BaseInitialRenderContextBuilder.java b/src/main/java/org/radeox/engine/context/BaseInitialRenderContextBuilder.java
new file mode 100644
index 0000000..ebd791a
--- /dev/null
+++ b/src/main/java/org/radeox/engine/context/BaseInitialRenderContextBuilder.java
@@ -0,0 +1,68 @@
+package org.radeox.engine.context;
+
+import java.util.Locale;
+
+/**
+ * Builder for {@link BaseInitialRenderContext}.
+ *
+ *
Created on 2025-06-02
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class BaseInitialRenderContextBuilder
+{
+ private static final Locale BASIC_LOCALE = new Locale("Basic", "basic");
+
+ private String languageBuldleName = "radeox_messages";
+ private Locale inputLocale;
+ private Locale outputLocale;
+ private String inputBundleName;
+ private String outputBundleName;
+
+ public BaseInitialRenderContextBuilder()
+ {
+ this.languageBuldleName = "radeox_messages";
+ this.inputLocale = BASIC_LOCALE;
+ this.outputLocale = BASIC_LOCALE;
+ this.inputBundleName = "radeox_markup";
+ this.outputBundleName = "radeox_markup";
+ }
+
+ public BaseInitialRenderContextBuilder setLanguageBuldleName(final String languageBuldleName)
+ {
+ this.languageBuldleName = languageBuldleName;
+ return this;
+ }
+
+ public BaseInitialRenderContextBuilder setInputLocale(final Locale inputLocale)
+ {
+ this.inputLocale = inputLocale;
+ return this;
+ }
+
+ public BaseInitialRenderContextBuilder setOutputLocale(final Locale outputLocale)
+ {
+ this.outputLocale = outputLocale;
+ return this;
+ }
+
+ public BaseInitialRenderContextBuilder setInputBundleName(final String inputBundleName)
+ {
+ this.inputBundleName = inputBundleName;
+ return this;
+ }
+
+ public BaseInitialRenderContextBuilder setOutputBundleName(final String outputBundleName)
+ {
+ this.outputBundleName = outputBundleName;
+ return this;
+ }
+
+ public BaseInitialRenderContext build()
+ {
+ return new BaseInitialRenderContext(languageBuldleName, inputLocale,
+ outputLocale, inputBundleName, outputBundleName);
+ }
+
+}
diff --git a/src/main/java/org/radeox/engine/context/BaseRenderContext.java b/src/main/java/org/radeox/engine/context/BaseRenderContext.java
new file mode 100644
index 0000000..7e8eeb1
--- /dev/null
+++ b/src/main/java/org/radeox/engine/context/BaseRenderContext.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.engine.context;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.function.Function;
+
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.RenderContext;
+
+/**
+ * Base impementation for RenderContext.
+ *
+ * @author Stephan J. Schmidt
+ * @author Marcin Golebski
+ * @version $Id: BaseRenderContext.java,v 1.8 2003/10/07 08:20:24 stephan Exp $
+ */
+public class BaseRenderContext implements RenderContext
+{
+ private Locale locale;
+
+ private boolean cacheable = true;
+ private boolean tempCacheable = false;
+
+ private RenderEngine engine;
+ private final Map values;
+
+ /**
+ * Single render context constructor with default locale.
+ *
+ * @see Locale#getDefault()
+ */
+ public BaseRenderContext()
+ {
+ this(Locale.getDefault());
+ }
+
+ /**
+ * Single render context constructor.
+ *
+ * @param locale render locale
+ */
+ public BaseRenderContext(final Locale locale)
+ {
+ this.locale = locale;
+ this.values = new HashMap<>();
+ }
+
+ @Override
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public void setLocale(final Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ @Override
+ public Object get(final String key)
+ {
+ return values.get(key);
+ }
+
+ @Override
+ public Object computeIfAbsent(final String key, final Function mappingFunction)
+ {
+ return values.computeIfAbsent(key, mappingFunction);
+ }
+
+ @Override
+ public void set(final String key, final Object value)
+ {
+ values.put(key, value);
+ }
+
+ @Override
+ public RenderEngine getRenderEngine()
+ {
+ return engine;
+ }
+
+ @Override
+ public void setRenderEngine(final RenderEngine engine)
+ {
+ this.engine = engine;
+ }
+
+ @Override
+ public void setCacheable(final boolean cacheable)
+ {
+ tempCacheable = cacheable;
+ }
+
+ @Override
+ public void commitCache()
+ {
+ cacheable = cacheable && tempCacheable;
+ tempCacheable = false;
+ }
+
+ @Override
+ public boolean isCacheable()
+ {
+ return cacheable;
+ }
+
+}
diff --git a/src/main/java/org/radeox/example/InteractiveExample.java b/src/main/java/org/radeox/example/InteractiveExample.java
new file mode 100644
index 0000000..593f5df
--- /dev/null
+++ b/src/main/java/org/radeox/example/InteractiveExample.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.example;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.engine.BaseRenderEngine;
+import org.radeox.engine.context.BaseRenderContext;
+
+/**
+ * Interactive example how to use EngineManager.
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: InteractiveExample.java,v 1.8 2004/05/26 08:56:20 stephan Exp $
+ */
+public class InteractiveExample
+{
+ private static DateFormat perfFormat = new SimpleDateFormat("m'm's's'S'ms'");
+
+ public static void main(final String[] args)
+ {
+ System.err.println("Radeox");
+ System.err.println("Copyright 2001-2004 Fraunhofer FIRST.");
+ System.err.println("See License Agreement for terms and conditions of use.");
+
+ final RenderEngine engine = new BaseRenderEngine();
+ final RenderContext context = new BaseRenderContext();
+
+ if(args.length > 0)
+ {
+ final File inputFile = new File(args[0]);
+ if(inputFile.exists())
+ {
+ batch(engine, context, inputFile);
+ }
+ else
+ {
+ System.err.println("The file '" + args[0] + "' does not exist.");
+ }
+ }
+ else
+ {
+ interactive(engine, context);
+ }
+
+ }
+
+ private static void batch(final RenderEngine engine,
+ final RenderContext context, final File inputFile)
+ {
+ final StringBuilder input = new StringBuilder();
+ try(final BufferedReader reader = new BufferedReader(new FileReader(inputFile)))
+ {
+ final char buffer[] = new char[4096];
+ int length = 0;
+ while((length = reader.read(buffer)) != -1)
+ {
+ input.append(buffer, 0, length);
+ }
+ }
+ catch(final IOException e)
+ {
+ e.printStackTrace();
+ return;
+ }
+ render(engine, context, input.toString());
+ }
+
+ private static void interactive(final RenderEngine engine,
+ final RenderContext context)
+ {
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(System.in));
+ String line;
+ try
+ {
+ System.out.print("> ");
+ System.out.flush();
+ while((line = reader.readLine()) != null)
+ {
+ render(engine, context, line);
+ System.out.print("> ");
+ System.out.flush();
+ }
+ }
+ catch(final IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private static void render(final RenderEngine engine,
+ final RenderContext context, final String input)
+ {
+ final long start = System.currentTimeMillis();
+ final String result = engine.render(input, context);
+ final long length = System.currentTimeMillis() - start;
+ System.out.println(result);
+ System.out.println("rendered in " + perfFormat.format(new Date(length)));
+ }
+
+}
diff --git a/src/main/java/org/radeox/example/PicoExample.java b/src/main/java/org/radeox/example/PicoExample.java
new file mode 100644
index 0000000..fe5d4ca
--- /dev/null
+++ b/src/main/java/org/radeox/example/PicoExample.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.example;
+
+import java.util.Locale;
+
+import org.picocontainer.PicoContainer;
+import org.picocontainer.defaults.DefaultPicoContainer;
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.engine.BaseRenderEngine;
+import org.radeox.engine.context.BaseRenderContext;
+
+/**
+ * Example how to use BaseRenderEngine with Pico.
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: PicoExample.java,v 1.3 2003/12/16 10:26:51 leo Exp $
+ */
+public class PicoExample
+{
+ public static void main(final String[] args)
+ {
+ final String test = "==SnipSnap== {link:Radeox|http://radeox.org}";
+
+ final DefaultPicoContainer c = new org.picocontainer.defaults.DefaultPicoContainer();
+ try
+ {
+ final InitialRenderContext initialContext = InitialRenderContext.builder()
+ .setInputLocale(new Locale("otherwiki", ""))
+ .build();
+ c.registerComponentInstance(InitialRenderContext.class,
+ initialContext);
+ c.registerComponentImplementation(RenderEngine.class,
+ BaseRenderEngine.class);
+ c.getComponentInstances();
+ }
+ catch(final Exception e)
+ {
+ System.err.println("Could not register component: " + e);
+ }
+
+ final PicoContainer container = c;
+
+ // no only work with container
+
+ // Only ask for RenderEngine, we automatically get an object
+ // that implements RenderEngine
+ final RenderEngine engine = (RenderEngine) container
+ .getComponentInstance(RenderEngine.class);
+ final RenderContext context = new BaseRenderContext();
+ System.out.println(engine.render(test, context));
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/example/RadeoxTemplateEngine.java b/src/main/java/org/radeox/example/RadeoxTemplateEngine.java
similarity index 67%
rename from main/trunk/src/java/org/radeox/example/RadeoxTemplateEngine.java
rename to src/main/java/org/radeox/example/RadeoxTemplateEngine.java
index 5eb7bf8..6bc28a0 100644
--- a/main/trunk/src/java/org/radeox/example/RadeoxTemplateEngine.java
+++ b/src/main/java/org/radeox/example/RadeoxTemplateEngine.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,34 +18,38 @@
package org.radeox.example;
-import groovy.text.SimpleTemplateEngine;
-import groovy.text.Template;
-import groovy.text.TemplateEngine;
-import org.codehaus.groovy.syntax.SyntaxException;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.codehaus.groovy.control.CompilationFailedException;
import org.radeox.api.engine.RenderEngine;
import org.radeox.api.engine.context.RenderContext;
import org.radeox.engine.BaseRenderEngine;
import org.radeox.engine.context.BaseRenderContext;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
+import groovy.text.SimpleTemplateEngine;
+import groovy.text.Template;
+import groovy.text.TemplateEngine;
/**
- * Groovy Template Engine which uses Radeox to render text markup
+ * Groovy Template Engine which uses Radeox to render text markup.
*
* @author Stephan J. Schmidt
* @version $Id: RadeoxTemplateEngine.java,v 1.1 2004/04/14 13:03:49 stephan Exp $
*/
+public class RadeoxTemplateEngine extends TemplateEngine
+{
+ @Override
+ public Template createTemplate(final Reader reader)
+ throws CompilationFailedException, ClassNotFoundException, IOException
+ {
+ final RenderContext context = new BaseRenderContext();
+ final RenderEngine engine = new BaseRenderEngine();
+ final String renderedText = engine.render(reader, context);
-public class RadeoxTemplateEngine extends TemplateEngine {
- public Template createTemplate(Reader reader) throws SyntaxException, ClassNotFoundException, IOException {
- RenderContext context = new BaseRenderContext();
- RenderEngine engine = new BaseRenderEngine();
- String renderedText = engine.render(reader , context);
+ final TemplateEngine templateEngine = new SimpleTemplateEngine();
+ return templateEngine.createTemplate(new StringReader(renderedText));
+ }
- TemplateEngine templateEngine = new SimpleTemplateEngine();
- return templateEngine.createTemplate(new StringReader(renderedText));
- }
}
diff --git a/main/trunk/src/java/org/radeox/example/RenderEngineExample.java b/src/main/java/org/radeox/example/RenderEngineExample.java
similarity index 57%
rename from main/trunk/src/java/org/radeox/example/RenderEngineExample.java
rename to src/main/java/org/radeox/example/RenderEngineExample.java
index 2b86060..2c737db 100644
--- a/main/trunk/src/java/org/radeox/example/RenderEngineExample.java
+++ b/src/main/java/org/radeox/example/RenderEngineExample.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,38 +16,40 @@
* limitations under the License.
*/
-
package org.radeox.example;
-import org.radeox.engine.context.BaseRenderContext;
-import org.radeox.api.engine.context.RenderContext;
-import org.radeox.api.engine.context.InitialRenderContext;
-import org.radeox.engine.context.BaseInitialRenderContext;
+import java.util.Locale;
+
import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.api.engine.context.RenderContext;
import org.radeox.engine.BaseRenderEngine;
+import org.radeox.engine.context.BaseRenderContext;
-import java.util.Locale;
-
-/*
- * Example how to use BaseRenderEngine
+/**
+ * Example how to use BaseRenderEngine.
*
* @author Stephan J. Schmidt
* @version $Id: RenderEngineExample.java,v 1.8 2003/10/07 08:20:24 stephan Exp $
*/
+public class RenderEngineExample
+{
+ public static void main(final String[] args)
+ {
+ final String test = "__SnipSnap__ {link:Radeox|http://radeox.org} ==Other Bold==";
+
+ final RenderContext context = new BaseRenderContext();
+ final RenderEngine engine = new BaseRenderEngine();
+ System.out.println("Rendering with default:");
+ System.out.println(engine.render(test, context));
+
+ System.out.println("Rendering with alternative Wiki:");
+ final InitialRenderContext initialContext = InitialRenderContext.builder()
+ .setInputLocale(new Locale("otherwiki", ""))
+ .build();
+ final RenderEngine engineWithContext = new BaseRenderEngine(
+ initialContext);
+ System.out.println(engineWithContext.render(test, context));
+ }
-public class RenderEngineExample {
- public static void main(String[] args) {
- String test = "__SnipSnap__ {link:Radeox|http://radeox.org} ==Other Bold==";
-
- RenderContext context = new BaseRenderContext();
- RenderEngine engine = new BaseRenderEngine();
- System.out.println("Rendering with default:");
- System.out.println(engine.render(test, context));
-
- System.out.println("Rendering with alternative Wiki:");
- InitialRenderContext initialContext = new BaseInitialRenderContext();
- initialContext.set(RenderContext.INPUT_LOCALE, new Locale("otherwiki", ""));
- RenderEngine engineWithContext = new BaseRenderEngine(initialContext);
- System.out.println(engineWithContext.render(test, context));
- }
}
diff --git a/main/trunk/src/java/org/radeox/example/XSLTExtension.java b/src/main/java/org/radeox/example/XSLTExtension.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/example/XSLTExtension.java
rename to src/main/java/org/radeox/example/XSLTExtension.java
diff --git a/src/main/java/org/radeox/filter/AbstractParamFilter.java b/src/main/java/org/radeox/filter/AbstractParamFilter.java
new file mode 100644
index 0000000..727ffca
--- /dev/null
+++ b/src/main/java/org/radeox/filter/AbstractParamFilter.java
@@ -0,0 +1,53 @@
+package org.radeox.filter;
+
+import org.radeox.filter.context.FilterContext;
+import org.radeox.filter.context.ParamContext;
+import org.radeox.filter.regex.LocaleRegexTokenFilter;
+import org.radeox.regex.MatchResult;
+
+/**
+ * Base class for parameter filters.
+ *
+ *
Created on 2025-05-28
+ *
+ * @author stephan
+ * @team sonicteam
+ * @author Marcin Golebski
+ * @see ParamContext
+ */
+public abstract class AbstractParamFilter extends LocaleRegexTokenFilter
+{
+ @Override
+ public void handleMatch(final StringBuffer buffer, final MatchResult result,
+ final FilterContext context)
+ {
+ final ParamContext param = ParamContext.get(context.getRenderContext());
+ final String name = result.group(1);
+ if(param != null)
+ {
+ final Object value = param.get(name);
+ if(value != null)
+ {
+ if(value instanceof String[])
+ {
+ buffer.append(((String[]) value)[0]);
+ }
+ else
+ {
+ buffer.append(value);
+ }
+ return;
+ }
+ }
+ appendEmptyValue(buffer, name);
+ }
+
+ @Override
+ protected boolean isSingleLine()
+ {
+ return true;
+ }
+
+ abstract void appendEmptyValue(final StringBuffer buffer, String name);
+
+}
diff --git a/main/trunk/src/java/org/radeox/filter/BoldFilter.java b/src/main/java/org/radeox/filter/BoldFilter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/BoldFilter.java
rename to src/main/java/org/radeox/filter/BoldFilter.java
diff --git a/main/trunk/src/java/org/radeox/filter/CacheFilter.java b/src/main/java/org/radeox/filter/CacheFilter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/CacheFilter.java
rename to src/main/java/org/radeox/filter/CacheFilter.java
diff --git a/main/trunk/src/java/org/radeox/filter/EscapeFilter.java b/src/main/java/org/radeox/filter/EscapeFilter.java
similarity index 57%
rename from main/trunk/src/java/org/radeox/filter/EscapeFilter.java
rename to src/main/java/org/radeox/filter/EscapeFilter.java
index 8576b42..09a70c9 100644
--- a/main/trunk/src/java/org/radeox/filter/EscapeFilter.java
+++ b/src/main/java/org/radeox/filter/EscapeFilter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.radeox.filter;
import org.radeox.filter.context.FilterContext;
@@ -24,40 +23,53 @@
import org.radeox.regex.MatchResult;
import org.radeox.util.Encoder;
-/*
+/**
* Transforms multiple \ into single backspaces and escapes other characters.
*
* @author leo
* @team other
* @version $Id: EscapeFilter.java,v 1.13 2004/04/15 13:56:14 stephan Exp $
*/
+public class EscapeFilter extends LocaleRegexTokenFilter implements CacheFilter
+{
+ @Override
+ protected String getLocaleKey()
+ {
+ return "filter.escape";
+ }
-public class EscapeFilter extends LocaleRegexTokenFilter implements CacheFilter {
- protected String getLocaleKey() {
- return "filter.escape";
- }
+ @Override
+ public void handleMatch(final StringBuffer buffer, final MatchResult result,
+ final FilterContext context)
+ {
+ buffer.append(handleMatch(result));
+ }
- public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context) {
- buffer.append(handleMatch(result, context));
- }
+ private String handleMatch(final MatchResult result)
+ {
+ if(result.group(1) == null)
+ {
+ String match = result.group(2);
+ if(match == null)
+ {
+ match = result.group(3);
+ }
+ if("\\".equals(match))
+ {
+ return "\\\\";
+ }
+ return Encoder.toEntity(match.charAt(0));
+ }
+ else
+ {
+ return "\";
+ }
+ }
- public String handleMatch(MatchResult result, FilterContext context) {
- if (result.group(1) == null) {
- String match = result.group(2);
- if (match == null) {
- match = result.group(3);
- }
- if ("\\".equals(match)) {
- return "\\\\";
- }
- return Encoder.toEntity(match.charAt(0));
- } else {
- return "\";
+ @Override
+ public String[] before()
+ {
+ return FilterPipe.FIRST_BEFORE;
}
- }
- public String[] before() {
- //return new String[]{ "BoldFilter.class", "BoingFilter.class" };
- return FilterPipe.FIRST_BEFORE;
- }
}
diff --git a/main/trunk/src/java/org/radeox/filter/Filter.java b/src/main/java/org/radeox/filter/Filter.java
similarity index 54%
rename from main/trunk/src/java/org/radeox/filter/Filter.java
rename to src/main/java/org/radeox/filter/Filter.java
index 404dfe1..93afe88 100644
--- a/main/trunk/src/java/org/radeox/filter/Filter.java
+++ b/src/main/java/org/radeox/filter/Filter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,30 +16,42 @@
* limitations under the License.
*/
-
package org.radeox.filter;
import org.radeox.api.engine.context.InitialRenderContext;
import org.radeox.filter.context.FilterContext;
-/*
- * Filter interface. Concrete Filters should
- * implement Filter. Filters transform a
- * String (usually snip content) to another String
- * (usually HTML).
+
+/**
+ * Filter interface. Concrete Filters should implement Filter. Filters transform
+ * a String (usually snip content) to another String (usually HTML).
*
* @author stephan
* @team sonicteam
* @version $Id: Filter.java,v 1.10 2003/10/07 08:20:24 stephan Exp $
*/
-
-public interface Filter {
- public String filter(String input, FilterContext context);
-
- public String[] replaces();
-
- public String[] before();
-
- public void setInitialContext(InitialRenderContext context);
-
- public String getDescription();
-}
\ No newline at end of file
+public interface Filter
+{
+ public String filter(String input, FilterContext context);
+
+ /**
+ * Returns classes which this filter should be run insted.
+ *
+ * @return names of the classes ({@link java.lang.Class#getName()})
+ */
+ public String[] replaces();
+
+ /**
+ * Returns array of filter class names which this filter shoud precede.
+ *
+ * @return array of class names or special arrays
+ * @see FilterPipe#FIRST_IN_PIPE
+ * @see FilterPipe#EMPTY_BEFORE
+ * @see FilterPipe#NO_REPLACES
+ */
+ public String[] before();
+
+ public void setInitialContext(InitialRenderContext context);
+
+ public String getDescription();
+
+}
diff --git a/src/main/java/org/radeox/filter/FilterPipe.java b/src/main/java/org/radeox/filter/FilterPipe.java
new file mode 100644
index 0000000..29ecc13
--- /dev/null
+++ b/src/main/java/org/radeox/filter/FilterPipe.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.filter.context.FilterContext;
+
+/**
+ * FilterPipe is a collection of Filters which are applied one by one to an
+ * input to generate output.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: FilterPipe.java,v 1.21 2004/06/21 13:08:43 leo Exp $
+ */
+public class FilterPipe
+{
+ private static Log log = LogFactory.getLog(FilterPipe.class);
+
+ public static final String FIRST_IN_PIPE = "all";
+ public static final String LAST_IN_PIPE = "none";
+ public static final String[] EMPTY_BEFORE = new String[] {};
+ public static final String[] NO_REPLACES = new String[] {};
+ public static final String[] FIRST_BEFORE = new String[] {FIRST_IN_PIPE};
+
+ private final InitialRenderContext initialContext;
+
+ private List activeFilters = null;
+ private Set inactiveFilters = null;
+
+ public FilterPipe()
+ {
+ this(InitialRenderContext.defaultContext());
+ }
+
+ public FilterPipe(final InitialRenderContext context)
+ {
+ activeFilters = new ArrayList<>();
+ inactiveFilters = new HashSet<>();
+ initialContext = context;
+ }
+
+ public void init()
+ {
+ // loop over copy of activeFilters becouse of #removeFilter()
+ for(final Filter filter : new ArrayList<>(activeFilters))
+ {
+ final String[] replaces = filter.replaces();
+ for(int i = 0; i < replaces.length; i++)
+ {
+ final String replace = replaces[i];
+ removeFilter(replace);
+ }
+ }
+ }
+
+ public void removeFilter(final String filterClass)
+ {
+ final Iterator iterator = activeFilters.iterator();
+ while(iterator.hasNext())
+ {
+ final Filter filter = iterator.next();
+ if(filter.getClass().getName().equals(filterClass))
+ {
+ iterator.remove();
+ }
+ }
+ }
+
+ public void activateFilter(final String name)
+ {
+ synchronized(inactiveFilters)
+ {
+ final Iterator iterator = inactiveFilters.iterator();
+ while(iterator.hasNext())
+ {
+ final Filter filter = iterator.next();
+ if(filter.getClass().getName().startsWith(name))
+ {
+ inactiveFilters.remove(filter);
+ }
+ }
+ }
+ }
+
+ public void deactivateFilter(final String name)
+ {
+ final Iterator iterator = activeFilters.iterator();
+ while(iterator.hasNext())
+ {
+ final Filter filter = iterator.next();
+ if(filter.getClass().getName().startsWith(name))
+ {
+ inactiveFilters.add(filter);
+ }
+ }
+ }
+
+ public List getAllFilters()
+ {
+ return new ArrayList<>(activeFilters);
+ }
+
+ public List getInactiveFilters()
+ {
+ return new ArrayList<>(inactiveFilters);
+ }
+
+ /**
+ * Add a filter to the active pipe.
+ *
+ * @param filter filter to add
+ */
+ public void addFilter(final Filter filter)
+ {
+ filter.setInitialContext(initialContext);
+
+ int minIndex = Integer.MAX_VALUE;
+ final String[] before = filter.before();
+ for(int i = 0; i < before.length; i++)
+ {
+ final String s = before[i];
+ final int index = index(activeFilters, s);
+ if(index < minIndex)
+ {
+ minIndex = index;
+ }
+ }
+ if(minIndex == Integer.MAX_VALUE)
+ {
+ // -1 is more usable for not-found than MAX_VALUE
+ minIndex = -1;
+ }
+
+ if(contains(filter.before(), FIRST_IN_PIPE))
+ {
+ activeFilters.add(0, filter);
+ }
+ else if(minIndex != -1)
+ {
+ activeFilters.add(minIndex, filter);
+ }
+ else
+ {
+ activeFilters.add(filter);
+ }
+ }
+
+ public int index(final String filterName)
+ {
+ return FilterPipe.index(activeFilters, filterName);
+ }
+
+ public static int index(final List> list, final String filterName)
+ {
+ for(int i = 0; i < list.size(); i++)
+ {
+ if(filterName.equals(list.get(i).getClass().getName()))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public static boolean contains(final Object[] array, final Object value)
+ {
+ return (Arrays.binarySearch(array, value) != -1);
+ }
+
+ /**
+ * Filter some input and generate ouput. FilterPipe pipes the string input
+ * through every filter in the pipe and returns the resulting string.
+ *
+ * @param input Input string which should be transformed
+ * @param context FilterContext with information about the enviroment
+ * @return result Filtered output
+ */
+ public String filter(final String input, final FilterContext context)
+ {
+ String output = input;
+ final Iterator filterIterator = activeFilters.iterator();
+ final RenderContext renderContext = context.getRenderContext();
+
+ // Apply every filter in activeFilters to input string
+ while(filterIterator.hasNext())
+ {
+ final Filter f = filterIterator.next();
+ if(!inactiveFilters.contains(f))
+ {
+ try
+ {
+ // assume all filters non cacheable
+ if(f instanceof CacheFilter)
+ {
+ renderContext.setCacheable(true);
+ }
+ else
+ {
+ renderContext.setCacheable(false);
+ }
+ final String tmp = f.filter(output, context);
+ if(output.equals(tmp))
+ {
+ renderContext.setCacheable(true);
+ }
+ if(null == tmp)
+ {
+ log.warn("FilterPipe.filter: error while filtering: " + f);
+ }
+ else
+ {
+ output = tmp;
+ }
+ renderContext.commitCache();
+ }
+ catch(final Exception e)
+ {
+ log.warn("Filtering exception: " + f, e);
+ }
+ }
+ }
+ return output;
+ }
+
+ public Filter getFilter(final int index)
+ {
+ return activeFilters.get(index);
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/filter/FilterSupport.java b/src/main/java/org/radeox/filter/FilterSupport.java
similarity index 56%
rename from main/trunk/src/java/org/radeox/filter/FilterSupport.java
rename to src/main/java/org/radeox/filter/FilterSupport.java
index e56d942..dd88ef5 100644
--- a/main/trunk/src/java/org/radeox/filter/FilterSupport.java
+++ b/src/main/java/org/radeox/filter/FilterSupport.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,42 +16,47 @@
* limitations under the License.
*/
-
package org.radeox.filter;
import org.radeox.api.engine.context.InitialRenderContext;
-/*
- * Abstract Filter Class that supplies the
- * Filter interface. Concrete Filters should
- * inherit from Filter. Filters transform a
- * String (usually snip content) to another String
- * (usually HTML).
+/**
+ * Abstract Filter Class that supplies the Filter interface.
+ *
+ * Concrete Filters should inherit from Filter. Filters transform a String
+ * (usually snip content) to another String (usually HTML).
+ *
*
* @author stephan
* @team sonicteam
* @version $Id: FilterSupport.java,v 1.9 2003/10/07 08:20:24 stephan Exp $
*/
-
-public abstract class FilterSupport implements Filter {
- protected InitialRenderContext initialContext;
-
- public FilterSupport() {
- }
-
- public String[] replaces() {
- return FilterPipe.NO_REPLACES;
- }
-
- public String[] before() {
- return FilterPipe.EMPTY_BEFORE;
- }
-
- public void setInitialContext(InitialRenderContext context) {
- this.initialContext = context;
- }
-
- public String getDescription() {
- return "";
- }
-}
\ No newline at end of file
+public abstract class FilterSupport implements Filter
+{
+ protected InitialRenderContext initialContext;
+
+ @Override
+ public String[] replaces()
+ {
+ return FilterPipe.NO_REPLACES;
+ }
+
+ @Override
+ public String[] before()
+ {
+ return FilterPipe.EMPTY_BEFORE;
+ }
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ this.initialContext = context;
+ }
+
+ @Override
+ public String getDescription()
+ {
+ return "";
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/filter/HeadingFilter.java b/src/main/java/org/radeox/filter/HeadingFilter.java
similarity index 56%
rename from main/trunk/src/java/org/radeox/filter/HeadingFilter.java
rename to src/main/java/org/radeox/filter/HeadingFilter.java
index 38caee8..d07b4e8 100644
--- a/main/trunk/src/java/org/radeox/filter/HeadingFilter.java
+++ b/src/main/java/org/radeox/filter/HeadingFilter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,50 +16,57 @@
* limitations under the License.
*/
-
package org.radeox.filter;
+import java.text.MessageFormat;
+
import org.radeox.api.engine.context.InitialRenderContext;
import org.radeox.filter.context.FilterContext;
import org.radeox.filter.regex.LocaleRegexTokenFilter;
import org.radeox.regex.MatchResult;
-import java.text.MessageFormat;
-
-/*
+/**
* Transforms header style lines into subsections. A header starts with a 1 for
* first level headers and 1.1 for secend level headers. Headers are
- * numbered automatically
+ * numbered automatically.
*
* @author leo
* @team other
* @version $Id: HeadingFilter.java,v 1.8 2004/04/15 13:56:14 stephan Exp $
*/
+public class HeadingFilter extends LocaleRegexTokenFilter implements CacheFilter
+{
+ private MessageFormat formatter;
-public class HeadingFilter extends LocaleRegexTokenFilter implements CacheFilter {
- private MessageFormat formatter;
-
+ @Override
+ protected String getLocaleKey()
+ {
+ return "filter.heading";
+ }
- protected String getLocaleKey() {
- return "filter.heading";
- }
+ @Override
+ public void handleMatch(final StringBuffer buffer,
+ final MatchResult result, final FilterContext context)
+ {
+ buffer.append(handleMatch(result));
+ }
- public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context) {
- buffer.append(handleMatch(result, context));
- }
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ super.setInitialContext(context);
+ final String outputTemplate = outputMessages.get(getLocaleKey() + ".print");
+ formatter = new MessageFormat("");
+ formatter.applyPattern(outputTemplate);
+ }
- public void setInitialContext(InitialRenderContext context) {
- super.setInitialContext(context);
- String outputTemplate = outputMessages.getString(getLocaleKey() + ".print");
- formatter = new MessageFormat("");
- formatter.applyPattern(outputTemplate);
- }
+ private String handleMatch(final MatchResult result)
+ {
+ String match = result.group(1);
+ match = match.replaceAll("\\.", "");
+ match = match.replaceAll(".", "1-");
+ match = match.substring(0, match.length() - 1);
+ return formatter.format(new Object[] {match, result.group(3)});
+ }
- public String handleMatch(MatchResult result, FilterContext context) {
- String match = result.group(1);
- match = match.replaceAll("\\.", "");
- match = match.replaceAll(".", "1-");
- match = match.substring(0, match.length() - 1);
- return formatter.format(new Object[]{match, result.group(3)});
- }
}
diff --git a/main/trunk/src/java/org/radeox/filter/HtmlRemoveFilter.java b/src/main/java/org/radeox/filter/HtmlRemoveFilter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/HtmlRemoveFilter.java
rename to src/main/java/org/radeox/filter/HtmlRemoveFilter.java
diff --git a/main/trunk/src/java/org/radeox/filter/ItalicFilter.java b/src/main/java/org/radeox/filter/ItalicFilter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/ItalicFilter.java
rename to src/main/java/org/radeox/filter/ItalicFilter.java
diff --git a/main/trunk/src/java/org/radeox/filter/KeyFilter.java b/src/main/java/org/radeox/filter/KeyFilter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/KeyFilter.java
rename to src/main/java/org/radeox/filter/KeyFilter.java
diff --git a/main/trunk/src/java/org/radeox/filter/LineFilter.java b/src/main/java/org/radeox/filter/LineFilter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/LineFilter.java
rename to src/main/java/org/radeox/filter/LineFilter.java
diff --git a/src/main/java/org/radeox/filter/LinkTestFilter.java b/src/main/java/org/radeox/filter/LinkTestFilter.java
new file mode 100644
index 0000000..ec25df5
--- /dev/null
+++ b/src/main/java/org/radeox/filter/LinkTestFilter.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.WikiRenderEngine;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.filter.interwiki.InterWiki;
+import org.radeox.filter.regex.LocaleRegexTokenFilter;
+import org.radeox.regex.MatchResult;
+import org.radeox.util.Encoder;
+import org.radeox.util.StringBufferWriter;
+
+/**
+ * LinkTestFilter finds [text] in its input and transforms this
+ * to ... if the wiki page exists. If not
+ * it adds a [create text] to the output.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: LinkTestFilter.java,v 1.15 2004/04/15 13:56:14 stephan Exp $
+ */
+public class LinkTestFilter extends LocaleRegexTokenFilter
+{
+ private static final Log LOG = LogFactory.getLog(LinkTestFilter.class);
+
+ /**
+ * The regular expression for detecting WikiLinks. Overwrite in subclass to
+ * support other link styles like OldAndUglyWikiLinking :-)
+ *
+ * /[A-Z][a-z]+([A-Z][a-z]+)+/ wikiPattern = "\\[(.*?)\\]";
+ */
+
+ @Override
+ protected String getLocaleKey()
+ {
+ return "filter.linktest";
+ }
+
+ @Override
+ protected void setUp(final FilterContext context)
+ {
+ context.getRenderContext().setCacheable(true);
+ }
+
+ @Override
+ public void handleMatch(final StringBuffer buffer,
+ final MatchResult result, final FilterContext context)
+ {
+ final RenderEngine engine = context.getRenderContext()
+ .getRenderEngine();
+
+ if(engine instanceof WikiRenderEngine)
+ {
+ final WikiRenderEngine wikiEngine = (WikiRenderEngine) engine;
+ final Writer writer = new StringBufferWriter(buffer);
+
+ String name = result.group(1);
+ if(name != null)
+ {
+ // User probably wrote [http://radeox.org] instead of
+ // http://radeox.org
+ if(name.indexOf("http://") != -1)
+ {
+ try
+ {
+ writer.write(
+ "
Do not surround URLs with [...].
");
+ }
+ catch(final IOException e)
+ {
+ // Do nothing. Give up.
+ }
+ return;
+ }
+
+ // trim the name and unescape it
+ name = Encoder.unescape(name.trim());
+
+ // Is there an alias like [alias|link] ?
+ final int pipeIndex = name.indexOf('|');
+ String alias = "";
+ if(-1 != pipeIndex)
+ {
+ if(null == getModifier())
+ {
+ alias = name.substring(0, pipeIndex);
+ name = name.substring(pipeIndex + 1);
+ }
+ else
+ {
+ alias = name.substring(pipeIndex + 1);
+ name = name.substring(0, pipeIndex);
+ }
+ }
+
+ final int hashIndex = name.lastIndexOf('#');
+
+ String hash = "";
+ if(-1 != hashIndex && hashIndex != name.length() - 1)
+ {
+ hash = name.substring(hashIndex + 1);
+ name = name.substring(0, hashIndex);
+ }
+
+ final int colonIndex = name.indexOf(':');
+ // typed link ?
+ if(-1 != colonIndex)
+ {
+ // for now throw away the type information
+ name = name.substring(colonIndex + 1);
+ }
+
+ final int atIndex = name.lastIndexOf('@');
+ // InterWiki link ?
+ if(-1 != atIndex)
+ {
+ final String extSpace = name.substring(atIndex + 1);
+ // known extarnal space ?
+ final InterWiki interWiki = InterWiki.getInstance();
+ if(interWiki.contains(extSpace))
+ {
+ String view = name;
+ if(-1 != pipeIndex)
+ {
+ view = alias;
+ }
+
+ name = name.substring(0, atIndex);
+ try
+ {
+ if(-1 != hashIndex)
+ {
+ interWiki.expand(writer, extSpace, name, view, hash);
+ }
+ else
+ {
+ interWiki.expand(writer, extSpace, name, view);
+ }
+ }
+ catch(final IOException e)
+ {
+ LOG.debug("InterWiki " + extSpace + " not found.");
+ }
+ }
+ else
+ {
+ buffer.append("[");
+ buffer.append(result.group(1));
+ buffer.append("?]");
+ }
+ }
+ else
+ {
+ // internal link
+
+ if(wikiEngine.exists(name))
+ {
+ String view = getWikiView(name);
+ if(-1 != pipeIndex)
+ {
+ view = alias;
+ }
+ // Do not add hash if an alias was given
+ if(-1 != hashIndex)
+ {
+ wikiEngine.appendLink(buffer, name, view, hash);
+ }
+ else
+ {
+ wikiEngine.appendLink(buffer, name, view);
+ }
+ }
+ else if(wikiEngine.showCreate())
+ {
+ wikiEngine.appendCreateLink(buffer, name, getWikiView(name));
+ // links with "create" are not cacheable because
+ // a missing wiki could be created
+ context.getRenderContext().setCacheable(false);
+ }
+ else
+ {
+ // cannot display/create wiki, so just display the text
+ buffer.append(name);
+ }
+ }
+ }
+ else
+ {
+ buffer.append(Encoder.escape(result.group(0)));
+ }
+ }
+ }
+
+ /**
+ * Returns the view of the wiki name that is shown to the user. Overwrite to
+ * support other views for example transform "WikiLinking" to "Wiki
+ * Linking". Does nothing by default.
+ *
+ * @return view The view of the wiki name
+ */
+
+ protected String getWikiView(final String name)
+ {
+ return name;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/filter/LinkTester.java b/src/main/java/org/radeox/filter/LinkTester.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/LinkTester.java
rename to src/main/java/org/radeox/filter/LinkTester.java
diff --git a/src/main/java/org/radeox/filter/ListFilter.java b/src/main/java/org/radeox/filter/ListFilter.java
new file mode 100644
index 0000000..9397d2f
--- /dev/null
+++ b/src/main/java/org/radeox/filter/ListFilter.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.filter.regex.LocaleRegexTokenFilter;
+import org.radeox.regex.MatchResult;
+
+/**
+ * Listfilter checks for lists in in its input. These are transformed to output
+ * lists, e.g. in HTML.
+ *
+ * Recognices different lists like numbered lists, unnumbered lists, greek
+ * lists, alpha lists etc.
+ *
+ *
+ * @credits nested list support by Davor Cubranic
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: ListFilter.java,v 1.17 2004/04/15 13:56:14 stephan Exp $
+ */
+public class ListFilter extends LocaleRegexTokenFilter implements CacheFilter
+{
+ private static final Log LOG = LogFactory.getLog(ListFilter.class);
+
+ private static final String NEWLINE = "\n";
+ private static final String LI_OPEN = "
";
+ private static final String LI_CLOSE = "
";
+ private static final String UL_CLOSE = "
";
+ private static final String OL_CLOSE = "";
+
+ private static final Map openList = new HashMap<>();
+ private static final Map closeList = new HashMap<>();
+
+ static
+ {
+ openList.put(Character.valueOf('-'), "
");
+ openList.put(Character.valueOf('*'), "
");
+ openList.put(Character.valueOf('#'), "");
+ openList.put(Character.valueOf('i'), "");
+ openList.put(Character.valueOf('I'), "");
+ openList.put(Character.valueOf('a'), "");
+ openList.put(Character.valueOf('A'), "");
+ openList.put(Character.valueOf('g'), "");
+ openList.put(Character.valueOf('h'), "");
+ openList.put(Character.valueOf('H'), "");
+ openList.put(Character.valueOf('k'), "");
+ openList.put(Character.valueOf('K'), "");
+ openList.put(Character.valueOf('j'), "");
+ openList.put(Character.valueOf('1'), "");
+ closeList.put(Character.valueOf('-'), UL_CLOSE);
+ closeList.put(Character.valueOf('*'), UL_CLOSE);
+ closeList.put(Character.valueOf('#'), OL_CLOSE);
+ closeList.put(Character.valueOf('i'), OL_CLOSE);
+ closeList.put(Character.valueOf('I'), OL_CLOSE);
+ closeList.put(Character.valueOf('a'), OL_CLOSE);
+ closeList.put(Character.valueOf('A'), OL_CLOSE);
+ closeList.put(Character.valueOf('1'), OL_CLOSE);
+ closeList.put(Character.valueOf('g'), OL_CLOSE);
+ closeList.put(Character.valueOf('G'), OL_CLOSE);
+ closeList.put(Character.valueOf('h'), OL_CLOSE);
+ closeList.put(Character.valueOf('H'), OL_CLOSE);
+ closeList.put(Character.valueOf('k'), OL_CLOSE);
+ closeList.put(Character.valueOf('K'), OL_CLOSE);
+ closeList.put(Character.valueOf('j'), OL_CLOSE);
+ }
+
+ @Override
+ protected String getLocaleKey()
+ {
+ return "filter.list";
+ }
+
+ @Override
+ protected boolean isSingleLine()
+ {
+ return false;
+ }
+
+ @Override
+ public void handleMatch(final StringBuffer buffer, final MatchResult result,
+ final FilterContext context)
+ {
+ try
+ {
+ final BufferedReader reader = new BufferedReader(new StringReader(result.group(0)));
+ addList(buffer, reader);
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("ListFilter: unable get list content", e);
+ }
+ }
+
+ /**
+ * Adds a list to a buffer
+ *
+ * @param buffer The buffer to write to
+ * @param reader Input is read from this Reader
+ */
+ private void addList(final StringBuffer buffer, final BufferedReader reader)
+ throws IOException
+ {
+ char[] lastBullet = new char[0];
+ String line = null;
+ while((line = reader.readLine()) != null)
+ {
+ // no nested list handling, trim lines:
+ line = line.trim();
+ if(line.length() == 0)
+ {
+ continue;
+ }
+
+ int bulletEnd = line.indexOf(' ');
+ if(bulletEnd < 1)
+ {
+ continue;
+ }
+ if(line.charAt(bulletEnd - 1) == '.')
+ {
+ bulletEnd--;
+ }
+ final char[] bullet = line.substring(0, bulletEnd).toCharArray();
+ // check whether we find a new list
+ int sharedPrefixEnd;
+ for(sharedPrefixEnd = 0;; sharedPrefixEnd++)
+ {
+ if(bullet.length <= sharedPrefixEnd ||
+ lastBullet.length <= sharedPrefixEnd ||
+ +bullet[sharedPrefixEnd] != lastBullet[sharedPrefixEnd])
+ {
+ break;
+ }
+ }
+
+ for(int i = sharedPrefixEnd; i < lastBullet.length; i++)
+ {
+ buffer.append(LI_CLOSE + NEWLINE);
+ buffer.append(closeList.get(Character.valueOf(lastBullet[i])))
+ .append("\n");
+ }
+
+ for(int i = sharedPrefixEnd; i < bullet.length; i++)
+ {
+ if(i > 0)
+ {
+ buffer.append(NEWLINE);
+ }
+ buffer.append(openList.get(Character.valueOf(bullet[i])))
+ .append("\n");
+ buffer.append(LI_OPEN);
+ }
+
+ if(lastBullet.length >= bullet.length)
+ {
+ buffer.append(LI_CLOSE + NEWLINE);
+ buffer.append(LI_OPEN);
+ }
+
+ buffer.append(line.substring(line.indexOf(' ') + 1));
+ lastBullet = bullet;
+ }
+
+ for(int i = lastBullet.length - 1; i >= 0; i--)
+ {
+ buffer.append(LI_CLOSE + NEWLINE);
+ buffer.append(closeList.get(Character.valueOf(lastBullet[i])));
+ if(i > 0)
+ {
+ buffer.append(NEWLINE);
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/org/radeox/filter/LiteralParamFilter.java b/src/main/java/org/radeox/filter/LiteralParamFilter.java
new file mode 100644
index 0000000..8cd6be2
--- /dev/null
+++ b/src/main/java/org/radeox/filter/LiteralParamFilter.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter;
+
+import org.radeox.filter.context.ParamContext;
+
+/**
+ * LiteralParamFilter replaces parametes as a last stage of markup transformation.
+ *
+ * These parameters could be read from an HTTP request and put in MacroFilter.
+ * A parameter is replaced in {$$paramName}.
+ *
+ * These parameters are read when encountering a variable in macros like
+ * {search:$query} or by {@link ParamFilter} in {$query} or by
+ * {@link LiteralParamFilter} in {$$query}. Query is then read from the
+ * parameter map before given to the macro.
+ *
+ *
+ *
Created on 2025-05-28
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class ParamContext
+{
+ private static final String KEY = ParamContext.class.getName()+"_KEY";
+
+ private final Map params = new HashMap<>();
+
+ public Object get(final String key)
+ {
+ return params.get(key);
+ }
+
+ public Object put(final String key, final Object value)
+ {
+ return params.put(key, value);
+ }
+
+ /**
+ * Return current object of {@link ParamFilter} context.
+ *
+ * @param context curent render context
+ * @return object of context
+ */
+ public static ParamContext getOrCreate(final RenderContext context)
+ {
+ return (ParamContext) context.computeIfAbsent(KEY, k -> new ParamContext());
+ }
+
+ /**
+ * Return object of filter context when avaliable.
+ *
+ * @param context curent render context
+ * @return param context or null when not avaliable.
+ */
+ public static ParamContext get(final RenderContext context)
+ {
+ return (ParamContext) context.get(KEY);
+ }
+
+}
diff --git a/src/main/java/org/radeox/filter/interwiki/InterWiki.java b/src/main/java/org/radeox/filter/interwiki/InterWiki.java
new file mode 100644
index 0000000..b801d8b
--- /dev/null
+++ b/src/main/java/org/radeox/filter/interwiki/InterWiki.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.interwiki;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.util.Encoder;
+
+/**
+ * Stores information and links to other wikis forming a InterWiki.
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: InterWiki.java,v 1.6 2004/01/19 11:45:24 stephan Exp $
+ */
+
+public class InterWiki
+{
+ private static final Log LOG = LogFactory.getLog(InterWiki.class);
+
+ private static InterWiki instance;
+ private Map interWiki;
+
+ public static synchronized InterWiki getInstance()
+ {
+ if(null == instance)
+ {
+ instance = new InterWiki();
+ }
+ return instance;
+ }
+
+ public InterWiki(final InputStream in)
+ {
+ try
+ {
+ init(in);
+ }
+ catch(final IOException e)
+ {
+ LOG.warn("Unable to initialize from stream.", e);
+ }
+ }
+
+ public InterWiki()
+ {
+ try
+ {
+ init(InterWiki.class.getClassLoader().getResourceAsStream("intermap.txt"));
+ }
+ catch(final IOException e)
+ {
+ LOG.warn("Unable to read intermap.txt", e);
+ }
+ }
+
+ public void init(final InputStream in) throws IOException
+ {
+ interWiki = new HashMap<>();
+ interWiki.put("LCOM", "http://www.langreiter.com/space/");
+ interWiki.put("ESA", "http://earl.strain.at/space/");
+ interWiki.put("C2", "http://www.c2.com/cgi/wiki?");
+ interWiki.put("WeblogKitchen",
+ "http://www.weblogkitchen.com/wiki.cgi?");
+ interWiki.put("Meatball", "http://www.usemod.com/cgi-bin/mb.pl?");
+ interWiki.put("SnipSnap", "http://snipsnap.org/space/");
+
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(in));
+ String line;
+ while((line = reader.readLine()) != null)
+ {
+ final int index = line.indexOf(" ");
+ interWiki.put(line.substring(0, index),
+ Encoder.escape(line.substring(index + 1)));
+ }
+ }
+
+ public Writer appendTo(final Writer writer) throws IOException
+ {
+ final Iterator> iterator = interWiki.entrySet()
+ .iterator();
+ writer.write("{table}\n");
+ writer.write("Wiki|Url\n");
+ while(iterator.hasNext())
+ {
+ final Entry entry = iterator.next();
+ writer.write(entry.getKey());
+ writer.write("|");
+ writer.write(entry.getValue());
+ writer.write("\n");
+ }
+ writer.write("{table}");
+ return writer;
+ }
+
+ public boolean contains(final String external)
+ {
+ return interWiki.containsKey(external);
+ }
+
+ public String getWikiUrl(final String wiki, final String name)
+ {
+ return (interWiki.get(wiki)) + name;
+ }
+
+ public Writer expand(final Writer writer, final String wiki,
+ final String name, final String view, final String anchor)
+ throws IOException
+ {
+ writer.write("");
+ writer.write(view);
+ writer.write("");
+ return writer;
+ }
+
+ public Writer expand(final Writer writer, final String wiki,
+ final String name, final String view) throws IOException
+ {
+ return expand(writer, wiki, name, view, "");
+ }
+
+}
diff --git a/src/main/java/org/radeox/filter/regex/LocaleRegexReplaceFilter.java b/src/main/java/org/radeox/filter/regex/LocaleRegexReplaceFilter.java
new file mode 100644
index 0000000..0558717
--- /dev/null
+++ b/src/main/java/org/radeox/filter/regex/LocaleRegexReplaceFilter.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.regex;
+
+import java.util.Locale;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * Class that extends RegexReplaceFilter but reads patterns from a locale file
+ * instead of hardwired regex.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: LocaleRegexReplaceFilter.java,v 1.6 2003/10/07 08:20:24 stephan Exp $
+ */
+public abstract class LocaleRegexReplaceFilter extends RegexReplaceFilter
+{
+ private String modifier = null;
+
+ protected abstract String getLocaleKey();
+
+ public void setModifier(final String modifier)
+ {
+ this.modifier = modifier;
+ }
+
+ public String getModifier()
+ {
+ return modifier;
+ }
+
+ protected boolean isSingleLine()
+ {
+ return false;
+ }
+
+ protected BaseResourceBundle getInputBundle()
+ {
+ final Locale inputLocale = initialContext.getInputLocale();
+ final String inputName = initialContext.getInputBundleName();
+ return initialContext.getBundle(inputLocale, inputName);
+ }
+
+ protected BaseResourceBundle getOutputBundle()
+ {
+ final String outputName = initialContext.getOutputBundleName();
+ final Locale outputLocale = initialContext.getOutputLocale();
+ return initialContext.getBundle(outputLocale, outputName);
+ }
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ super.setInitialContext(context);
+ clearRegex();
+
+ final BaseResourceBundle outputMessages = getOutputBundle();
+ final BaseResourceBundle inputMessages = getInputBundle();
+
+ final String match;
+ final String print;
+ if(modifier != null)
+ {
+ match = inputMessages.getString(getLocaleKey() + "." + modifier + ".match");
+ print = outputMessages.getString(getLocaleKey() + "." + modifier + ".print");
+ addRegex(match, print, isSingleLine() ? RegexReplaceFilter.SINGLELINE
+ : RegexReplaceFilter.MULTILINE);
+ }
+ else
+ {
+ match = inputMessages.getString(getLocaleKey() + ".match");
+ print = outputMessages.getString(getLocaleKey() + ".print");
+ }
+ addRegex(match, print, isSingleLine() ? RegexReplaceFilter.SINGLELINE
+ : RegexReplaceFilter.MULTILINE);
+ }
+
+}
diff --git a/src/main/java/org/radeox/filter/regex/LocaleRegexTokenFilter.java b/src/main/java/org/radeox/filter/regex/LocaleRegexTokenFilter.java
new file mode 100644
index 0000000..eb85631
--- /dev/null
+++ b/src/main/java/org/radeox/filter/regex/LocaleRegexTokenFilter.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.regex;
+
+import java.util.Locale;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * Filter that extends RegexTokenFilter but reads regular expressions from
+ * a locale
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: LocaleRegexTokenFilter.java,v 1.5 2003/10/07 08:20:24 stephan Exp $
+ */
+public abstract class LocaleRegexTokenFilter extends RegexTokenFilter
+{
+ protected BaseResourceBundle inputMessages;
+ protected BaseResourceBundle outputMessages;
+ private String modifier;
+
+ public void setModifier(final String modifier)
+ {
+ this.modifier = modifier;
+ }
+
+ public String getModifier()
+ {
+ return modifier;
+ }
+
+ protected boolean isSingleLine()
+ {
+ return false;
+ }
+
+ protected BaseResourceBundle getInputBundle()
+ {
+ final Locale inputLocale = initialContext.getInputLocale();
+ final String inputName = initialContext.getInputBundleName();
+ return initialContext.getBundle(inputLocale, inputName);
+ }
+
+ protected BaseResourceBundle getOutputBundle()
+ {
+ final Locale outputLocale = initialContext.getOutputLocale();
+ final String outputName = initialContext.getOutputBundleName();
+ return initialContext.getBundle(outputLocale, outputName);
+ }
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ super.setInitialContext(context);
+ clearRegex();
+
+ outputMessages = getOutputBundle();
+ inputMessages = getInputBundle();
+ final String match = inputMessages.getString(getLocaleKey() +
+ (modifier != null ? "." + modifier : "") + ".match");
+ addRegex(match, "", isSingleLine() ? RegexReplaceFilter.SINGLELINE
+ : RegexReplaceFilter.MULTILINE);
+ }
+
+ protected abstract String getLocaleKey();
+
+}
diff --git a/main/trunk/src/java/org/radeox/filter/regex/MatchResult.java b/src/main/java/org/radeox/filter/regex/MatchResult.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/filter/regex/MatchResult.java
rename to src/main/java/org/radeox/filter/regex/MatchResult.java
diff --git a/src/main/java/org/radeox/filter/regex/RegexFilter.java b/src/main/java/org/radeox/filter/regex/RegexFilter.java
new file mode 100644
index 0000000..8e155ed
--- /dev/null
+++ b/src/main/java/org/radeox/filter/regex/RegexFilter.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.regex;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.filter.FilterSupport;
+import org.radeox.regex.Pattern;
+
+/**
+ * Class that stores regular expressions, can be subclassed for special Filters.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: RegexFilter.java,v 1.11 2004/04/15 13:56:14 stephan Exp $
+ */
+public abstract class RegexFilter extends FilterSupport
+{
+ private static Log log = LogFactory.getLog(RegexFilter.class);
+
+ protected List pattern = new ArrayList<>();
+ protected List substitute = new ArrayList<>();
+
+ public static final boolean SINGLELINE = false;
+ public static final boolean MULTILINE = true;
+
+ protected RegexFilter()
+ {
+
+ }
+
+ /**
+ * Create a new regular expression that takes input as multiple lines.
+ */
+ protected RegexFilter(final String regex, final String substitute)
+ {
+ addRegex(regex, substitute);
+ }
+
+ /**
+ * Create a new regular expression and set.
+ */
+ protected RegexFilter(final String regex, final String substitute,
+ final boolean multiline)
+ {
+ addRegex(regex, substitute, multiline);
+ }
+
+ public void clearRegex()
+ {
+ pattern.clear();
+ substitute.clear();
+ }
+
+ public void addRegex(final String regex, final String substitute)
+ {
+ addRegex(regex, substitute, MULTILINE);
+ }
+
+ public void addRegex(final String regex, final String substitute,
+ final boolean multiline)
+ {
+ // compiler.compile(regex, (multiline ? Perl5Compiler.MULTILINE_MASK :
+ // Perl5Compiler.SINGLELINE_MASK) | Perl5Compiler.READ_ONLY_MASK));
+ try
+ {
+ final org.radeox.regex.Compiler compiler = org.radeox.regex.Compiler
+ .create();
+ compiler.setMultiline(multiline);
+ this.pattern.add(compiler.compile(regex));
+ // Pattern.DOTALL
+ this.substitute.add(substitute);
+ }
+ catch(final Exception e)
+ {
+ log.warn("bad pattern: " + regex + " -> " + substitute + " " + e);
+ }
+ }
+
+}
diff --git a/src/main/java/org/radeox/filter/regex/RegexReplaceFilter.java b/src/main/java/org/radeox/filter/regex/RegexReplaceFilter.java
new file mode 100644
index 0000000..0b14915
--- /dev/null
+++ b/src/main/java/org/radeox/filter/regex/RegexReplaceFilter.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.regex;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.regex.Matcher;
+import org.radeox.regex.Pattern;
+
+/**
+ * Class that applies a RegexFilter, can be subclassed for special Filters.
+ *
+ * Regular expressions in the input are replaced with strings.
+ *
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: RegexReplaceFilter.java,v 1.8 2004/04/15 13:56:14 stephan Exp $
+ */
+public class RegexReplaceFilter extends RegexFilter
+{
+ private static final Log LOG = LogFactory.getLog(RegexReplaceFilter.class);
+
+ public RegexReplaceFilter()
+ {
+
+ }
+
+ public RegexReplaceFilter(final String regex, final String substitute)
+ {
+ super(regex, substitute);
+ }
+
+ public RegexReplaceFilter(final String regex, final String substitute,
+ final boolean multiline)
+ {
+ super(regex, substitute, multiline);
+ }
+
+ @Override
+ public String filter(final String input, final FilterContext context)
+ {
+ String result = input;
+ final int size = pattern.size();
+ Pattern p;
+ String s;
+ for(int i = 0; i < size; i++)
+ {
+ p = pattern.get(i);
+ s = substitute.get(i);
+ try
+ {
+ final Matcher matcher = Matcher.create(result, p);
+ result = matcher.substitute(s);
+
+ // Util.substitute(matcher, p, new Perl5Substitution(s,
+ // interps), result, limit);
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("Exception for: " + this, e);
+ }
+ catch(final Error err)
+ {
+ LOG.warn("Error for: " + this, err);
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/main/java/org/radeox/filter/regex/RegexTokenFilter.java b/src/main/java/org/radeox/filter/regex/RegexTokenFilter.java
new file mode 100644
index 0000000..747b774
--- /dev/null
+++ b/src/main/java/org/radeox/filter/regex/RegexTokenFilter.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.regex;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.regex.MatchResult;
+import org.radeox.regex.Matcher;
+import org.radeox.regex.Pattern;
+
+/**
+ * Filter that calls a special handler method
+ * {@link #handleMatch(StringBuffer, MatchResult, FilterContext)} for every
+ * occurance of a regular expression.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: RegexTokenFilter.java,v 1.11 2004/04/16 07:47:41 stephan Exp $
+ */
+public abstract class RegexTokenFilter extends RegexFilter
+{
+ private static final Log LOG = LogFactory.getLog(RegexTokenFilter.class);
+
+ protected RegexTokenFilter()
+ {
+ super();
+ }
+
+ /**
+ * create a new regular expression and set
+ */
+ protected RegexTokenFilter(final String regex, final boolean multiline)
+ {
+ super(regex, "", multiline);
+ }
+
+ /**
+ * create a new regular expression and set
+ */
+ protected RegexTokenFilter(final String regex)
+ {
+ super(regex, "");
+ }
+
+ protected void setUp(final FilterContext context)
+ {
+ }
+
+ /**
+ * Method is called for every occurance of a regular expression.
+ *
+ * @param buffer Buffer to write replacement string to
+ * @param result Hit with the found regualr expression
+ * @param context FilterContext for filters
+ */
+ public abstract void handleMatch(StringBuffer buffer, MatchResult result,
+ FilterContext context);
+
+ @Override
+ public String filter(final String input, final FilterContext context)
+ {
+ setUp(context);
+
+ String result = input;
+ final int size = pattern.size();
+ for(int i = 0; i < size; i++)
+ {
+ final Pattern p = pattern.get(i);
+ try
+ {
+ final Matcher m = Matcher.create(result, p);
+ result = m.substitute((buffer, result1) -> handleMatch(buffer, result1, context));
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("Exception: " + this, e);
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/ApiDocMacro.java b/src/main/java/org/radeox/macro/ApiDocMacro.java
similarity index 68%
rename from main/trunk/src/java/org/radeox/macro/ApiDocMacro.java
rename to src/main/java/org/radeox/macro/ApiDocMacro.java
index e25264f..3ad2757 100644
--- a/main/trunk/src/java/org/radeox/macro/ApiDocMacro.java
+++ b/src/main/java/org/radeox/macro/ApiDocMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,30 +18,33 @@
package org.radeox.macro;
-import org.radeox.macro.api.ApiDoc;
-import org.radeox.macro.parameter.MacroParameter;
-
import java.io.IOException;
import java.io.Writer;
-/*
- * Lists all known API documentation repositories and
- * mappings
+import org.radeox.macro.api.ApiDoc;
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
+ * Lists all known API documentation repositories and mappings.
*
* @author stephan
* @team sonicteam
* @version $Id: ApiDocMacro.java,v 1.7 2004/04/27 19:30:38 leo Exp $
*/
+public class ApiDocMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.apidocs";
+ }
-public class ApiDocMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.apidocs";
- }
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ final ApiDoc apiDoc = ApiDoc.getInstance();
+ apiDoc.appendTo(writer);
+ }
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
- ApiDoc apiDoc = ApiDoc.getInstance();
- apiDoc.appendTo(writer);
- return;
- }
}
diff --git a/src/main/java/org/radeox/macro/ApiMacro.java b/src/main/java/org/radeox/macro/ApiMacro.java
new file mode 100644
index 0000000..17b2bd2
--- /dev/null
+++ b/src/main/java/org/radeox/macro/ApiMacro.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.radeox.macro.api.ApiDoc;
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
+ * Macro that replaces {api} with external URLS to api documentation.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: ApiMacro.java,v 1.6 2004/04/27 19:30:38 leo Exp $
+ */
+public class ApiMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.api";
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ String mode;
+ String klass;
+
+ if(params.getLength() == 1)
+ {
+ klass = params.get("0");
+ final int index = klass.indexOf("@");
+ if(index > 0)
+ {
+ mode = klass.substring(index + 1);
+ klass = klass.substring(0, index);
+ }
+ else
+ {
+ mode = "java";
+ }
+ }
+ else if(params.getLength() == 2)
+ {
+ mode = params.get("1").toLowerCase();
+ klass = params.get("0");
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "api macro needs one or two paramaters");
+ }
+ ApiDoc.getInstance().expand(writer, klass, mode);
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/AsinMacro.java b/src/main/java/org/radeox/macro/AsinMacro.java
similarity index 58%
rename from main/trunk/src/java/org/radeox/macro/AsinMacro.java
rename to src/main/java/org/radeox/macro/AsinMacro.java
index edd20e8..56172a9 100644
--- a/main/trunk/src/java/org/radeox/macro/AsinMacro.java
+++ b/src/main/java/org/radeox/macro/AsinMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,44 +16,51 @@
* limitations under the License.
*/
-
package org.radeox.macro;
+import java.io.IOException;
+import java.io.Writer;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.radeox.macro.book.AsinServices;
import org.radeox.macro.parameter.MacroParameter;
-import java.io.IOException;
-import java.io.Writer;
-
-/*
+/**
* Macro for displaying links to external DVD/CD services or dealers.
- * AsinMacro reads the mapping from names to
- * urls from a configuration file and then maps an ASIN number
- * like {asin:1234} to the DVD/CD e.g. on Amazon.
+ *
+ * AsinMacro reads the mapping from names to urls from a configuration file and
+ * then maps an ASIN number like {asin:1234} to the DVD/CD e.g. on Amazon.
+ *
*
* @author stephan
* @team sonicteam
* @version $Id: AsinMacro.java,v 1.7 2004/04/27 19:30:38 leo Exp $
*/
+public class AsinMacro extends BaseLocaleMacro
+{
+ private static final Log LOG = LogFactory.getLog(AsinMacro.class);
-public class AsinMacro extends BaseLocaleMacro {
- private static Log log = LogFactory.getLog(AsinMacro.class);
-
- public String getLocaleKey() {
- return "macro.asin";
- }
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.asin";
+ }
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
- if (params.getLength() == 1) {
- AsinServices.getInstance().appendUrl(writer, params.get("0"));
- return;
- } else {
- log.warn("needs an ASIN number as argument");
- throw new IllegalArgumentException("needs an ASIN number as argument");
+ if(params.getLength() == 1)
+ {
+ AsinServices.getInstance().appendUrl(writer, params.get("0"));
+ }
+ else
+ {
+ LOG.warn("needs an ASIN number as argument");
+ throw new IllegalArgumentException("needs an ASIN number as argument");
+ }
}
- }
+
}
diff --git a/src/main/java/org/radeox/macro/BaseLocaleMacro.java b/src/main/java/org/radeox/macro/BaseLocaleMacro.java
new file mode 100644
index 0000000..838208f
--- /dev/null
+++ b/src/main/java/org/radeox/macro/BaseLocaleMacro.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.util.Locale;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * Class that implements base functionality to write macros and reads it's name
+ * from a locale file
+ *
+ * @author stephan
+ * @version $Id: BaseLocaleMacro.java,v 1.6 2004/04/27 19:30:38 leo Exp $
+ */
+public abstract class BaseLocaleMacro extends BaseMacro implements LocaleMacro
+{
+ private String name;
+
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ super.setInitialContext(context);
+ final Locale inputLocale = context.getInputLocale();
+ final String inputName = context.getInputBundleName();
+ final BaseResourceBundle inputMessages = context.getBundle(inputLocale, inputName);
+ name = inputMessages.getString(getLocaleKey() + ".name");
+ }
+
+}
diff --git a/src/main/java/org/radeox/macro/BaseMacro.java b/src/main/java/org/radeox/macro/BaseMacro.java
new file mode 100644
index 0000000..76fdef4
--- /dev/null
+++ b/src/main/java/org/radeox/macro/BaseMacro.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * Class that implements base functionality to write macros.
+ *
+ *
Created on 2004-11-033
+ *
+ * @author stephan
+ * @author Marcin Golebski
+ * @version $Id: BaseMacro.java,v 1.3 2004/04/27 19:30:38 leo Exp $
+ */
+public abstract class BaseMacro implements Macro, LocaleMacro
+{
+ protected InitialRenderContext initialContext;
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ this.initialContext = context;
+ }
+
+ @Override
+ public String getDescription(final Locale locale)
+ {
+ final String bundleName = initialContext.getLanguageBuldleName();
+ final BaseResourceBundle bundle = initialContext.getBundle(locale,
+ bundleName);
+ return bundle.getString(getLocaleKey() + ".description");
+ }
+
+ @Override
+ public String[] getParamDescription(final Locale locale)
+ {
+ final String buldleName = initialContext.getLanguageBuldleName();
+ final BaseResourceBundle bundle = initialContext.getBundle(locale,
+ buldleName);
+ try
+ {
+ return bundle.get(getLocaleKey() + ".params").split(";");
+ }
+ catch(final MissingResourceException e)
+ {
+ return new String[0];
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return getName();
+ }
+
+ @Override
+ public int compareTo(final Object object)
+ {
+ final Macro macro = (Macro) object;
+ return getName().compareTo(macro.getName());
+ }
+
+}
diff --git a/src/main/java/org/radeox/macro/CodeMacro.java b/src/main/java/org/radeox/macro/CodeMacro.java
new file mode 100644
index 0000000..929759d
--- /dev/null
+++ b/src/main/java/org/radeox/macro/CodeMacro.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.filter.context.BaseFilterContext;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.macro.code.CodeMacroContext;
+import org.radeox.macro.code.SourceCodeFormatter;
+import org.radeox.macro.parameter.MacroParameter;
+import org.radeox.util.Service;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * Macro for displaying programming language source code.
+ *
+ * CodeMacro knows about different source code formatters which can be plugged
+ * into radeox to display more languages. CodeMacro displays Java, Ruby or SQL
+ * code.
+ *
+ *
+ * @author stephan
+ * @team sonicteam
+ * @author Marcin Golebski
+ * @version $Id: CodeMacro.java,v 1.16 2004/04/27 19:30:38 leo Exp $
+ * @see CodeMacroContext
+ */
+public class CodeMacro extends Preserved
+{
+ private static final Log LOG = LogFactory.getLog(CodeMacro.class);
+
+ private final Map formatters;
+ private final FilterContext nullContext = new BaseFilterContext();
+
+ private String start;
+ private String end;
+
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.code";
+ }
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ super.setInitialContext(context);
+ final Locale outputLocale = context.getOutputLocale();
+ final String outputName = context.getOutputBundleName();
+ final BaseResourceBundle outputMessages = context.getBundle(outputLocale, outputName);
+ start = outputMessages.get(getLocaleKey() + ".start");
+ end = outputMessages.get(getLocaleKey() + ".end");
+ }
+
+ public CodeMacro()
+ {
+ formatters = new HashMap<>();
+
+ final Iterator formatterIt = Service
+ .providers(SourceCodeFormatter.class);
+ while(formatterIt.hasNext())
+ {
+ try
+ {
+ final SourceCodeFormatter formatter = formatterIt.next();
+ final String name = formatter.getName();
+ if(formatters.containsKey(name))
+ {
+ final SourceCodeFormatter existing = formatters.get(name);
+ if(existing.getPriority() < formatter.getPriority())
+ {
+ formatters.put(name, formatter);
+ LOG.debug("Replacing formatter: " +
+ formatter.getClass() + " (" + name + ")");
+ }
+ }
+ else
+ {
+ formatters.put(name, formatter);
+ LOG.debug("Loaded formatter: " + formatter.getClass() +
+ " (" + name + ")");
+ }
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("CodeMacro: unable to load code formatter", e);
+ }
+ }
+
+ addSpecial('[');
+ addSpecial(']');
+ addSpecial('{');
+ addSpecial('}');
+ addSpecial('*');
+ addSpecial('-');
+ addSpecial('#');
+ addSpecial('\\');
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ SourceCodeFormatter formatter = null;
+
+ final String formatterName = params.get("0");
+ if(formatterName != null)
+ {
+ formatter = formatters.get(formatterName);
+ LOG.warn("Formatter not found: " + formatterName);
+ }
+ if(formatter == null)
+ {
+ final CodeMacroContext macroContext = CodeMacroContext.getOrCreate(params.getContext());
+ formatter = formatters.get(macroContext.getDefaultFormatter());
+ if(formatter == null)
+ {
+ LOG.error("Formatter not found: " + macroContext.getDefaultFormatter());
+ }
+ }
+ writer.write(start);
+ if(formatter != null)
+ {
+ final String result = formatter.filter(params.getContent(), nullContext);
+ writer.write(replace(result.trim()));
+ }
+ else
+ {
+ writer.write(params.getContent());
+ }
+ writer.write(end);
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/FilePathMacro.java b/src/main/java/org/radeox/macro/FilePathMacro.java
similarity index 55%
rename from main/trunk/src/java/org/radeox/macro/FilePathMacro.java
rename to src/main/java/org/radeox/macro/FilePathMacro.java
index 8216c9b..c329954 100644
--- a/main/trunk/src/java/org/radeox/macro/FilePathMacro.java
+++ b/src/main/java/org/radeox/macro/FilePathMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,38 +18,45 @@
package org.radeox.macro;
-import org.radeox.macro.parameter.MacroParameter;
-
import java.io.IOException;
import java.io.Writer;
-/*
- * Displays a file path. This is used to store a filepath in an
- * OS independent way and then display the file path as needed.
- * This macro also solves the problems with to many backslashes
- * in Windows filepaths when they are entered in Snipsnap.
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
+ * Displays a file path. This is used to store a filepath in an OS independent
+ * way and then display the file path as needed.
+ *
+ * This macro also solves the problems with to many backslashes in Windows
+ * filepaths when they are entered in Snipsnap.
+ *
*
* @author stephan
* @team sonicteam
* @version $Id: FilePathMacro.java,v 1.9 2004/04/27 19:30:38 leo Exp $
*/
+public class FilePathMacro extends Preserved
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.filepath";
+ }
-public class FilePathMacro extends LocalePreserved {
- public String getLocaleKey() {
- return "macro.filepath";
- }
-
- public FilePathMacro() {
- addSpecial('\\');
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
+ public FilePathMacro()
+ {
+ addSpecial('\\');
+ }
- if (params.getLength() == 1) {
- String path = params.get("0").replace('/', '\\');
- writer.write(replace(path));
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ if(params.getLength() == 1)
+ {
+ final String path = params.get("0").replace('/', '\\');
+ writer.write(replace(path));
+ }
}
- return;
- }
+
}
diff --git a/main/trunk/src/java/org/radeox/macro/HelloWorldMacro.java b/src/main/java/org/radeox/macro/HelloWorldMacro.java
similarity index 51%
rename from main/trunk/src/java/org/radeox/macro/HelloWorldMacro.java
rename to src/main/java/org/radeox/macro/HelloWorldMacro.java
index 897566e..12f7914 100644
--- a/main/trunk/src/java/org/radeox/macro/HelloWorldMacro.java
+++ b/src/main/java/org/radeox/macro/HelloWorldMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,44 +16,62 @@
* limitations under the License.
*/
-
package org.radeox.macro;
-import org.radeox.macro.parameter.MacroParameter;
-
import java.io.IOException;
import java.io.Writer;
+import java.util.Locale;
-/*
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
* Hello world example macro. This Macro displays a hello world string.
*
* @author stephan
* @version $Id: HelloWorldMacro.java,v 1.4 2003/10/07 08:05:33 stephan Exp $
*/
+public class HelloWorldMacro extends BaseMacro
+{
+ private final String[] paramDescription = {"1: name to print"};
+
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.hello";
+ }
+
+ @Override
+ public String getName()
+ {
+ return "hello";
+ }
+
+ @Override
+ public String getDescription(final Locale locale)
+ {
+ return "Say hello example macro.";
+ }
+
+ @Override
+ public String[] getParamDescription(final Locale locale)
+ {
+ return paramDescription;
+ }
-public class HelloWorldMacro extends BaseMacro {
- private String[] paramDescription = {"1: name to print"};
-
- public String getName() {
- return "hello";
- }
-
- public String getDescription() {
- return "Say hello example macro.";
- }
-
- public String[] getParamDescription() {
- return paramDescription;
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
- if (params.getLength() == 1) {
- writer.write("Hello ");
- writer.write(params.get("0"));
- writer.write("");
- } else {
- throw new IllegalArgumentException("Number of arguments does not match");
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ if(params.getLength() == 1)
+ {
+ writer.write("Hello ");
+ writer.write(params.get("0"));
+ writer.write("");
+ }
+ else
+ {
+ throw new IllegalArgumentException("Number of arguments does not match");
+ }
}
- }
+
}
diff --git a/src/main/java/org/radeox/macro/ImgMacro.java b/src/main/java/org/radeox/macro/ImgMacro.java
new file mode 100644
index 0000000..dacc6f2
--- /dev/null
+++ b/src/main/java/org/radeox/macro/ImgMacro.java
@@ -0,0 +1,215 @@
+package org.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Base64;
+
+import org.apache.commons.lang3.StringUtils;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.filter.context.ParamContext;
+import org.radeox.macro.img.ImgMacroFile;
+import org.radeox.macro.img.ImgMacroContext;
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
+ * Html image rendering macro.
+ *
+ * It renders img html tag when placed into html page:
+ *
+ *
+ * @author Marcin Golebski
+ * @see ImgMacroContext
+ * @see ImgMacroFile
+ */
+public class ImgMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.img";
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ final RenderContext context = params.getContext();
+
+ final String width = toCss(params.get("width", "w"));
+ final String height = toCss(params.get("height", "h"));
+ boolean left = false;
+ boolean right = false;
+ boolean center = false;
+ String filename = null;
+
+ final int paramLength = params.getLength();
+ for(int i = 0; i < paramLength; ++i)
+ {
+ final String value = params.get(i);
+ if(value == null || value.startsWith("width") || value.startsWith("height") || value.equals("w") || value.equals("h"))
+ {
+ continue;
+ }
+ if(value.equals("left") || value.equals("l"))
+ {
+ left = true;
+ }
+ else if(value.equals("right") || value.equals("r"))
+ {
+ right = true;
+ }
+ else if(value.equals("center") || value.equals("c"))
+ {
+ center = true;
+ }
+ else
+ {
+ filename = value;
+ }
+ }
+ if(filename == null)
+ {
+ writer.write("{img:right|width=20em|height=10em|example-file.png}");
+ return;
+ }
+ final ImgMacroContext imgContext = ImgMacroContext.getOrCreate(context);
+ final ImgMacroFile file = imgContext.get(filename);
+ if(file == null || file.isNoContent())
+ {
+ writeImageNotFound(writer, width, height, left, right, center, filename);
+ return;
+ }
+ writer.write("");
+ }
+
+ private void writeMimeRef(final Writer writer, final ImgMacroFile file)
+ throws IOException
+ {
+ writer.write("src='cid:");
+ writer.write(file.getContentId());
+ writer.write("'");
+ }
+
+ private void writeBase64Content(final Writer writer,
+ final RenderContext context, final ImgMacroContext imgContext,
+ final ImgMacroFile file) throws IOException
+ {
+ writer.write("src='data:");
+ writer.write(file.getMime());
+ writer.write(";charset=utf-8;base64,{$$");
+ final String varialbeName = imgContext.nextVarialbeName();
+ writer.write(varialbeName);
+ writer.write("}'");
+ // value of the imgage will be
+ final ParamContext paramContext = ParamContext.getOrCreate(context);
+ final String base64 = Base64.getEncoder().encodeToString(file.getContent());
+ paramContext.put(varialbeName, base64);
+ }
+
+ private void writeStyle(final Writer writer, final String width,
+ final String height, final boolean left, final boolean right, final boolean center)
+ throws IOException
+ {
+ final boolean hasStyle = left || right || center || height != null ||
+ width != null;
+ if(hasStyle)
+ {
+ writer.write("style='");
+ }
+ if(left)
+ {
+ writer.write("float:left;");
+ }
+ if(right)
+ {
+ writer.write("float:right;");
+ }
+ if(center)
+ {
+ writer.write("margin-left:auto;margin-right:auto;display:block;");
+ }
+ if(width != null)
+ {
+ writer.write("width:");
+ writer.write(width);
+ writer.write(";");
+ }
+ if(height != null)
+ {
+ writer.write("height:");
+ writer.write(height);
+ writer.write(";");
+ }
+ if(hasStyle)
+ {
+ writer.write("' ");
+ }
+ }
+
+ private void writeImageNotFound(final Writer writer, final String width,
+ final String height, final boolean left, final boolean right, final boolean center,
+ final String filename) throws IOException
+ {
+ writer.write("{img:");
+ if(left)
+ {
+ writer.write("left|");
+ }
+ if(right)
+ {
+ writer.write("right|");
+ }
+ if(center)
+ {
+ writer.write("center|");
+ }
+ if(width != null)
+ {
+ writer.write("width=");
+ writer.write(width);
+ writer.write("|");
+ }
+ if(height != null)
+ {
+ writer.write("height=");
+ writer.write(height);
+ writer.write("|");
+ }
+ writer.write(filename);
+ writer.write("}");
+ }
+
+ private static String toCss(final String size)
+ {
+ final String trimmed = StringUtils.trimToNull(size);
+ if(trimmed == null)
+ {
+ return null;
+ }
+ final char last = trimmed.charAt(trimmed.length() - 1);
+ if(Character.isDigit(last))
+ {
+ return trimmed + "px";
+ }
+ return trimmed;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/InterWikiMacro.java b/src/main/java/org/radeox/macro/InterWikiMacro.java
similarity index 72%
rename from main/trunk/src/java/org/radeox/macro/InterWikiMacro.java
rename to src/main/java/org/radeox/macro/InterWikiMacro.java
index ebace4e..3874b8f 100644
--- a/main/trunk/src/java/org/radeox/macro/InterWikiMacro.java
+++ b/src/main/java/org/radeox/macro/InterWikiMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,32 +16,35 @@
* limitations under the License.
*/
-
package org.radeox.macro;
-import org.radeox.filter.interwiki.InterWiki;
-import org.radeox.macro.parameter.MacroParameter;
-
import java.io.IOException;
import java.io.Writer;
-/*
+import org.radeox.filter.interwiki.InterWiki;
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
* Macro that shows all know interwiki mappings.
*
* @author stephan
* @team sonicteam
* @version $Id: InterWikiMacro.java,v 1.5 2004/04/27 19:30:38 leo Exp $
*/
+public class InterWikiMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.interwiki";
+ }
-public class InterWikiMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.interwiki";
- }
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ final InterWiki interWiki = InterWiki.getInstance();
+ interWiki.appendTo(writer);
+ }
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
- InterWiki interWiki = InterWiki.getInstance();
- interWiki.appendTo(writer);
- return;
- }
}
diff --git a/main/trunk/src/java/org/radeox/macro/IsbnMacro.java b/src/main/java/org/radeox/macro/IsbnMacro.java
similarity index 59%
rename from main/trunk/src/java/org/radeox/macro/IsbnMacro.java
rename to src/main/java/org/radeox/macro/IsbnMacro.java
index 2e95602..d52b0d9 100644
--- a/main/trunk/src/java/org/radeox/macro/IsbnMacro.java
+++ b/src/main/java/org/radeox/macro/IsbnMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,39 +16,48 @@
* limitations under the License.
*/
-
package org.radeox.macro;
-import org.radeox.macro.book.BookServices;
-import org.radeox.macro.parameter.MacroParameter;
-
import java.io.IOException;
import java.io.Writer;
-/*
+import org.radeox.macro.book.BookServices;
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
* Macro for displaying links to external book services, book dealers or
- * intranet libraries. IsbnMacro reads the mapping from names to
- * urls from a configuration file and then maps an ISBN number
- * like {isbn:1234} to the book e.g. on Amazon.
+ * intranet libraries.
+ *
+ * IsbnMacro reads the mapping from names to urls from a configuration file and
+ * then maps an ISBN number like {isbn:1234} to the book e.g. on Amazon.
+ *
*
* @author stephan
* @team sonicteam
* @version $Id: IsbnMacro.java,v 1.7 2004/04/27 19:30:38 leo Exp $
*/
+public class IsbnMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.isbn";
+ }
-public class IsbnMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.isbn";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
-
- if (params.getLength() == 1) {
- BookServices.getInstance().appendUrl(writer, params.get("0"));
- return;
- } else {
- throw new IllegalArgumentException("needs an ISBN number as argument");
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+
+ if(params.getLength() == 1)
+ {
+ BookServices.getInstance().appendUrl(writer, params.get("0"));
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "needs an ISBN number as argument");
+ }
}
- }
+
}
diff --git a/src/main/java/org/radeox/macro/LinkMacro.java b/src/main/java/org/radeox/macro/LinkMacro.java
new file mode 100644
index 0000000..171a3ed
--- /dev/null
+++ b/src/main/java/org/radeox/macro/LinkMacro.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.radeox.api.engine.ImageRenderEngine;
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.macro.parameter.MacroParameter;
+import org.radeox.util.Encoder;
+
+/**
+ * Macro for displaying external links with a name. The normal UrlFilter takes
+ * the url as a name.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: LinkMacro.java,v 1.17 2004/05/03 11:12:37 stephan Exp $
+ */
+public class LinkMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.link";
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ final RenderContext context = params.getContext();
+ final RenderEngine engine = context.getRenderEngine();
+
+ String text = params.get("text", 0);
+ String url = params.get("url", 1);
+ final String img = params.get("img", 2);
+
+ // check for single url argument (text == url)
+ if(params.getLength() == 1)
+ {
+ url = text;
+ text = Encoder.toEntity(text.charAt(0)) +
+ Encoder.escape(text.substring(1));
+ }
+
+ if(url != null && text != null)
+ {
+ writer.write("");
+ if(!"none".equals(img) && engine instanceof ImageRenderEngine)
+ {
+ writer
+ .write(((ImageRenderEngine) engine).getExternalImageLink());
+ }
+ writer.write("");
+ writer.write(text);
+ writer.write("");
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "link needs a name and a url as argument: txt=" + text +
+ " url=" + url);
+ }
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/LocaleMacro.java b/src/main/java/org/radeox/macro/LocaleMacro.java
similarity index 89%
rename from main/trunk/src/java/org/radeox/macro/LocaleMacro.java
rename to src/main/java/org/radeox/macro/LocaleMacro.java
index b32522b..fd59629 100644
--- a/main/trunk/src/java/org/radeox/macro/LocaleMacro.java
+++ b/src/main/java/org/radeox/macro/LocaleMacro.java
@@ -1,10 +1,10 @@
package org.radeox.macro;
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,7 +18,7 @@
* limitations under the License.
*/
-
-public interface LocaleMacro {
- public String getLocaleKey();
+public interface LocaleMacro
+{
+ String getLocaleKey();
}
diff --git a/src/main/java/org/radeox/macro/Macro.java b/src/main/java/org/radeox/macro/Macro.java
new file mode 100644
index 0000000..e2cbf61
--- /dev/null
+++ b/src/main/java/org/radeox/macro/Macro.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
+ * Class that implements base functionality to write macros
+ *
+ * @author stephan
+ * @version $Id: Macro.java,v 1.8 2003/12/16 17:08:24 stephan Exp $
+ */
+public interface Macro extends Comparable
+{
+ /**
+ * Get the name of the macro. This is used to map a macro in the input to
+ * the macro which should be called. The method has to be implemented by
+ * subclassing classes.
+ *
+ * @return name Name of the Macro
+ */
+ public String getName();
+
+ /**
+ * Get a description of the macro. This description explains in a short way
+ * what the macro does
+ *
+ * @param locale current locale
+ * @return description A string describing the macro
+ */
+ public String getDescription(Locale locale);
+
+ /**
+ * Get a description of the paramters of the macro. The method returns an
+ * array with an String entry for every parameter. The format is {"1:
+ * description", ...} where 1 is the position of the parameter.
+ *
+ * @param locale current locale
+ * @return description Array describing the parameters of the macro
+ */
+ public String[] getParamDescription(Locale locale);
+
+ public void setInitialContext(InitialRenderContext context);
+
+ /**
+ * Execute the macro. This method is called by MacroFilter to handle macros.
+ *
+ * @param writer A write where the macro should write its output to
+ * @param params Macro parameters with the parameters the macro is called
+ * with
+ * @throws IllegalArgumentException when illegal argument(s) was passed to
+ * the macro. Exception message will be passed to the user as rendered
+ * result
+ */
+ public void execute(Writer writer, MacroParameter params)
+ throws IllegalArgumentException, IOException;
+
+}
diff --git a/src/main/java/org/radeox/macro/MacroListMacro.java b/src/main/java/org/radeox/macro/MacroListMacro.java
new file mode 100644
index 0000000..29d1f4b
--- /dev/null
+++ b/src/main/java/org/radeox/macro/MacroListMacro.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.radeox.macro.parameter.MacroParameter;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * MacroListMacro displays a list of all known macros of the EngineManager with
+ * their name, parameters and a description.
+ *
+ * @author Matthias L. Jugel
+ * @version $Id: MacroListMacro.java,v 1.11 2004/05/11 12:17:21 leo Exp $
+ */
+public class MacroListMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.macrolist";
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ final Locale locale = params.getContext().getLocale();
+ final List macros = MacroRepository.getInstance().getPlugins();
+ if(params.getLength() == 0)
+ {
+ appendTo(writer, locale, macros);
+ }
+ else
+ {
+ final Set allowedMacros = params.getParams().values().stream()
+ .collect(Collectors.toSet());
+ final List filtered = macros.stream()
+ .filter(m -> allowedMacros.contains(m.getName()))
+ .collect(Collectors.toCollection(ArrayList::new));
+ appendTo(writer, locale, filtered);
+ }
+ }
+
+ private Writer appendTo(final Writer writer, final Locale locale, final List macroList)
+ throws IOException
+ {
+ final String bundleName = initialContext.getLanguageBuldleName();
+ Collections.sort(macroList);
+ final BaseResourceBundle bundle = initialContext.getBundle(locale, bundleName);
+ writer.write("
");
+ return writer;
+ }
+}
diff --git a/main/trunk/src/java/org/radeox/macro/MacroLoader.java b/src/main/java/org/radeox/macro/MacroLoader.java
similarity index 54%
rename from main/trunk/src/java/org/radeox/macro/MacroLoader.java
rename to src/main/java/org/radeox/macro/MacroLoader.java
index e629afc..12a7f04 100644
--- a/main/trunk/src/java/org/radeox/macro/MacroLoader.java
+++ b/src/main/java/org/radeox/macro/MacroLoader.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,38 +16,45 @@
* limitations under the License.
*/
-
package org.radeox.macro;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * Plugin loader for macros
+ * Plugin loader for macros.
*
* @author Stephan J. Schmidt
* @version $Id: MacroLoader.java,v 1.5 2004/05/03 11:12:37 stephan Exp $
*/
+public class MacroLoader extends PluginLoader
+{
+ private static final Log LOG = LogFactory.getLog(MacroLoader.class);
+
+ @Override
+ public Class getLoadClass()
+ {
+ return Macro.class;
+ }
-public class MacroLoader extends PluginLoader {
- private static Log log = LogFactory.getLog(MacroLoader.class);
-
- public Class getLoadClass() {
- return Macro.class;
- }
-
- /**
- * Add a plugin to the known plugin map
- *
- * @param repository a Repository to add the plugin to
- * @param plugin a Macro to add to the repository
- */
- public void add(Repository repository, Object plugin) {
- if (plugin instanceof Macro) {
- repository.put(((Macro) plugin).getName(), plugin);
- } else {
- log.debug("MacroLoader: " + plugin.getClass() + " not of Type " + getLoadClass());
+ /**
+ * Add a plugin to the known plugin map.
+ *
+ * @param repository a Repository to add the plugin to
+ * @param plugin a Macro to add to the repository
+ */
+ @Override
+ public void add(final Repository repository, final R plugin)
+ {
+ if(plugin instanceof Macro)
+ {
+ repository.put(plugin.getName(), plugin);
+ }
+ else
+ {
+ LOG.debug("MacroLoader: " + plugin.getClass() + " not of Type " +
+ getLoadClass());
+ }
}
- }
}
diff --git a/src/main/java/org/radeox/macro/MacroRepository.java b/src/main/java/org/radeox/macro/MacroRepository.java
new file mode 100644
index 0000000..2e9fa12
--- /dev/null
+++ b/src/main/java/org/radeox/macro/MacroRepository.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.api.engine.context.InitialRenderContext;
+
+/**
+ * Repository for plugins
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: MacroRepository.java,v 1.9 2003/12/17 13:35:36 stephan Exp $
+ */
+public class MacroRepository extends PluginRepository
+{
+ private static final Log LOG = LogFactory.getLog(MacroRepository.class);
+
+ protected static MacroRepository instance;
+ protected List loaders;
+
+ public static synchronized MacroRepository getInstance()
+ {
+ if(null == instance)
+ {
+ instance = new MacroRepository();
+ }
+ return instance;
+ }
+
+ private void initialize(final InitialRenderContext context)
+ {
+ final Iterator iterator = list.iterator();
+ while(iterator.hasNext())
+ {
+ final Macro macro = iterator.next();
+ macro.setInitialContext(context);
+ }
+ init();
+ }
+
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ initialize(context);
+ }
+
+ private void init()
+ {
+ final Map newPlugins = new HashMap<>();
+
+ final Iterator iterator = list.iterator();
+ while(iterator.hasNext())
+ {
+ final Macro macro = iterator.next();
+ newPlugins.put(macro.getName(), macro);
+ }
+ plugins = newPlugins;
+ }
+
+ /**
+ * Loads macros from all loaders into plugins.
+ */
+ private void load()
+ {
+ final Iterator iterator = loaders.iterator();
+ while(iterator.hasNext())
+ {
+ final MacroLoader loader = iterator.next();
+ loader.setRepository(this);
+ LOG.debug("Loading from: " + loader.getClass());
+ loader.loadPlugins(this);
+ }
+ }
+
+ public void addLoader(final MacroLoader loader)
+ {
+ loader.setRepository(this);
+ loaders.add(loader);
+ plugins = new HashMap<>();
+ list = new ArrayList<>();
+ load();
+ }
+
+ private MacroRepository()
+ {
+ loaders = new ArrayList<>();
+ loaders.add(new MacroLoader());
+ load();
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/MailToMacro.java b/src/main/java/org/radeox/macro/MailToMacro.java
similarity index 67%
rename from main/trunk/src/java/org/radeox/macro/MailToMacro.java
rename to src/main/java/org/radeox/macro/MailToMacro.java
index 7f6e875..9cd3e8d 100644
--- a/main/trunk/src/java/org/radeox/macro/MailToMacro.java
+++ b/src/main/java/org/radeox/macro/MailToMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,31 +18,36 @@
package org.radeox.macro;
-import org.radeox.macro.parameter.MacroParameter;
-
import java.io.IOException;
import java.io.Writer;
-/*
+import org.radeox.macro.parameter.MacroParameter;
+
+/**
* Displays a mail to link.
*
* @author stephan
* @team sonicteam
* @version $Id: MailToMacro.java,v 1.5 2004/04/27 19:30:38 leo Exp $
*/
+public class MailToMacro extends Preserved
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.mailto";
+ }
-public class MailToMacro extends LocalePreserved {
- public String getLocaleKey() {
- return "macro.mailto";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
- if (params.getLength() == 1) {
- String mail = params.get("0");
- writer.write(""+mail+"");
+ if(params.getLength() == 1)
+ {
+ final String mail = params.get("0");
+ writer.write("" + mail + "");
+ }
}
- return;
- }
+
}
diff --git a/src/main/java/org/radeox/macro/PluginLoader.java b/src/main/java/org/radeox/macro/PluginLoader.java
new file mode 100644
index 0000000..1a72baf
--- /dev/null
+++ b/src/main/java/org/radeox/macro/PluginLoader.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.util.Service;
+
+/**
+ * Plugin loader
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: PluginLoader.java,v 1.6 2004/01/09 12:27:14 stephan Exp $
+ */
+
+public abstract class PluginLoader
klass)
+ {
+ if(null != repository)
+ {
+ /* load all macros found in the services plugin control file */
+ final Iterator
iterator = getPlugins(klass);
+ while(iterator.hasNext())
+ {
+ try
+ {
+ final P plugin = iterator.next();
+ add(repository, plugin);
+ log.debug("PluginLoader: Loaded plugin: " + plugin.getClass());
+ }
+ catch(final Exception e)
+ {
+ log.warn("PluginLoader: unable to load plugin", e);
+ }
+ }
+ }
+ return repository;
+ }
+
+ /**
+ * Add a plugin to the known plugin map
+ *
+ * @param plugin Plugin to add
+ */
+ public abstract void add(Repository
repository, R plugin);
+
+ public abstract Class
getLoadClass();
+}
diff --git a/main/trunk/src/java/org/radeox/macro/PluginRepository.java b/src/main/java/org/radeox/macro/PluginRepository.java
similarity index 57%
rename from main/trunk/src/java/org/radeox/macro/PluginRepository.java
rename to src/main/java/org/radeox/macro/PluginRepository.java
index 519bc88..15b3012 100644
--- a/main/trunk/src/java/org/radeox/macro/PluginRepository.java
+++ b/src/main/java/org/radeox/macro/PluginRepository.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.radeox.macro;
import java.util.ArrayList;
@@ -25,37 +24,45 @@
import java.util.Map;
/**
- * Repository for plugins
+ * Repository for plugins.
*
* @author Stephan J. Schmidt
* @version $Id: PluginRepository.java,v 1.5 2003/12/17 13:41:54 stephan Exp $
*/
+public class PluginRepository implements Repository
+{
+ protected Map plugins;
+ protected List list;
-public class PluginRepository implements Repository {
- protected Map plugins;
- protected List list;
-
- protected static Repository instance;
+ public PluginRepository()
+ {
+ plugins = new HashMap<>();
+ list = new ArrayList<>();
+ }
- public PluginRepository() {
- plugins = new HashMap();
- list = new ArrayList();
- }
+ @Override
+ public boolean containsKey(final String key)
+ {
+ return plugins.containsKey(key);
+ }
- public boolean containsKey(String key) {
- return plugins.containsKey(key);
- }
+ @Override
+ public E get(final String key)
+ {
+ return plugins.get(key);
+ }
- public Object get(String key) {
- return plugins.get(key);
- }
+ @Override
+ public List getPlugins()
+ {
+ return new ArrayList<>(plugins.values());
+ }
- public List getPlugins() {
- return new ArrayList(plugins.values());
- }
+ @Override
+ public void put(final String key, final E value)
+ {
+ plugins.put(key, value);
+ list.add(value);
+ }
- public void put(String key, Object value) {
- plugins.put(key, value);
- list.add(value);
- }
}
diff --git a/src/main/java/org/radeox/macro/Preserved.java b/src/main/java/org/radeox/macro/Preserved.java
new file mode 100644
index 0000000..381c05c
--- /dev/null
+++ b/src/main/java/org/radeox/macro/Preserved.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.util.Encoder;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * A specialized macro that allows to preserve certain special characters by
+ * creating character entities.
+ *
+ * The subclassing macro may decide whether to call {@link #replace(String)}
+ * before or after executing the actual macro substitution.
+ *
+ *
+ * @author Matthias L. Jugel
+ * @version $Id: Preserved.java,v 1.7 2004/06/08 08:46:18 leo Exp $
+ */
+public abstract class Preserved extends BaseMacro
+{
+ private final Map special = new HashMap<>();
+ private String specialString = "";
+
+ private String name;
+
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public void setInitialContext(final InitialRenderContext context)
+ {
+ super.setInitialContext(context);
+
+ final Locale inputLocale = context.getInputLocale();
+ final String inputName = context.getInputBundleName();
+ final BaseResourceBundle inputMessages = context.getBundle(inputLocale, inputName);
+ name = inputMessages.get(getLocaleKey() + ".name");
+ }
+
+ /**
+ * Encode special character c by replacing with it's hex character entity
+ * code.
+ */
+ protected void addSpecial(final char c)
+ {
+ addSpecial("" + c, Encoder.toEntity(c));
+ }
+
+ /**
+ * Add a replacement for the special character c which may be a string
+ *
+ * @param c the character to replace
+ * @param replacement the new string
+ */
+ protected void addSpecial(final String c, final String replacement)
+ {
+ specialString += c;
+ special.put(c, replacement);
+ }
+
+ /**
+ * Actually replace specials in source. This method can be used by
+ * subclassing macros.
+ *
+ * @param source String to encode
+ *
+ * @return encoded Encoded string
+ */
+ protected String replace(final String source)
+ {
+ final StringBuilder tmp = new StringBuilder();
+ final StringTokenizer st = new StringTokenizer(source, specialString, true);
+ String previous = "";
+ while(st.hasMoreTokens())
+ {
+ String current = st.nextToken();
+ if(special.containsKey(current) && !previous.endsWith("&"))
+ {
+ current = special.get(current);
+ }
+ tmp.append(current);
+ previous = current;
+ }
+ return tmp.toString();
+ }
+
+}
diff --git a/src/main/java/org/radeox/macro/QuoteMacro.java b/src/main/java/org/radeox/macro/QuoteMacro.java
new file mode 100644
index 0000000..4774a4b
--- /dev/null
+++ b/src/main/java/org/radeox/macro/QuoteMacro.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.MissingResourceException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.macro.parameter.MacroParameter;
+import org.radeox.util.i18n.BaseResourceBundle;
+
+/**
+ * Macro to display quotations from other sources.
+ *
+ * The output is wrapped usually in
to look like a quotation.
+ *
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: QuoteMacro.java,v 1.11 2004/06/08 07:54:36 leo Exp $
+ */
+public class QuoteMacro extends Preserved
+{
+ private static final Log LOG = LogFactory.getLog(QuoteMacro.class);
+
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.quote";
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ final Locale locale = params.getContext().getLocale();
+ writer.write("
");
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/Repository.java b/src/main/java/org/radeox/macro/Repository.java
similarity index 78%
rename from main/trunk/src/java/org/radeox/macro/Repository.java
rename to src/main/java/org/radeox/macro/Repository.java
index 221be9c..4eb08a4 100644
--- a/main/trunk/src/java/org/radeox/macro/Repository.java
+++ b/src/main/java/org/radeox/macro/Repository.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,24 +16,24 @@
* limitations under the License.
*/
-
package org.radeox.macro;
import java.util.List;
/**
- * Repository for Macros
+ * Repository for Macros.
*
- * @author
+ * @author stephan
* @version $Id: Repository.java,v 1.2 2003/06/11 10:04:27 stephan Exp $
*/
+public interface Repository
+{
+ public boolean containsKey(String key);
-public interface Repository {
- public boolean containsKey(String key);
+ public E get(String key);
- public Object get(String key);
+ public List getPlugins();
- public List getPlugins();
+ public void put(String key, E value);
- public void put(String key, Object value);
}
diff --git a/main/trunk/src/java/org/radeox/macro/RfcMacro.java b/src/main/java/org/radeox/macro/RfcMacro.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/macro/RfcMacro.java
rename to src/main/java/org/radeox/macro/RfcMacro.java
diff --git a/main/trunk/src/java/org/radeox/macro/TableMacro.java b/src/main/java/org/radeox/macro/TableMacro.java
similarity index 52%
rename from main/trunk/src/java/org/radeox/macro/TableMacro.java
rename to src/main/java/org/radeox/macro/TableMacro.java
index 652ac40..510d59d 100644
--- a/main/trunk/src/java/org/radeox/macro/TableMacro.java
+++ b/src/main/java/org/radeox/macro/TableMacro.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,47 +16,54 @@
* limitations under the License.
*/
-
package org.radeox.macro;
+import java.io.IOException;
+import java.io.Writer;
+
import org.radeox.macro.parameter.MacroParameter;
import org.radeox.macro.table.Table;
import org.radeox.macro.table.TableBuilder;
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Macro for defining and displaying tables. The rows of the table are
- * devided by newlins and the columns are divided by pipe symbols "|".
- * The first line of the table is rendered as column headers.
- * {table}
- * A|B|C
- * 1|2|3
- * {table}
+/**
+ * Macro for defining and displaying tables.
+ *
+ * The rows of the table are devided by newlins and the columns are divided by
+ * pipe symbols "|". The first line of the table is rendered as column headers.
+ *
+ * {table}
+ * A|B|C
+ * 1|2|3
+ * {table}
+ *
+ *
*
* @author stephan
* @team sonicteam
* @version $Id: TableMacro.java,v 1.9 2004/04/27 19:30:38 leo Exp $
*/
+public class TableMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.table";
+ }
-public class TableMacro extends BaseLocaleMacro {
- public String getLocaleKey() {
- return "macro.table";
- }
-
- public void execute(Writer writer, MacroParameter params)
- throws IllegalArgumentException, IOException {
-
- String content = params.getContent();
-
- if (null == content) throw new IllegalArgumentException("TableMacro: missing table content");
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ String content = params.getContent();
+ if(null == content)
+ {
+ throw new IllegalArgumentException("TableMacro: missing table content");
+ }
+ content = content.trim() + "\n";
- content = content.trim() + "\n";
+ final Table table = TableBuilder.build(content);
+ table.calc(); // calculate macros like =SUM(A1:A3)
+ table.appendTo(writer);
+ }
- Table table = TableBuilder.build(content);
- table.calc(); // calculate macros like =SUM(A1:A3)
- table.appendTo(writer);
- return;
- }
}
diff --git a/src/main/java/org/radeox/macro/XrefMacro.java b/src/main/java/org/radeox/macro/XrefMacro.java
new file mode 100644
index 0000000..a96f933
--- /dev/null
+++ b/src/main/java/org/radeox/macro/XrefMacro.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.radeox.macro.parameter.MacroParameter;
+import org.radeox.macro.xref.XrefMapper;
+
+/**
+ * Macro that replaces {xref} with external URLS to xref source code.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: XrefMacro.java,v 1.6 2004/04/27 19:30:38 leo Exp $
+ */
+public class XrefMacro extends BaseLocaleMacro
+{
+ @Override
+ public String getLocaleKey()
+ {
+ return "macro.xref";
+ }
+
+ @Override
+ public void execute(final Writer writer, final MacroParameter params)
+ throws IllegalArgumentException, IOException
+ {
+ String project;
+ String klass;
+ int lineNumber = 0;
+
+ if(params.getLength() >= 1)
+ {
+ klass = params.get("0");
+
+ final int index = klass.indexOf("@");
+ if(index > 0)
+ {
+ project = klass.substring(index + 1);
+ klass = klass.substring(0, index);
+ }
+ else
+ {
+ project = "SnipSnap";
+ }
+ if(params.getLength() == 2)
+ {
+ lineNumber = Integer.parseInt(params.get("1"));
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "xref macro needs one or two paramaters");
+ }
+ XrefMapper.getInstance().expand(writer, klass, project, lineNumber);
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/api/ApiConverter.java b/src/main/java/org/radeox/macro/api/ApiConverter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/macro/api/ApiConverter.java
rename to src/main/java/org/radeox/macro/api/ApiConverter.java
diff --git a/src/main/java/org/radeox/macro/api/ApiDoc.java b/src/main/java/org/radeox/macro/api/ApiDoc.java
new file mode 100644
index 0000000..aa7b36d
--- /dev/null
+++ b/src/main/java/org/radeox/macro/api/ApiDoc.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro.api;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Stores information and links to api documentation, e.g. for Java, Ruby, JBoss
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: ApiDoc.java,v 1.6 2003/06/11 10:04:27 stephan Exp $
+ */
+public class ApiDoc
+{
+ private static final Log LOG = LogFactory.getLog(ApiDoc.class);
+
+ private static ApiDoc instance;
+ private final Map apiDocs;
+
+ public static synchronized ApiDoc getInstance()
+ {
+ if(null == instance)
+ {
+ instance = new ApiDoc();
+ }
+ return instance;
+ }
+
+ public ApiDoc()
+ {
+ apiDocs = new HashMap<>();
+ try
+ {
+ final BufferedReader br = new BufferedReader(
+ new InputStreamReader(ApiDoc.class.getClassLoader()
+ .getResourceAsStream("apidocs.txt")));
+ addApiDoc(br);
+ }
+ catch(final IOException e)
+ {
+ LOG.warn("Unable to read apidocs.txt");
+ }
+
+ }
+
+ public void addApiDoc(final BufferedReader reader) throws IOException
+ {
+ String line;
+ while((line = reader.readLine()) != null)
+ {
+ final StringTokenizer tokenizer = new StringTokenizer(line, " ");
+ final String mode = tokenizer.nextToken();
+ final String baseUrl = tokenizer.nextToken();
+ final String converterName = tokenizer.nextToken();
+ ApiConverter converter = null;
+ try
+ {
+ converter = (ApiConverter) Class.forName(
+ "org.radeox.macro.api." + converterName + "ApiConverter")
+ .newInstance();
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("Unable to load converter: " + converterName +
+ "ApiConverter", e);
+ }
+ converter.setBaseUrl(baseUrl);
+ apiDocs.put(mode.toLowerCase(), converter);
+ }
+ }
+
+ public boolean contains(final String external)
+ {
+ return apiDocs.containsKey(external);
+ }
+
+ public Writer expand(final Writer writer, final String className,
+ String mode) throws IOException
+ {
+ mode = mode.toLowerCase();
+ if(apiDocs.containsKey(mode))
+ {
+ writer.write("");
+ writer.write(className);
+ writer.write("");
+ }
+ else
+ {
+ LOG.warn(mode + " not found");
+ }
+ return writer;
+ }
+
+ public Writer appendTo(final Writer writer) throws IOException
+ {
+ writer.write("{table}\n");
+ writer.write("Binding|BaseUrl|Converter Name\n");
+ for(final Entry entry : apiDocs.entrySet())
+ {
+ writer.write(entry.getKey());
+ final ApiConverter converter = entry.getValue();
+ writer.write("|");
+ writer.write(converter.getBaseUrl());
+ writer.write("|");
+ writer.write(converter.getName());
+ writer.write("\n");
+ }
+ writer.write("{table}");
+ return writer;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/api/BaseApiConverter.java b/src/main/java/org/radeox/macro/api/BaseApiConverter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/macro/api/BaseApiConverter.java
rename to src/main/java/org/radeox/macro/api/BaseApiConverter.java
diff --git a/main/trunk/src/java/org/radeox/macro/api/JavaApiConverter.java b/src/main/java/org/radeox/macro/api/JavaApiConverter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/macro/api/JavaApiConverter.java
rename to src/main/java/org/radeox/macro/api/JavaApiConverter.java
diff --git a/main/trunk/src/java/org/radeox/macro/api/RubyApiConverter.java b/src/main/java/org/radeox/macro/api/RubyApiConverter.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/macro/api/RubyApiConverter.java
rename to src/main/java/org/radeox/macro/api/RubyApiConverter.java
diff --git a/main/trunk/src/java/org/radeox/macro/book/AsinServices.java b/src/main/java/org/radeox/macro/book/AsinServices.java
similarity index 67%
rename from main/trunk/src/java/org/radeox/macro/book/AsinServices.java
rename to src/main/java/org/radeox/macro/book/AsinServices.java
index 9d5aa6c..bdb3f14 100644
--- a/main/trunk/src/java/org/radeox/macro/book/AsinServices.java
+++ b/src/main/java/org/radeox/macro/book/AsinServices.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,36 +16,37 @@
* limitations under the License.
*/
-
-
package org.radeox.macro.book;
/**
- * Manages links to asin (DVD, CD) dealears or comparison services
+ * Manages links to asin (DVD, CD) dealears or comparison services.
*
* @author Stephan J. Schmidt
* @version $Id: AsinServices.java,v 1.3 2003/02/06 13:41:41 leo Exp $
*/
+public class AsinServices extends TextFileUrlMapper
+{
+ private static AsinServices instance;
+
+ public static synchronized UrlMapper getInstance()
+ {
+ if(null == instance)
+ {
+ instance = new AsinServices();
+ }
+ return instance;
+ }
-public class AsinServices extends TextFileUrlMapper {
- private static AsinServices instance;
-
- public AsinServices() {
- super(AsinServices.class);
- }
-
- public static synchronized UrlMapper getInstance() {
- if (null == instance) {
- instance = new AsinServices();
+ @Override
+ public String getFileName()
+ {
+ return "asinservices.txt";
}
- return instance;
- }
- public String getFileName() {
- return "conf/asinservices.txt";
- }
+ @Override
+ public String getKeyName()
+ {
+ return "asin";
+ }
- public String getKeyName() {
- return "asin";
- }
}
diff --git a/main/trunk/src/java/org/radeox/macro/book/BookServices.java b/src/main/java/org/radeox/macro/book/BookServices.java
similarity index 63%
rename from main/trunk/src/java/org/radeox/macro/book/BookServices.java
rename to src/main/java/org/radeox/macro/book/BookServices.java
index 5476bd1..0842d0a 100644
--- a/main/trunk/src/java/org/radeox/macro/book/BookServices.java
+++ b/src/main/java/org/radeox/macro/book/BookServices.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,36 +16,37 @@
* limitations under the License.
*/
-
-
package org.radeox.macro.book;
/**
- * Manages links to book dealears or comparison services
+ * Manages links to book dealears or comparison services.
*
* @author Stephan J. Schmidt
* @version $Id: BookServices.java,v 1.4 2003/02/06 13:41:41 leo Exp $
*/
+public class BookServices extends TextFileUrlMapper
+{
+ private static BookServices instance;
+
+ public static synchronized UrlMapper getInstance()
+ {
+ if(null == instance)
+ {
+ instance = new BookServices();
+ }
+ return instance;
+ }
-public class BookServices extends TextFileUrlMapper {
- private static BookServices instance;
-
- public BookServices() {
- super(BookServices.class);
- }
-
- public static synchronized UrlMapper getInstance() {
- if (null == instance) {
- instance = new BookServices();
+ @Override
+ public String getFileName()
+ {
+ return "bookservices.txt";
}
- return instance;
- }
- public String getFileName() {
- return "conf/bookservices.txt";
- }
+ @Override
+ public String getKeyName()
+ {
+ return "isbn";
+ }
- public String getKeyName() {
- return "isbn";
- }
}
diff --git a/src/main/java/org/radeox/macro/book/TextFileUrlMapper.java b/src/main/java/org/radeox/macro/book/TextFileUrlMapper.java
new file mode 100644
index 0000000..2ab21b1
--- /dev/null
+++ b/src/main/java/org/radeox/macro/book/TextFileUrlMapper.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro.book;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.radeox.util.Encoder;
+
+/**
+ * Manages links to keys, mapping is read from a text file.
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: TextFileUrlMapper.java,v 1.6 2003/06/11 10:04:27 stephan Exp $
+ */
+public abstract class TextFileUrlMapper implements UrlMapper
+{
+ private static Log log = LogFactory.getLog(TextFileUrlMapper.class);
+
+ private final Map services;
+
+ public abstract String getFileName();
+
+ public abstract String getKeyName();
+
+ protected TextFileUrlMapper()
+ {
+ services = new HashMap<>();
+
+ try
+ {
+ final BufferedReader br = new BufferedReader(
+ new InputStreamReader(TextFileUrlMapper.class.getClassLoader()
+ .getResourceAsStream(getFileName())));
+ addMapping(br);
+ }
+ catch(final IOException e)
+ {
+ log.warn("Unable to read " + getFileName());
+ }
+
+ }
+
+ public void addMapping(final BufferedReader reader) throws IOException
+ {
+ String line;
+ while((line = reader.readLine()) != null)
+ {
+ if(!line.startsWith("#"))
+ {
+ final int index = line.indexOf(" ");
+ services.put(line.substring(0, index),
+ Encoder.escape(line.substring(index + 1)));
+ }
+ }
+ }
+
+ @Override
+ public Writer appendTo(final Writer writer) throws IOException
+ {
+ final Iterator> iterator = services.entrySet().iterator();
+ writer.write("{table}\n");
+ writer.write("Service|Url\n");
+ while(iterator.hasNext())
+ {
+ final Entry entry = iterator.next();
+ writer.write(entry.getKey());
+ writer.write("|");
+ writer.write(entry.getValue());
+ writer.write("\n");
+ }
+ writer.write("{table}");
+ return writer;
+ }
+
+ public boolean contains(final String external)
+ {
+ return services.containsKey(external);
+ }
+
+ @Override
+ public Writer appendUrl(final Writer writer, final String key)
+ throws IOException
+ {
+ if(services.size() == 0)
+ {
+ writer.write(getKeyName());
+ writer.write(":");
+ writer.write(key);
+ }
+ else
+ {
+ // SnipLink.appendImage(writer, "external-link", ">>");
+ writer.write("(");
+ final Iterator> iterator = services.entrySet()
+ .iterator();
+ while(iterator.hasNext())
+ {
+ final Entry entry = iterator.next();
+ writer.write("");
+ writer.write(entry.getKey());
+ writer.write("");
+ if(iterator.hasNext())
+ {
+ writer.write(" | ");
+ }
+ }
+ writer.write(")");
+ }
+ return writer;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/book/UrlMapper.java b/src/main/java/org/radeox/macro/book/UrlMapper.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/macro/book/UrlMapper.java
rename to src/main/java/org/radeox/macro/book/UrlMapper.java
diff --git a/src/main/java/org/radeox/macro/code/CodeMacroContext.java b/src/main/java/org/radeox/macro/code/CodeMacroContext.java
new file mode 100644
index 0000000..8fff3d3
--- /dev/null
+++ b/src/main/java/org/radeox/macro/code/CodeMacroContext.java
@@ -0,0 +1,35 @@
+package org.radeox.macro.code;
+
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.macro.CodeMacro;
+
+/**
+ * Context for {@link CodeMacro}.
+ *
+ *
Created on 2025-06-02
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class CodeMacroContext
+{
+ private static final String KEY = CodeMacroContext.class.getName()+"_KEY";
+
+ private String defaultFormatter = "java";
+
+ public String getDefaultFormatter()
+ {
+ return defaultFormatter;
+ }
+
+ public void setDefaultFormatter(final String defaultFormatter)
+ {
+ this.defaultFormatter = defaultFormatter;
+ }
+
+ public static CodeMacroContext getOrCreate(final RenderContext context)
+ {
+ return (CodeMacroContext) context.computeIfAbsent(KEY, k -> new CodeMacroContext());
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/code/DefaultRegexCodeFormatter.java b/src/main/java/org/radeox/macro/code/DefaultRegexCodeFormatter.java
similarity index 83%
rename from main/trunk/src/java/org/radeox/macro/code/DefaultRegexCodeFormatter.java
rename to src/main/java/org/radeox/macro/code/DefaultRegexCodeFormatter.java
index 4e0a89c..4999c64 100644
--- a/main/trunk/src/java/org/radeox/macro/code/DefaultRegexCodeFormatter.java
+++ b/src/main/java/org/radeox/macro/code/DefaultRegexCodeFormatter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,25 +16,27 @@
* limitations under the License.
*/
-
package org.radeox.macro.code;
-/*
+/**
* Default code formatter
*
* @author stephan
* @team sonicteam
* @version $Id: DefaultRegexCodeFormatter.java,v 1.1 2003/08/29 12:32:55 stephan Exp $
*/
-
import org.radeox.filter.regex.RegexReplaceFilter;
-public class DefaultRegexCodeFormatter extends RegexReplaceFilter {
- public DefaultRegexCodeFormatter(String regex, String substitute) {
- super(regex, substitute);
- }
+public class DefaultRegexCodeFormatter extends RegexReplaceFilter
+{
+ public DefaultRegexCodeFormatter(final String regex, final String substitute)
+ {
+ super(regex, substitute);
+ }
+
+ public int getPriority()
+ {
+ return 0;
+ }
- public int getPriority() {
- return 0;
- }
}
diff --git a/src/main/java/org/radeox/macro/code/JavaCodeFilter.java b/src/main/java/org/radeox/macro/code/JavaCodeFilter.java
new file mode 100644
index 0000000..871a9cb
--- /dev/null
+++ b/src/main/java/org/radeox/macro/code/JavaCodeFilter.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro.code;
+
+/**
+ * JavaCodeFilter colourizes Java source code.
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: JavaCodeFilter.java,v 1.5 2003/08/29 12:32:12 stephan Exp $
+ */
+public class JavaCodeFilter extends DefaultRegexCodeFormatter
+ implements SourceCodeFormatter
+{
+
+ private static final String KEYWORDS = "\\b(abstract|break|byvalue|case|cast|catch|" +
+ "const|continue|default|do|else|extends|" +
+ "false|final|finally|for|future|generic|goto|if|" +
+ "implements|import|inner|instanceof|interface|" +
+ "native|new|null|operator|outer|package|private|" +
+ "protected|public|rest|return|static|super|switch|" +
+ "synchronized|this|throw|throws|transient|true|try|" +
+ "var|volatile|while)\\b";
+
+ private static final String OBJECTS = "\\b(Boolean|Byte|Character|Class|ClassLoader|Cloneable|Compiler|" +
+ "Double|Float|Integer|Long|Math|Number|Object|Process|" +
+ "Runnable|Runtime|SecurityManager|Short|String|StringBuilder|StringBuffer|" +
+ "System|Thread|ThreadGroup|Void|boolean|char|byte|short|int|long|float|double)\\b";
+
+ private static final String QUOTES = "\"(([^\"\\\\]|\\.)*)\"";
+
+ public JavaCodeFilter()
+ {
+ super(QUOTES, "\"$1\"");
+ addRegex(KEYWORDS, "$1");
+ addRegex(OBJECTS, "$1");
+ }
+
+ @Override
+ public String getName()
+ {
+ return "java";
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/code/NullCodeFilter.java b/src/main/java/org/radeox/macro/code/NullCodeFilter.java
similarity index 73%
rename from main/trunk/src/java/org/radeox/macro/code/NullCodeFilter.java
rename to src/main/java/org/radeox/macro/code/NullCodeFilter.java
index 032e574..55e32b1 100644
--- a/main/trunk/src/java/org/radeox/macro/code/NullCodeFilter.java
+++ b/src/main/java/org/radeox/macro/code/NullCodeFilter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,33 +16,35 @@
* limitations under the License.
*/
-
package org.radeox.macro.code;
import org.radeox.filter.context.FilterContext;
-/*
+/**
* Dummy filter that does nothing
*
* @author stephan
* @team sonicteam
* @version $Id: NullCodeFilter.java,v 1.4 2003/08/29 12:32:12 stephan Exp $
*/
-
-public class NullCodeFilter implements SourceCodeFormatter {
-
- public NullCodeFilter() {
- }
-
- public String filter(String content, FilterContext context) {
- return content;
- }
-
- public String getName() {
- return "none";
- }
-
- public int getPriority() {
- return 0;
- }
-}
\ No newline at end of file
+public class NullCodeFilter implements SourceCodeFormatter
+{
+ @Override
+ public String filter(final String content, final FilterContext context)
+ {
+ return content;
+ }
+
+ @Override
+ public String getName()
+ {
+ return "none";
+ }
+
+ @Override
+ public int getPriority()
+ {
+ return 0;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/macro/code/SourceCodeFormatter.java b/src/main/java/org/radeox/macro/code/SourceCodeFormatter.java
similarity index 82%
rename from main/trunk/src/java/org/radeox/macro/code/SourceCodeFormatter.java
rename to src/main/java/org/radeox/macro/code/SourceCodeFormatter.java
index 86e2ebd..a3772e0 100644
--- a/main/trunk/src/java/org/radeox/macro/code/SourceCodeFormatter.java
+++ b/src/main/java/org/radeox/macro/code/SourceCodeFormatter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
package org.radeox.macro.code;
import org.radeox.filter.context.FilterContext;
@@ -25,11 +24,14 @@
* Displays source code with syntax highlighting etc.
*
* @author Stephan J. Schmidt
- * @version $Id: SourceCodeFormatter.java,v 1.4 2003/02/18 12:57:24 stephan Exp $
+ * @version $Id: SourceCodeFormatter.java,v 1.4 2003/02/18 12:57:24 stephan Exp
+ * $
*/
+public interface SourceCodeFormatter
+{
+ public String getName();
+
+ public int getPriority();
-public interface SourceCodeFormatter {
- public String getName();
- public int getPriority();
- public String filter(String content, FilterContext context);
+ public String filter(String content, FilterContext context);
}
diff --git a/main/trunk/src/java/org/radeox/macro/code/SqlCodeFilter.java b/src/main/java/org/radeox/macro/code/SqlCodeFilter.java
similarity index 51%
rename from main/trunk/src/java/org/radeox/macro/code/SqlCodeFilter.java
rename to src/main/java/org/radeox/macro/code/SqlCodeFilter.java
index dcf2e97..f2a8e40 100644
--- a/main/trunk/src/java/org/radeox/macro/code/SqlCodeFilter.java
+++ b/src/main/java/org/radeox/macro/code/SqlCodeFilter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,45 +16,40 @@
* limitations under the License.
*/
-
package org.radeox.macro.code;
-
-/*
- * SqlCodeFilter colourizes SQL source code
+/**
+ * SqlCodeFilter colourizes SQL source code.
*
* @author stephan
* @team sonicteam
* @version $Id: SqlCodeFilter.java,v 1.6 2004/02/19 12:47:56 stephan Exp $
*/
+public class SqlCodeFilter extends DefaultRegexCodeFormatter implements SourceCodeFormatter
+{
+ private static final String KEYWORDS = "\\b(SELECT|INSERT INTO|DELETE|UPDATE|CREATE|DROP|IF EXISTS|TABLE|TEMPORARY|WHERE|LEFT JOIN|ON|FROM|GROUP|BY|HAVING|AND|OR|ORDER)\\b";
-public class SqlCodeFilter extends DefaultRegexCodeFormatter implements SourceCodeFormatter {
+ private static final String OBJECTS = "\\b(VARCHAR)" + "\\b";
- private static final String KEYWORDS =
- "\\b(SELECT|INSERT INTO|DELETE|UPDATE|CREATE|DROP|IF EXISTS|TABLE|TEMPORARY|WHERE|LEFT JOIN|ON|FROM|GROUP|BY|HAVING|AND|OR|ORDER)\\b";
+ private static final String QUOTES = "\"(([^\"\\\\]|\\.)*)\"";
- private static final String OBJECTS =
- "\\b(VARCHAR)" +
- "\\b";
+ private static final String COMMENTS = "^#(.*)$";
- private static final String QUOTES =
- "\"(([^\"\\\\]|\\.)*)\"";
+ private static final String EMPTYLINES = "^\\s*$";
- private static final String COMMENTS =
- "^#(.*)$";
-
- private static final String EMPTYLINES =
- "^\\s*$";
+ public SqlCodeFilter()
+ {
+ super(QUOTES, "\"$1\"");
+ addRegex(OBJECTS, "$1");
+ addRegex(KEYWORDS, "$1");
+ addRegex(COMMENTS, "#$1");
+ addRegex(EMPTYLINES, "");
+ }
- public SqlCodeFilter() {
- super(QUOTES, "\"$1\"");
- addRegex(OBJECTS, "$1");
- addRegex(KEYWORDS, "$1");
- addRegex(COMMENTS, "#$1");
- addRegex(EMPTYLINES, "");
- }
+ @Override
+ public String getName()
+ {
+ return "sql";
+ }
- public String getName() {
- return "sql";
- }
}
diff --git a/main/trunk/src/java/org/radeox/macro/code/XmlCodeFilter.java b/src/main/java/org/radeox/macro/code/XmlCodeFilter.java
similarity index 56%
rename from main/trunk/src/java/org/radeox/macro/code/XmlCodeFilter.java
rename to src/main/java/org/radeox/macro/code/XmlCodeFilter.java
index 308f24e..02c0067 100644
--- a/main/trunk/src/java/org/radeox/macro/code/XmlCodeFilter.java
+++ b/src/main/java/org/radeox/macro/code/XmlCodeFilter.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,28 +18,31 @@
package org.radeox.macro.code;
-/*
- * XmlCodeFilter colourizes Xml Code
+/**
+ * XmlCodeFilter colourizes Xml Code.
*
* @author stephan
* @team sonicteam
* @version $Id: XmlCodeFilter.java,v 1.6 2003/12/11 13:24:56 leo Exp $
*/
+public class XmlCodeFilter extends DefaultRegexCodeFormatter implements SourceCodeFormatter
+{
+ private static final String KEYWORDS = "\\b(xsl:[^&\\s]*)\\b";
+ private static final String TAGS = "(</?[^!0-9].*?>)";
+ private static final String QUOTE = "\"(([^\"\\\\]|\\.)*)\"";
+ private static final String COMMENT = "(<!--.*-->)";
-public class XmlCodeFilter extends DefaultRegexCodeFormatter implements SourceCodeFormatter {
- private static final String KEYWORDS = "\\b(xsl:[^&\\s]*)\\b";
- private static final String TAGS = "(</?[^!0-9].*?>)";
- private static final String QUOTE = "\"(([^\"\\\\]|\\.)*)\"";
- private static final String COMMENT = "(<!--.*-->)";
-
- public XmlCodeFilter() {
- super(QUOTE, "\"$1\"");
- addRegex(TAGS, "$1");
- addRegex(KEYWORDS, "$1");
- addRegex(COMMENT, "$1");
- }
+ public XmlCodeFilter()
+ {
+ super(QUOTE, "\"$1\"");
+ addRegex(TAGS, "$1");
+ addRegex(KEYWORDS, "$1");
+ addRegex(COMMENT, "$1");
+ }
- public String getName() {
- return "xml";
- }
+ @Override
+ public String getName()
+ {
+ return "xml";
+ }
}
diff --git a/src/main/java/org/radeox/macro/img/ImgMacroContext.java b/src/main/java/org/radeox/macro/img/ImgMacroContext.java
new file mode 100644
index 0000000..0b37d34
--- /dev/null
+++ b/src/main/java/org/radeox/macro/img/ImgMacroContext.java
@@ -0,0 +1,98 @@
+package org.radeox.macro.img;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nonnull;
+
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.filter.LiteralParamFilter;
+import org.radeox.macro.ImgMacro;
+
+/**
+ * Context for {@link ImgMacro}.
+ *
+ * Should be used, whem renderer should include images into its output.
+ *
+ *
+ *
Created on 2025-05-28
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class ImgMacroContext
+{
+ private static final String KEY = ImgMacroContext.class.getName()+"_KEY";
+
+ private final List files;
+ private Map map;
+ private int index;
+
+ public ImgMacroContext()
+ {
+ files = new ArrayList<>();
+ index = 0;
+ }
+
+ public void addAll(final Collection files)
+ {
+ this.files.addAll(files);
+ this.map = null;
+ }
+
+ public void add(final ImgMacroFile file)
+ {
+ this.files.add(file);
+ this.map = null;
+ }
+
+ public void clear()
+ {
+ files.clear();
+ }
+
+ /**
+ * Get file info for given filename.
+ *
+ * @param filename the name of the file
+ * @return file info
+ */
+ public ImgMacroFile get(final String filename)
+ {
+ if(map == null)
+ {
+ map = files.stream()
+ .collect(Collectors.toMap(ImgMacroFile::getFilename, Function.identity()));
+ }
+ return map.get(filename);
+ }
+
+ /**
+ * Generates valuename for {@link LiteralParamFilter}, to substitute this
+ * value after every filters, to protect its content.
+ *
+ * @return new unique value name of the shape Base64Image_1
+ */
+ public String nextVarialbeName()
+ {
+ return "Base64Image_" + (++index);
+ }
+
+ /**
+ * Obtain current context for {@link ImgMacro}. If context is not avaliable
+ * new context will be created.
+ *
+ * @param context current rendererm macro
+ * @return context object
+ */
+ @Nonnull
+ public static ImgMacroContext getOrCreate(final RenderContext context)
+ {
+ return (ImgMacroContext) context.computeIfAbsent(KEY, k -> new ImgMacroContext());
+ }
+
+}
diff --git a/src/main/java/org/radeox/macro/img/ImgMacroFile.java b/src/main/java/org/radeox/macro/img/ImgMacroFile.java
new file mode 100644
index 0000000..8a310fb
--- /dev/null
+++ b/src/main/java/org/radeox/macro/img/ImgMacroFile.java
@@ -0,0 +1,143 @@
+package org.radeox.macro.img;
+
+import java.util.Base64;
+import java.util.function.Supplier;
+
+import org.radeox.macro.ImgMacro;
+
+/**
+ * File to be rendered by {@link ImgMacro}.
+ *
+ *
Created on 2025-05-28
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class ImgMacroFile
+{
+ private final String filename;
+ private final String mime;
+ private final Supplier content;
+ private final String contentId;
+
+ /**
+ * Constructs file container, which should be rendered inline, using
+ * {@link Base64} encoding.
+ *
+ * Example:
+ *
+ *
+ *
+ *
+ *
+ * This should be used, when template is displayed in html page.
+ *
+ *
+ * @param filename the name of the file
+ * @param mime mime type
+ * @param content lazy inicialized file content - not every attachment will
+ * be displayed in rendered output
+ */
+ public ImgMacroFile(final String filename, final String mime, final Supplier content)
+ {
+ this.filename = filename;
+ this.mime = mime;
+ this.content = content;
+ this.contentId = null;
+ }
+
+ /**
+ * Constructs file container, which should be rendered as reference to the
+ * MIME part.
+ *
");
+ return writer;
+ }
+
+}
diff --git a/src/main/java/org/radeox/macro/table/TableBuilder.java b/src/main/java/org/radeox/macro/table/TableBuilder.java
new file mode 100644
index 0000000..0243d6d
--- /dev/null
+++ b/src/main/java/org/radeox/macro/table/TableBuilder.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro.table;
+
+import java.util.StringTokenizer;
+
+/**
+ * Built a table from a string
+ *
+ * @author stephan
+ * @version $Id: TableBuilder.java,v 1.3 2003/10/06 08:30:02 stephan Exp $
+ */
+public class TableBuilder
+{
+ public static Table build(final String content)
+ {
+ final Table table = new Table();
+ final StringTokenizer tokenizer = new StringTokenizer(content, "|\n", true);
+ String lastToken = null;
+ while(tokenizer.hasMoreTokens())
+ {
+ String token = tokenizer.nextToken();
+ String linkToken = "";
+ if(token.indexOf('[') != -1 && token.indexOf(']') == -1)
+ {
+ while(token.indexOf(']') == -1 && tokenizer.hasMoreTokens())
+ {
+ linkToken += token;
+ token = tokenizer.nextToken();
+ }
+ token = linkToken + token;
+ }
+ if("\n".equals(token))
+ {
+ // Handles "\n" - "|\n"
+ if(null == lastToken || "|".equals(lastToken))
+ {
+ table.addCell(" ");
+ }
+ table.newRow();
+ }
+ else if(!"|".equals(token))
+ {
+ table.addCell(token);
+ }
+ else if(null == lastToken || "|".equals(lastToken))
+ {
+ // Handles "|" "||"
+ table.addCell(" ");
+ }
+ lastToken = token;
+ }
+ return table;
+ }
+
+}
diff --git a/src/main/java/org/radeox/macro/xref/XrefMapper.java b/src/main/java/org/radeox/macro/xref/XrefMapper.java
new file mode 100644
index 0000000..fbf4b5a
--- /dev/null
+++ b/src/main/java/org/radeox/macro/xref/XrefMapper.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro.xref;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Stores information and links to xref Java source code e.g.
+ * http://nanning.sourceforge.net/xref/com/tirsen/nanning/MixinInstance.html#83
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: XrefMapper.java,v 1.3 2003/06/11 10:04:27 stephan Exp $
+ */
+public class XrefMapper
+{
+ private static final Log LOG = LogFactory.getLog(XrefMapper.class);
+
+ private static XrefMapper instance;
+ private final Map xrefMap;
+
+ public static synchronized XrefMapper getInstance()
+ {
+ if(null == instance)
+ {
+ instance = new XrefMapper();
+ }
+ return instance;
+ }
+
+ public XrefMapper()
+ {
+ xrefMap = new HashMap<>();
+ try
+ {
+ final BufferedReader br = new BufferedReader(
+ new InputStreamReader(XrefMapper.class.getClassLoader()
+ .getResourceAsStream("xref.txt")));
+ addXref(br);
+ }
+ catch(final IOException e)
+ {
+ LOG.warn("Unable to read xref.txt");
+ }
+ }
+
+ public void addXref(final BufferedReader reader) throws IOException
+ {
+ String line;
+ while((line = reader.readLine()) != null)
+ {
+ final StringTokenizer tokenizer = new StringTokenizer(line, " ");
+ final String site = tokenizer.nextToken();
+ final String baseUrl = tokenizer.nextToken();
+ xrefMap.put(site.toLowerCase(), baseUrl);
+ }
+ }
+
+ public boolean contains(final String external)
+ {
+ return xrefMap.containsKey(external);
+ }
+
+ public Writer expand(final Writer writer, final String className,
+ String site, final int lineNumber) throws IOException
+ {
+ site = site.toLowerCase();
+ if(xrefMap.containsKey(site))
+ {
+ writer.write(" 0)
+ {
+ writer.write("#");
+ writer.write("" + lineNumber);
+ }
+ writer.write("\">");
+ writer.write(className);
+ writer.write("");
+ }
+ else
+ {
+ LOG.debug("Xrefs : " + xrefMap);
+ LOG.warn(site + " not found");
+ }
+ return writer;
+ }
+
+ public Writer appendTo(final Writer writer) throws IOException
+ {
+ writer.write("{table}\n");
+ writer.write("Binding|Site\n");
+ final Iterator> iterator = xrefMap.entrySet()
+ .iterator();
+ while(iterator.hasNext())
+ {
+ final Entry entry = iterator.next();
+ writer.write(entry.getKey());
+ writer.write("|");
+ writer.write(entry.getValue());
+ writer.write("\n");
+ }
+ writer.write("{table}");
+ return writer;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/regex/Compiler.java b/src/main/java/org/radeox/regex/Compiler.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/Compiler.java
rename to src/main/java/org/radeox/regex/Compiler.java
diff --git a/main/trunk/src/java/org/radeox/regex/JdkCompiler.java b/src/main/java/org/radeox/regex/JdkCompiler.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/JdkCompiler.java
rename to src/main/java/org/radeox/regex/JdkCompiler.java
diff --git a/main/trunk/src/java/org/radeox/regex/JdkMatchResult.java b/src/main/java/org/radeox/regex/JdkMatchResult.java
similarity index 51%
rename from main/trunk/src/java/org/radeox/regex/JdkMatchResult.java
rename to src/main/java/org/radeox/regex/JdkMatchResult.java
index 6eb476b..c990c5a 100644
--- a/main/trunk/src/java/org/radeox/regex/JdkMatchResult.java
+++ b/src/main/java/org/radeox/regex/JdkMatchResult.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,42 +16,52 @@
* limitations under the License.
*/
-
package org.radeox.regex;
-/*
- * The result when a Matcher object finds matches in some input
- * Implementation for regex package in JDK 1.4
+/**
+ * The result when a Matcher object finds matches in some input Implementation
+ * for regex package in JDK 1.4.
*
* @author stephan
* @team sonicteam
* @version $Id: JdkMatchResult.java,v 1.1 2004/04/16 07:37:52 stephan Exp $
*/
+public class JdkMatchResult extends MatchResult
+{
+ private final java.util.regex.Matcher matcher;
-public class JdkMatchResult extends MatchResult {
- private java.util.regex.Matcher matcher;
+ public JdkMatchResult(final java.util.regex.Matcher matcher)
+ {
+ this.matcher = matcher;
+ }
- public JdkMatchResult(java.util.regex.Matcher matcher) {
- this.matcher = matcher;
- }
+ public JdkMatchResult(final Matcher matcher)
+ {
+ this.matcher = ((JdkMatcher) matcher).getMatcher();
+ }
- public JdkMatchResult(Matcher matcher) {
- this.matcher = ((JdkMatcher) matcher).getMatcher();
- }
+ @Override
+ public int groups()
+ {
+ return matcher.groupCount();
+ }
- public int groups() {
- return matcher.groupCount();
- }
+ @Override
+ public String group(final int i)
+ {
+ return matcher.group(i);
+ }
- public String group(int i) {
- return matcher.group(i);
- }
+ @Override
+ public int beginOffset(final int i)
+ {
+ return matcher.start(i);
+ }
- public int beginOffset(int i) {
- return matcher.start(i);
- }
+ @Override
+ public int endOffset(final int i)
+ {
+ return matcher.end(i);
+ }
- public int endOffset(int i) {
- return matcher.end(i);
- }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/radeox/regex/JdkMatcher.java b/src/main/java/org/radeox/regex/JdkMatcher.java
new file mode 100644
index 0000000..57bc076
--- /dev/null
+++ b/src/main/java/org/radeox/regex/JdkMatcher.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.regex;
+
+/**
+ * Matcher matches regular expressions (Pattern) to input Implementation for
+ * regex package in JDK 1.4
+ *
+ * @author stephan
+ * @team sonicteam
+ * @version $Id: JdkMatcher.java,v 1.5 2004/04/16 09:10:38 stephan Exp $
+ */
+public class JdkMatcher extends Matcher
+{
+ private final JdkPattern pattern;
+ private final String input;
+ private final java.util.regex.Matcher internalMatcher;
+
+ @Override
+ public String substitute(final Substitution substitution)
+ {
+ final MatchResult matchResult = new JdkMatchResult(internalMatcher);
+ final StringBuffer buffer = new StringBuffer();
+ while(internalMatcher.find())
+ {
+ internalMatcher.appendReplacement(buffer, "");
+ substitution.handleMatch(buffer, matchResult);
+ }
+ internalMatcher.appendTail(buffer);
+ return buffer.toString();
+ }
+
+ @Override
+ public String substitute(final String substitution)
+ {
+ return internalMatcher.replaceAll(substitution);
+ }
+
+ protected java.util.regex.Matcher getMatcher()
+ {
+ return internalMatcher;
+ }
+
+ public JdkMatcher(final String input, final Pattern pattern)
+ {
+ this.input = input;
+ this.pattern = (JdkPattern) pattern;
+ internalMatcher = this.pattern.getPattern().matcher(this.input);
+
+ }
+
+ @Override
+ public boolean contains()
+ {
+ internalMatcher.reset();
+ return internalMatcher.find();
+ }
+
+ @Override
+ public boolean matches()
+ {
+ return internalMatcher.matches();
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/regex/JdkPattern.java b/src/main/java/org/radeox/regex/JdkPattern.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/JdkPattern.java
rename to src/main/java/org/radeox/regex/JdkPattern.java
diff --git a/main/trunk/src/java/org/radeox/regex/MatchResult.java b/src/main/java/org/radeox/regex/MatchResult.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/MatchResult.java
rename to src/main/java/org/radeox/regex/MatchResult.java
diff --git a/main/trunk/src/java/org/radeox/regex/Matcher.java b/src/main/java/org/radeox/regex/Matcher.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/Matcher.java
rename to src/main/java/org/radeox/regex/Matcher.java
diff --git a/main/trunk/src/java/org/radeox/regex/OroActionSubstitution.java b/src/main/java/org/radeox/regex/OroActionSubstitution.java
similarity index 51%
rename from main/trunk/src/java/org/radeox/regex/OroActionSubstitution.java
rename to src/main/java/org/radeox/regex/OroActionSubstitution.java
index 0f94d52..8f9d947 100644
--- a/main/trunk/src/java/org/radeox/regex/OroActionSubstitution.java
+++ b/src/main/java/org/radeox/regex/OroActionSubstitution.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,34 +16,38 @@
* limitations under the License.
*/
-
package org.radeox.regex;
-import org.apache.oro.text.regex.*;
import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.PatternMatcher;
+import org.apache.oro.text.regex.PatternMatcherInput;
+import org.apache.oro.text.regex.StringSubstitution;
-/*
- * Called with a MatchResult which is substituted
- * This implementation is needed by Jakarta ORO
+/**
+ * Called with a MatchResult which is substituted This implementation is needed
+ * by Jakarta ORO.
*
* @author stephan
* @team sonicteam
* @version $Id: OroActionSubstitution.java,v 1.1 2004/04/20 13:45:36 stephan Exp $
*/
+public class OroActionSubstitution extends StringSubstitution
+{
+ private final org.radeox.regex.Substitution substitution;
-public class OroActionSubstitution extends StringSubstitution {
- private org.radeox.regex.Substitution substitution;
+ public OroActionSubstitution(final Substitution substitution)
+ {
+ this.substitution = substitution;
+ }
- public OroActionSubstitution(Substitution substitution) {
- this.substitution = substitution;
- }
+ @Override
+ public void appendSubstitution(final StringBuffer stringBuffer,
+ final MatchResult matchResult, final int i,
+ final PatternMatcherInput patternMatcherInput,
+ final PatternMatcher patternMatcher,
+ final org.apache.oro.text.regex.Pattern pattern)
+ {
+ substitution.handleMatch(stringBuffer, new OroMatchResult(matchResult));
+ }
- public void appendSubstitution(StringBuffer stringBuffer,
- MatchResult matchResult,
- int i,
- PatternMatcherInput patternMatcherInput,
- PatternMatcher patternMatcher,
- org.apache.oro.text.regex.Pattern pattern) {
- substitution.handleMatch(stringBuffer, new OroMatchResult(matchResult));
- }
-}
\ No newline at end of file
+}
diff --git a/main/trunk/src/java/org/radeox/regex/OroCompiler.java b/src/main/java/org/radeox/regex/OroCompiler.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/OroCompiler.java
rename to src/main/java/org/radeox/regex/OroCompiler.java
diff --git a/main/trunk/src/java/org/radeox/regex/OroMatchResult.java b/src/main/java/org/radeox/regex/OroMatchResult.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/OroMatchResult.java
rename to src/main/java/org/radeox/regex/OroMatchResult.java
diff --git a/main/trunk/src/java/org/radeox/regex/OroMatcher.java b/src/main/java/org/radeox/regex/OroMatcher.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/OroMatcher.java
rename to src/main/java/org/radeox/regex/OroMatcher.java
diff --git a/main/trunk/src/java/org/radeox/regex/OroPattern.java b/src/main/java/org/radeox/regex/OroPattern.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/OroPattern.java
rename to src/main/java/org/radeox/regex/OroPattern.java
diff --git a/main/trunk/src/java/org/radeox/regex/Pattern.java b/src/main/java/org/radeox/regex/Pattern.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/regex/Pattern.java
rename to src/main/java/org/radeox/regex/Pattern.java
diff --git a/main/trunk/src/java/org/radeox/regex/Substitution.java b/src/main/java/org/radeox/regex/Substitution.java
similarity index 64%
rename from main/trunk/src/java/org/radeox/regex/Substitution.java
rename to src/main/java/org/radeox/regex/Substitution.java
index 9689ef9..bb855b4 100644
--- a/main/trunk/src/java/org/radeox/regex/Substitution.java
+++ b/src/main/java/org/radeox/regex/Substitution.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -19,23 +19,26 @@
package org.radeox.regex;
-/*
- * Called with a MatchResult which is substituted
+/**
+ * Called with a MatchResult which is substituted.
*
* @author stephan
* @team sonicteam
* @version $Id: Substitution.java,v 1.3 2004/04/20 09:47:03 stephan Exp $
*/
-
-public interface Substitution {
- /**
- * When substituting matches in a matcher, the handleMatch method
- * of the supplied substitution is called with a MatchResult.
- * This method then does something with the match and replaces
- * the match with some output, like replace all 2*2 with (2*2 =) 4.
- *
- * @param buffer StringBuffer to append the output to
- * @param result MatchResult with the match
- */
+public interface Substitution
+{
+ /**
+ * When substituting matches in a matcher, the handleMatch method of the
+ * supplied substitution is called with a MatchResult.
+ *
+ * This method then does something with the match and replaces the match with
+ * some output, like replace all 2*2 with (2*2 =) 4.
+ *
+ *
+ * @param buffer StringBuilder to append the output to
+ * @param result MatchResult with the match
+ */
public void handleMatch(StringBuffer buffer, MatchResult result);
+
}
\ No newline at end of file
diff --git a/src/main/java/org/radeox/util/Encoder.java b/src/main/java/org/radeox/util/Encoder.java
new file mode 100644
index 0000000..a49a27c
--- /dev/null
+++ b/src/main/java/org/radeox/util/Encoder.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.radeox.regex.MatchResult;
+import org.radeox.regex.Matcher;
+import org.radeox.regex.Pattern;
+import org.radeox.regex.Substitution;
+
+/**
+ * Escapes and encodes Strings for web usage.
+ *
+ * @author stephan
+ * @version $Id: Encoder.java,v 1.8 2004/09/06 19:25:33 leo Exp $
+ */
+public class Encoder
+{
+ private static final String DELIMITER = "&\"'<>[]";
+ private static final Map ESCAPED_CHARS = new HashMap<>();
+
+ static
+ {
+ ESCAPED_CHARS.put("&", toEntity('&'));
+ ESCAPED_CHARS.put("\"", toEntity('"'));
+ ESCAPED_CHARS.put("'", toEntity('\''));
+ ESCAPED_CHARS.put(">", toEntity('>'));
+ ESCAPED_CHARS.put("<", toEntity('<'));
+ ESCAPED_CHARS.put("[", toEntity('['));
+ ESCAPED_CHARS.put("]", toEntity(']'));
+ }
+
+ /**
+ * Encoder special characters that may occur in a HTML so it can be displayed
+ * safely.
+ *
+ * @param str the original string
+ * @return the escaped string
+ */
+ public static String escape(final String str)
+ {
+ final StringBuilder result = new StringBuilder();
+ final StringTokenizer tokenizer = new StringTokenizer(str, DELIMITER,
+ true);
+ while(tokenizer.hasMoreTokens())
+ {
+ final String currentToken = tokenizer.nextToken();
+ if(ESCAPED_CHARS.containsKey(currentToken))
+ {
+ result.append(ESCAPED_CHARS.get(currentToken));
+ }
+ else
+ {
+ result.append(currentToken);
+ }
+ }
+ return result.toString();
+ }
+
+ public static String unescape(final String str)
+ {
+ final StringBuilder result = new StringBuilder();
+
+ final org.radeox.regex.Compiler compiler = org.radeox.regex.Compiler.create();
+ final Pattern entityPattern = compiler.compile("&(#?[0-9a-fA-F]+);");
+
+ final Matcher matcher = Matcher.create(str, entityPattern);
+ result.append(matcher.substitute(new Substitution()
+ {
+ @Override
+ public void handleMatch(final StringBuffer buffer, final MatchResult result)
+ {
+ buffer.append(toChar(result.group(1)));
+ }
+ }));
+ return result.toString();
+ }
+
+ public static String toEntity(final int c)
+ {
+ return "" + c + ";";
+ }
+
+ public static char toChar(final String number)
+ {
+ return (char) Integer.decode(number.substring(1)).intValue();
+ }
+
+}
diff --git a/src/main/java/org/radeox/util/Service.java b/src/main/java/org/radeox/util/Service.java
new file mode 100644
index 0000000..28dda7c
--- /dev/null
+++ b/src/main/java/org/radeox/util/Service.java
@@ -0,0 +1,262 @@
+package org.radeox.util;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * After the Service class from Sun and the Apache project. With help from
+ * Frédéric Miserey.
+ *
+ * credits Frédéric Miserey, Joseph Oettinger
+ *
+ * @author Matthias L. Jugel
+ * @version $id$
+ */
+public class Service
+{
+ private static final Log LOG = LogFactory.getLog(Service.class);
+
+ public static final int RESOURCE = 0;
+ public static final int CLASS = 1;
+ public static final int INSTANCE = 2;
+
+ static HashMap services = new HashMap();
+
+ public static synchronized Iterator providerNames(final Class cls)
+ {
+ return providers(cls, Service.RESOURCE);
+ }
+
+ public static synchronized Iterator
+ providerClasses(final Class cls)
+ {
+ return providers(cls, false);
+ }
+
+ public static synchronized Iterator providers(final Class cls)
+ {
+ return providers(cls, true);
+ }
+
+ public static synchronized Iterator providers(final Class cls,
+ final boolean instantiate)
+ {
+ return providers(cls, instantiate ? Service.INSTANCE : Service.CLASS);
+ }
+
+ public static synchronized Iterator providers(final Class cls,
+ final int providerKind)
+ {
+ final ClassLoader cl = cls.getClassLoader();
+ String providerFile = "META-INF/services/" + cls.getName();
+
+ // check whether we already loaded the provider classes
+ List providers = (List) services.get(providerFile);
+ if(providers != null)
+ {
+ return providers.iterator();
+ }
+
+ // create new list of providers
+ providers = new ArrayList<>();
+ services.put(providerFile, providers);
+
+ try
+ {
+ // get all files with the name providerFile out of all jar files
+ final Enumeration providerFiles = cl
+ .getResources(providerFile);
+
+ if(providerFiles.hasMoreElements())
+ {
+ // cycle through the provider files and load classes
+ while(providerFiles.hasMoreElements())
+ {
+ final URL url = providerFiles.nextElement();
+ try(final Reader reader = new InputStreamReader(
+ url.openStream(), UTF_8))
+ {
+ switch (providerKind)
+ {
+ case Service.RESOURCE:
+ loadResources(reader, cl, (List) providers);
+ break;
+ case Service.CLASS:
+ loadClasses(reader, cl, (List) providers);
+ break;
+ case Service.INSTANCE:
+ loadInstances(reader, cl, providers);
+ break;
+ }
+ }
+ catch(final Exception ex)
+ {
+ LOG.error("Error reading file: " + providerFile, ex);
+ // ex.printStackTrace();
+ // Just try the next file...
+ }
+ }
+ }
+ else
+ {
+ // Workaround for broken classloaders, e.g. Orion
+ InputStream is = cl.getResourceAsStream(providerFile);
+ if(is == null)
+ {
+ providerFile = providerFile
+ .substring(providerFile.lastIndexOf('.') + 1);
+ is = cl.getResourceAsStream(providerFile);
+ }
+ if(is != null)
+ {
+ final Reader reader = new InputStreamReader(is, UTF_8);
+ loadInstances(reader, cl, providers);
+ }
+ }
+ }
+ catch(final IOException ioe)
+ {
+ // ioe.printStackTrace();
+ // ignore exception
+ }
+ return providers.iterator();
+ }
+
+ private static void loadResources(final Reader input,
+ final ClassLoader classLoader, final List providers)
+ throws IOException
+ {
+ final BufferedReader reader = new BufferedReader(input);
+ String line = reader.readLine();
+ while(line != null)
+ {
+ providers.add(line);
+ line = reader.readLine();
+ }
+ }
+
+ private static void loadClasses(final Reader input, final ClassLoader cl,
+ final List> classes) throws IOException
+ {
+ for(final String className : readLines(input))
+ {
+ try
+ {
+ classes.add(cl.loadClass(className));
+ }
+ catch(final ClassNotFoundException e)
+ {
+ // ignore silently
+ }
+ }
+ }
+
+ private static void loadInstances(final Reader input,
+ final ClassLoader cl, final List providers) throws IOException
+ {
+ for(String className : readLines(input))
+ {
+ final int modifierIndex = className.indexOf('_');
+ String modifier = null;
+ if(modifierIndex != -1)
+ {
+ modifier = className.substring(modifierIndex + 1);
+ className = className.substring(0, modifierIndex);
+ }
+ try
+ {
+ final Class> klass = cl.loadClass(className);
+ final C obj = (C) klass.newInstance();
+ if(null != modifier)
+ {
+ final Method setModifierMethod = klass
+ .getMethod("setModifier", String.class);
+ setModifierMethod.invoke(obj, modifier);
+ }
+ // stick it into our vector...
+ providers.add(obj);
+ }
+ catch(final NoSuchMethodException e)
+ {
+ // ignore silently
+ }
+ catch(final InvocationTargetException e)
+ {
+ // ignore silently
+ }
+ catch(final ClassNotFoundException e)
+ {
+ // ignore silently
+ }
+ catch(final InstantiationException e)
+ {
+ e.printStackTrace();
+ }
+ catch(final IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ // Logger.debug("Service: loaded "+ obj.getClass().getName());
+ }
+ }
+
+ /**
+ * Read all lines from the reader and filter out comment lines starting with
+ * a hash mark (#)
+ *
+ * @param input the stream reader to contain lines
+ * @return a list containing all significant lines
+ * @throws IOException if the reader was interrupted
+ */
+ private static List readLines(final Reader input) throws IOException
+ {
+ final List linesList = new ArrayList<>();
+
+ final BufferedReader reader = new BufferedReader(input);
+ String line;
+ while((line = reader.readLine()) != null)
+ {
+ try
+ {
+ // strip comments out of the stream
+ final int idx = line.indexOf('#');
+ if(idx != -1)
+ {
+ line = line.substring(0, idx);
+ }
+
+ // Trim whitespace
+ line = line.trim();
+
+ // store line if there is still more than spaces on it
+ if(line.length() > 0)
+ {
+ linesList.add(line);
+ }
+ }
+ catch(final Exception ex)
+ {
+ // ex.printStackTrace();
+ // Just try the next line
+ }
+ }
+ return linesList;
+ }
+
+}
diff --git a/src/main/java/org/radeox/util/StringBufferWriter.java b/src/main/java/org/radeox/util/StringBufferWriter.java
new file mode 100644
index 0000000..738d5e9
--- /dev/null
+++ b/src/main/java/org/radeox/util/StringBufferWriter.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.util;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * The same as StringWriter, but takes an existing StringBuilder in its
+ * constructor.
+ *
+ * @author Stephan J. Schmidt
+ * @version $Id: StringBufferWriter.java,v 1.2 2003/02/06 13:41:42 leo Exp $
+ */
+public class StringBufferWriter extends Writer
+{
+
+ private final StringBuffer buffer;
+
+ public StringBufferWriter(final StringBuffer buffer)
+ {
+ this.buffer = buffer;
+ this.lock = buffer;
+ }
+
+ public StringBufferWriter()
+ {
+ this.buffer = new StringBuffer();
+ this.lock = buffer;
+ }
+
+ public StringBufferWriter(final int initialSize)
+ {
+ if(initialSize < 0)
+ {
+ throw new IllegalArgumentException("Negative buffer size");
+ }
+ buffer = new StringBuffer(initialSize);
+ lock = buffer;
+ }
+
+ @Override
+ public void write(final int c)
+ {
+ buffer.append((char) c);
+ }
+
+ @Override
+ public void write(final char cbuf[], final int off, final int len)
+ {
+ if((off < 0) || (off > cbuf.length) || (len < 0) ||
+ ((off + len) > cbuf.length) || ((off + len) < 0))
+ {
+ throw new IndexOutOfBoundsException();
+ }
+ else if(len == 0)
+ {
+ return;
+ }
+ buffer.append(cbuf, off, len);
+ }
+
+ @Override
+ public void write(final String str)
+ {
+ buffer.append(str);
+ }
+
+ @Override
+ public void write(final String str, final int off, final int len)
+ {
+ buffer.append(str.substring(off, off + len));
+ }
+
+ @Override
+ public String toString()
+ {
+ return buffer.toString();
+ }
+
+ public StringBuffer getBuffer()
+ {
+ return buffer;
+ }
+
+ @Override
+ public void flush()
+ {
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ }
+
+}
diff --git a/src/main/java/org/radeox/util/i18n/BaseResourceBundle.java b/src/main/java/org/radeox/util/i18n/BaseResourceBundle.java
new file mode 100644
index 0000000..1bfc858
--- /dev/null
+++ b/src/main/java/org/radeox/util/i18n/BaseResourceBundle.java
@@ -0,0 +1,62 @@
+package org.radeox.util.i18n;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * String resource bundle.
+ *
+ *
Created on 2025-06-02
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class BaseResourceBundle
+{
+ private static final Log LOG = LogFactory.getLog(BaseResourceBundle.class);
+
+ private final String baseName;
+ private final ResourceBundle bundle;
+
+ public BaseResourceBundle(final String baseName, final ResourceBundle bundle)
+ {
+ this.baseName = baseName;
+ this.bundle = bundle;
+ }
+
+ /**
+ * Always returns string value of given key.
+ *
+ * @param key searched key
+ * @return value of the key or "???" + key + "???" if not found
+ */
+ public String getString(final String key)
+ {
+ try
+ {
+ return bundle.getString(key);
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("missing resource for bundle '" + baseName + "', key '" +
+ key + "'", e);
+ return "???" + key + "???";
+ }
+ }
+
+ /**
+ * Returns known value of given key or throws an expception.
+ *
+ * @param key searched key
+ * @return found value fo the searched key
+ * @throws MissingResourceException when value not found
+ */
+ public String get(final String key) throws MissingResourceException
+ {
+ return bundle.getString(key);
+ }
+
+}
diff --git a/src/main/java/org/radeox/util/i18n/ResourceManager.java b/src/main/java/org/radeox/util/i18n/ResourceManager.java
new file mode 100644
index 0000000..c233ca9
--- /dev/null
+++ b/src/main/java/org/radeox/util/i18n/ResourceManager.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.util.i18n;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A Resource Manager implementation to aid the use of locales. It works similar
+ * to what the bundle tag in jstl fmt taglibs does but adapted for use withing a
+ * threaded java environment.
+ *
+ * @author Matthias L. Jugel
+ * @version $Id: ResourceManager.java,v 1.5 2004/06/08 07:54:37 leo Exp $
+ */
+public class ResourceManager
+{
+ private static final Log LOG = LogFactory.getLog(ResourceManager.class);
+ private static final List FALLBACK = Collections.singletonList(new Locale("en_US"));
+
+ private final Locale locale;
+ private final ConcurrentHashMap resourceBundles;
+
+ public ResourceManager(final Locale locale)
+ {
+ this.locale = locale;
+ this.resourceBundles = new ConcurrentHashMap<>();
+ }
+
+ /**
+ * Get the bundle that is active for this thread. This is done by loading
+ * either the specified locale based resource bundle and, if that fails, by
+ * looping through the fallback locales to locate a usable bundle.
+ *
+ * @return the resource bundle
+ */
+ public BaseResourceBundle getResourceBundle(final String baseName)
+ {
+ return resourceBundles.computeIfAbsent(baseName, this::findBundle);
+ }
+
+ /**
+ * Find a resource bundle by looking up using the locales. This is done by
+ * loading either the specified locale based resource bundle and, if that
+ * fails, by looping through the fallback locales to locate a usable bundle.
+ */
+ private BaseResourceBundle findBundle(final String baseName)
+ {
+ ResourceBundle resourceBundle = null;
+
+ // first try to load the resource bundle with the specified locale
+ final ClassLoader cl = getClass().getClassLoader();
+ try
+ {
+ resourceBundle = ResourceBundle.getBundle(baseName, locale, cl);
+ // check that the requested main locale matches the resource bundle's,
+ // since we get the system fallback locale if no match is found
+ if(!resourceBundle.getLocale().equals(locale))
+ {
+ LOG.warn("loaded bundle locale differs requested locale. Requestet locale: " +
+ locale + ", bundle locale: " + resourceBundle.getLocale());
+ }
+ }
+ catch(final Exception e)
+ {
+ LOG.warn("unable to load a default bundle: " + baseName + "_" + locale, e);
+ }
+
+ // loop through the fall back locales until a bundle is found
+ if(resourceBundle == null)
+ {
+ resourceBundle = getFallbackBundle(baseName, cl);
+
+ // make sure the resource bundle is loaded (should not happen)
+ if(resourceBundle == null)
+ {
+ resourceBundle = ResourceBundle.getBundle(baseName);
+ if(null != resourceBundle)
+ {
+ LOG.debug("system locale bundle taken: " + baseName + "_" +
+ resourceBundle.getLocale());
+ }
+ }
+ }
+ return new BaseResourceBundle(baseName, resourceBundle);
+ }
+
+ private ResourceBundle getFallbackBundle(final String baseName, final ClassLoader cl)
+ {
+ ResourceBundle resourceBundle = null;
+ for(final Locale testLocale : FALLBACK)
+ {
+ LOG.debug("looking up locale " + testLocale);
+ try
+ {
+ final ResourceBundle testBundle = ResourceBundle.getBundle(baseName, testLocale, cl);
+ final Locale foundLocale = testBundle.getLocale();
+ final String language = foundLocale.getLanguage();
+ final String country = foundLocale.getCountry();
+
+ if(foundLocale.equals(testLocale))
+ {
+ resourceBundle = testBundle;
+ LOG.debug("found bundle for locale " + baseName + "_" + foundLocale);
+ break;
+ }
+ else if(testLocale.getLanguage().equals(language))
+ {
+ if(testLocale.getCountry().equals(country))
+ {
+ // language and country match which is good, keep
+ // looking for variant too
+ resourceBundle = testBundle;
+ LOG.debug("potential bundle: " + baseName + "_" + foundLocale);
+ }
+ else
+ {
+ // only accept this if there is no better previous lookup
+ if(resourceBundle == null)
+ {
+ resourceBundle = testBundle;
+ LOG.debug("potential bundle: " + baseName + "_" + foundLocale);
+ }
+ }
+ }
+ }
+ catch(final MissingResourceException e)
+ {
+ LOG.debug("not found bundle for locale " + baseName + "_" + testLocale);
+ }
+ }
+ return resourceBundle;
+ }
+
+}
diff --git a/main/trunk/src/java/org/radeox/util/logging/LogHandler.java b/src/main/java/org/radeox/util/logging/LogHandler.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/util/logging/LogHandler.java
rename to src/main/java/org/radeox/util/logging/LogHandler.java
diff --git a/main/trunk/src/java/org/radeox/util/logging/Logger.java b/src/main/java/org/radeox/util/logging/Logger.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/util/logging/Logger.java
rename to src/main/java/org/radeox/util/logging/Logger.java
diff --git a/main/trunk/src/java/org/radeox/util/logging/NullLogger.java b/src/main/java/org/radeox/util/logging/NullLogger.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/util/logging/NullLogger.java
rename to src/main/java/org/radeox/util/logging/NullLogger.java
diff --git a/main/trunk/src/java/org/radeox/util/logging/SystemErrLogger.java b/src/main/java/org/radeox/util/logging/SystemErrLogger.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/util/logging/SystemErrLogger.java
rename to src/main/java/org/radeox/util/logging/SystemErrLogger.java
diff --git a/main/trunk/src/java/org/radeox/util/logging/SystemOutLogger.java b/src/main/java/org/radeox/util/logging/SystemOutLogger.java
similarity index 100%
rename from main/trunk/src/java/org/radeox/util/logging/SystemOutLogger.java
rename to src/main/java/org/radeox/util/logging/SystemOutLogger.java
diff --git a/main/trunk/src/java/simplelog.properties b/src/main/java/simplelog.properties
similarity index 100%
rename from main/trunk/src/java/simplelog.properties
rename to src/main/java/simplelog.properties
diff --git a/main/trunk/src/java/META-INF/services/org.radeox.filter.Filter b/src/main/resources/META-INF/services/org.radeox.filter.Filter
similarity index 88%
rename from main/trunk/src/java/META-INF/services/org.radeox.filter.Filter
rename to src/main/resources/META-INF/services/org.radeox.filter.Filter
index 6c1d829..116f6fa 100644
--- a/main/trunk/src/java/META-INF/services/org.radeox.filter.Filter
+++ b/src/main/resources/META-INF/services/org.radeox.filter.Filter
@@ -24,3 +24,5 @@ org.radeox.filter.LinkTestFilter_Creole
#org.radeox.filter.WikiLinkFilter
#Should be called first, done with before()
org.radeox.filter.EscapeFilter
+#Should be called last, the value of parameters should not be transfomrated
+org.radeox.filter.LiteralParamFilter
diff --git a/main/trunk/src/java/META-INF/services/org.radeox.macro.Macro b/src/main/resources/META-INF/services/org.radeox.macro.Macro
similarity index 94%
rename from main/trunk/src/java/META-INF/services/org.radeox.macro.Macro
rename to src/main/resources/META-INF/services/org.radeox.macro.Macro
index 3ffa049..63e4df9 100644
--- a/main/trunk/src/java/META-INF/services/org.radeox.macro.Macro
+++ b/src/main/resources/META-INF/services/org.radeox.macro.Macro
@@ -15,3 +15,4 @@ org.radeox.macro.RfcMacro
org.radeox.macro.TableMacro
org.radeox.macro.InterWikiMacro
org.radeox.macro.XrefMacro
+org.radeox.macro.ImgMacro
diff --git a/main/trunk/src/java/META-INF/services/org.radeox.macro.code.SourceCodeFormatter b/src/main/resources/META-INF/services/org.radeox.macro.code.SourceCodeFormatter
similarity index 100%
rename from main/trunk/src/java/META-INF/services/org.radeox.macro.code.SourceCodeFormatter
rename to src/main/resources/META-INF/services/org.radeox.macro.code.SourceCodeFormatter
diff --git a/main/trunk/src/java/META-INF/services/org.radeox.macro.list.ListFormatter b/src/main/resources/META-INF/services/org.radeox.macro.list.ListFormatter
similarity index 100%
rename from main/trunk/src/java/META-INF/services/org.radeox.macro.list.ListFormatter
rename to src/main/resources/META-INF/services/org.radeox.macro.list.ListFormatter
diff --git a/main/trunk/src/java/META-INF/services/org.radeox.macro.table.Function b/src/main/resources/META-INF/services/org.radeox.macro.table.Function
similarity index 100%
rename from main/trunk/src/java/META-INF/services/org.radeox.macro.table.Function
rename to src/main/resources/META-INF/services/org.radeox.macro.table.Function
diff --git a/main/trunk/conf/apidocs.txt b/src/main/resources/conf/apidocs.txt
similarity index 100%
rename from main/trunk/conf/apidocs.txt
rename to src/main/resources/conf/apidocs.txt
diff --git a/main/trunk/conf/asinservices.txt b/src/main/resources/conf/asinservices.txt
similarity index 100%
rename from main/trunk/conf/asinservices.txt
rename to src/main/resources/conf/asinservices.txt
diff --git a/main/trunk/conf/bookservices.txt b/src/main/resources/conf/bookservices.txt
similarity index 100%
rename from main/trunk/conf/bookservices.txt
rename to src/main/resources/conf/bookservices.txt
diff --git a/main/trunk/conf/intermap.txt b/src/main/resources/conf/intermap.txt
similarity index 100%
rename from main/trunk/conf/intermap.txt
rename to src/main/resources/conf/intermap.txt
diff --git a/main/trunk/conf/radeox_markup.properties b/src/main/resources/conf/radeox_markup.properties
similarity index 95%
rename from main/trunk/conf/radeox_markup.properties
rename to src/main/resources/conf/radeox_markup.properties
index 8eed820..771273a 100644
--- a/main/trunk/conf/radeox_markup.properties
+++ b/src/main/resources/conf/radeox_markup.properties
@@ -16,6 +16,7 @@ macro.macrolist.name=list-of-macros
macro.rfc.name=rfc
macro.table.name=table
macro.xref.name=xref
+macro.img.name=img
macro.code.start=
macro.code.end=
@@ -72,8 +73,9 @@ filter.linktest.Creole.match=\\[\\[(.*?)\\]\\]
filter.wikilink.match=([A-Z][a-z]+([A-Z][a-z]+)+)
filter.param.match=\\{\\$([^}]*)\\}
+filter.lparam.match=\\{\\$\\$([^}]*)\\}
-filter.list.match=(^[\\p{Space}]*([-#*]+|[-#*]*[iIaA1ghHkKj]+\\.)[\\p{Space}]+([^\r\n]+)[\r\n]*)+
+filter.list.match=(^[\\p{Space}]*([-#*]+|[-#*]*[iIaA1ghHkKj]+\\.)[ ]+([^\r\n]+)[\r\n]*)+
#filter.list.match=^[\\p{Space}]*([-#*]+[\\p{Space}]+|[-#*]?[iIaA1ghHkKj][-#*iIaA1ghHkKj]*\\.[\\p{Space}]+)(\r?\n[\\p{Space}]*(?:([-#*]+[\\p{Space}]+)|([-#*]?[iIaA1ghHkKj][-#*iIaA1ghHkKj]*\\.[\\p{Space}]+))|[^\\r\\n]+)*$
#filter.list.match=^[\\p{Space}]*([-#*]+[\\p{Space}]+|[iIaA1ghHkKj][iIaA1ghHkKj]*[.][\\p{Space}]+)(?:([-#*]+[\\p{Space}]+)|([iIaA1ghHkKj][iIaA1ghHkKj]*[.][\\p{Space}]+)|.+)*$
-filter.list.Creole.match=(^[\\p{Space}]*([#-]+)[\\p{Space}]+([^\r\n]+)[\r\n]*)+
+filter.list.Creole.match=(^[\\p{Space}]*([#-]+)[ ]+([^\r\n]+)[\r\n]*)+
diff --git a/main/trunk/conf/radeox_markup_otherwiki.properties b/src/main/resources/conf/radeox_markup_otherwiki.properties
similarity index 100%
rename from main/trunk/conf/radeox_markup_otherwiki.properties
rename to src/main/resources/conf/radeox_markup_otherwiki.properties
diff --git a/main/trunk/conf/radeox_messages_de.properties b/src/main/resources/conf/radeox_messages_de.properties
similarity index 91%
rename from main/trunk/conf/radeox_messages_de.properties
rename to src/main/resources/conf/radeox_messages_de.properties
index b3c63c1..7080c52 100644
--- a/main/trunk/conf/radeox_messages_de.properties
+++ b/src/main/resources/conf/radeox_messages_de.properties
@@ -40,6 +40,9 @@ macro.macrolist.title.parameters=Parameter
macro.macrolist.title.description=Beschreibung
macro.macrolist.noparams=Keine Parameter.
macro.macrolist.optional=(optional)
+macro.macrolist.label.example=Beispiel
+macro.macrolist.params=\
+ ?1: Anzuzeigende Makronamen. Trennen Sie die einzelnen Elemente mit dem Zeichen |.
macro.mailto.description=Erzeigt einen Verweis auf eine Emailadresse.
macro.mailto.params=1: email adresse
@@ -54,6 +57,10 @@ macro.rfc.description=Erzeugt einen Verweis zu einem RFC.
macro.rfc.params=1: RFC Nummer auf den Verwiesen werden soll.
macro.table.description=Zeigt eine Tabelle an.
+macro.table.example={table} \n\
+ a | b | c \n\
+ d | e | f \n\
+{table}
macro.xref.description=Erzeugt einen Verweis auf XRef Dokumentation.
macro.xref.params=\
diff --git a/main/trunk/conf/radeox_messages_en.properties b/src/main/resources/conf/radeox_messages_en_US.properties
similarity index 78%
rename from main/trunk/conf/radeox_messages_en.properties
rename to src/main/resources/conf/radeox_messages_en_US.properties
index e4283f4..e03c218 100644
--- a/main/trunk/conf/radeox_messages_en.properties
+++ b/src/main/resources/conf/radeox_messages_en_US.properties
@@ -8,7 +8,7 @@ macro.apidocs.description=Displays a list of known online API documentations \
macro.api.description=Generates links to Java or Ruby API documentation.
macro.api.params=\
1: class name, e.g. java.lang.Object or java.lang.Object@Java131 ;\
- ?2: mode, e.g. Java12, Ruby, defaults to Java"
+ ?2: mode, e.g. Java12, Ruby, defaults to Java
macro.asin.description=Generates links to DVD/CD dealers or comparison \
services. Configuration is read from conf/asinservices.txt.
@@ -35,12 +35,15 @@ macro.link.params=\
2: The URL to generate a hyperlink to ;\
?3: none if the external link image should not appear
-macro.macrolist.description=Displays a list of available macros.
+macro.macrolist.description=Displays this list of available macros.
macro.macrolist.title.macro=Macro
macro.macrolist.title.parameters=Parameters
macro.macrolist.title.description=Description
macro.macrolist.noparams=No Parameters.
macro.macrolist.optional=(optional)
+macro.macrolist.label.example=Example
+macro.macrolist.params=\
+ ?1: Macro names to be displaied, use sign | to separate each item
macro.mailto.description=Displays an email address.
macro.mailto.params=1: an Email address
@@ -55,8 +58,20 @@ macro.rfc.description=Generates links to RFCs.
macro.rfc.params=1: the RFC number to link to
macro.table.description=Displays a table.
+macro.table.example={table} \n\
+ a | b | c \n\
+ d | e | f \n\
+{table}
macro.xref.description=Generates links to Java Xref source code.
macro.xref.params=\
1: class name, e.g. java.lang.Object or java.lang.Object@Nanning" ;\
?2: line number
+
+macro.img.description=Displays image, taken from attachment
+macro.img.params=\
+ ?1: width=10% - width, (or w=10%) ;\
+ ?2: height=2em - height (or h=2em) ;\
+ ?3: left/l/right/r/center/c - position ;\
+ 4: filename.png - file to render
+macro.img.example={img:width=3em|right|image01.png}
diff --git a/src/main/resources/conf/radeox_messages_pl_PL.properties b/src/main/resources/conf/radeox_messages_pl_PL.properties
new file mode 100644
index 0000000..63359ec
--- /dev/null
+++ b/src/main/resources/conf/radeox_messages_pl_PL.properties
@@ -0,0 +1,78 @@
+# Macro Localization
+#
+# 1. Multiple parameter descriptions are delimited by a semicolon (;)
+
+macro.apidocs.description=Wyswietla liste znanych dokumentacji API i ich mapowania.
+
+macro.api.description=Generuje link do dokumentacji API dla Java lub Ruby.
+macro.api.params=\
+ 1: nazwa klasy, np. java.lang.Object or java.lang.Object@Java131 ;\
+ ?2: tryb, np. Java12, Ruby, domyslnie Java
+
+macro.asin.description=Generuje linki do sprzedawcow DVD/CD lub uslug porownawczych. \
+ services. Konfiguracja jest odczytywana z conf/asinservices.txt.
+macro.asin.params=1: ASIN numer DVD lub CD
+
+macro.code.description=Wyswietla fragment kodu zrodlowego podswietlajac skladnie dla \
+ np. Java, XML i SQL. The 'none' typ nie robi nic, uzyteczny, gdy nie znanego typu \
+ skladni
+macro.code.params=?1: java/xml/sql/none - wybrany jezyk, domyslnie java
+
+macro.filepath.description=Wyswietla sciezke systemowa do pliku w stylu Windows. \
+ Sciezka zrodlowa moze uzywac dowolnego ukosnika.
+macro.filepath.params=1: sciezka w stylu Windows lub UNIX
+
+macro.interwiki.description=Wyswietla liste znanych mapowan InterWiki.
+
+macro.isbn.description=Generuje linki do sprzedawcow ksiazek lub uslug porownawczych. \
+ Konfiguracja jest odczytywana z conf/bookservices.txt.
+macro.isbn.params=1: ISBN numer ksiazki lub czasopisma
+
+macro.link.description=Generuje link.
+macro.link.params=\
+ ?1: tekst pojawiajacy sie w linku ;\
+ 2: URL na który ma wskazywac link ;\
+ ?3: none jesli grafika linku zewnetrznego nie powinna sie pojawic
+
+macro.macrolist.description=Wyswietla liste dostepnych makr.
+macro.macrolist.title.macro=Makro
+macro.macrolist.title.parameters=Parametry
+macro.macrolist.title.description=Opis
+macro.macrolist.noparams=Brak parametrow.
+macro.macrolist.optional=(opcjonalny)
+macro.macrolist.label.example=Przyklad
+macro.macrolist.params=\
+ ?1: nazwy makr do wyswietlenia odzielone znakiem |
+
+macro.mailto.description=Wyswietla adres Email.
+macro.mailto.params=1: adres Email do wyswietlenia
+macro.mailto.example={mailto:example@example.org}
+
+macro.quote.description=Wyswietla cytaty.
+macro.quote.params=\
+ ?1: tekst zrodlowy ;\
+ ?2: wyswietla opis (domyslnie "Cytat")
+macro.quote.source=Cytat
+
+macro.rfc.description=Generuje linki do RFC.
+macro.rfc.params=1: numer RFC
+
+macro.table.description=Wyswietla tabele.
+macro.table.example={table} \n\
+ a | b | c \n\
+ d | e | f \n\
+{table}
+
+macro.xref.description=Generuje lini do Java Xref.
+macro.xref.params=\
+ 1: nazwa klasy, np. java.lang.Object lub java.lang.Object@Nanning" ;\
+ ?2: numer linii
+
+macro.img.description=Wyswietla grafike, pobrana z zalacznika
+macro.img.params=\
+ ?1: width=10% - szerokosc, (lub w=10%) ;\
+ ?2: height=2em - wysokosc (lub h=2em) ;\
+ ?3: left/l/right/r/center/c - pozycja ;\
+ 4: filename.png - nazwa pliku, taka sama jak w zalaczniku
+macro.img.example={img:width=3em|right|image01.png}
+
\ No newline at end of file
diff --git a/main/trunk/conf/wiki.txt b/src/main/resources/conf/wiki.txt
similarity index 100%
rename from main/trunk/conf/wiki.txt
rename to src/main/resources/conf/wiki.txt
diff --git a/main/trunk/conf/xref.txt b/src/main/resources/conf/xref.txt
similarity index 100%
rename from main/trunk/conf/xref.txt
rename to src/main/resources/conf/xref.txt
diff --git a/main/trunk/src/test/org/radeox/BaseRenderEngineTest.java b/src/test/java/org/radeox/BaseRenderEngineTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/BaseRenderEngineTest.java
rename to src/test/java/org/radeox/BaseRenderEngineTest.java
diff --git a/src/test/java/org/radeox/PerformanceTests.java b/src/test/java/org/radeox/PerformanceTests.java
new file mode 100644
index 0000000..130132e
--- /dev/null
+++ b/src/test/java/org/radeox/PerformanceTests.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.engine.BaseRenderEngine;
+import org.radeox.engine.context.BaseRenderContext;
+
+import com.clarkware.junitperf.TimedTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class PerformanceTests
+{
+ public static Test suite() throws IOException
+ {
+ // get test markup from text file
+ final InputStream wiki = PerformanceTests.class.getClassLoader()
+ .getResourceAsStream("wiki.txt");
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(wiki));
+ final StringBuilder input = new StringBuilder();
+ String tmp;
+ while((tmp = reader.readLine()) != null)
+ {
+ input.append(tmp);
+ }
+ final RenderEngine engine = new BaseRenderEngine();
+ System.err
+ .println(engine.render("__initialized__", new BaseRenderContext()));
+
+ final TestSuite s = new TestSuite();
+ final long maxElapsedTime = 30 * 1000; // 30s
+ final StringBuilder testString = new StringBuilder();
+ for(int i = 0; i < 10; i++)
+ {
+ testString.append(input);
+ final Test renderEngineTest = new RenderEnginePerformanceTest(
+ testString.toString());
+ final Test timedTest = new TimedTest(renderEngineTest,
+ maxElapsedTime, false);
+ s.addTest(timedTest);
+ }
+ return s;
+ }
+
+}
diff --git a/src/test/java/org/radeox/RegexpTest.java b/src/test/java/org/radeox/RegexpTest.java
new file mode 100644
index 0000000..969a655
--- /dev/null
+++ b/src/test/java/org/radeox/RegexpTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.engine.BaseRenderEngine;
+import org.radeox.engine.context.BaseRenderContext;
+
+public class RegexpTest
+{
+ public static void main(final String[] args)
+ {
+ final String file = args.length > 0 ? args[0] : "conf/wiki.txt";
+ try
+ {
+ System.setOut(new PrintStream(System.out, true, "UTF-8"));
+ }
+ catch(final UnsupportedEncodingException e)
+ {
+ // this should never happen
+ }
+
+ final StringBuilder tmp = new StringBuilder();
+ try(final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)))
+ {
+ final char[] buffer = new char[1024];
+ int n = 0;
+ while((n = reader.read(buffer)) != -1)
+ {
+ tmp.append(buffer, 0, n);
+ }
+ }
+ catch(final Exception e)
+ {
+ System.err.println("File not found: " + e.getMessage());
+ }
+
+ final String content = tmp.toString();
+
+ try
+ {
+ final PrintWriter out = new PrintWriter(
+ new OutputStreamWriter(System.out, "UTF-8"));
+ out.println(content);
+ out.flush();
+
+ final RenderContext context = new BaseRenderContext();
+ final RenderEngine engine = new BaseRenderEngine();
+
+ final long now = System.currentTimeMillis();
+ final String output = engine.render(content, context);
+ final long dif = System.currentTimeMillis() - now;
+
+ System.err.println("time spent: " + dif + "ms");
+ out.println(output);
+ out.flush();
+ out.close();
+ }
+ catch(final UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/main/trunk/src/test/org/radeox/RenderEnginePerformanceTest.java b/src/test/java/org/radeox/RenderEnginePerformanceTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/RenderEnginePerformanceTest.java
rename to src/test/java/org/radeox/RenderEnginePerformanceTest.java
diff --git a/src/test/java/org/radeox/filter/BasicRegexTest.java b/src/test/java/org/radeox/filter/BasicRegexTest.java
new file mode 100644
index 0000000..a1f904c
--- /dev/null
+++ b/src/test/java/org/radeox/filter/BasicRegexTest.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter;
+
+import java.text.MessageFormat;
+
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.engine.context.BaseRenderContext;
+import org.radeox.filter.context.BaseFilterContext;
+import org.radeox.filter.context.FilterContext;
+import org.radeox.filter.regex.RegexReplaceFilter;
+import org.radeox.filter.regex.RegexTokenFilter;
+import org.radeox.macro.code.XmlCodeFilter;
+import org.radeox.regex.MatchResult;
+import org.radeox.regex.Matcher;
+import org.radeox.regex.Pattern;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class BasicRegexTest extends TestCase
+{
+ private static final String BOLD_TEST_REGEX = "(^|>|[[:space:]]+)__(.*?)__([[:space:]]+|<|$)";
+ private org.radeox.regex.Compiler compiler;
+
+ public BasicRegexTest(final String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ compiler = org.radeox.regex.Compiler.create();
+ compiler.setMultiline(true);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(BasicRegexTest.class);
+ }
+
+ // filter.heading.match=^[[:space:]]*(1(\\.1)*)[[:space:]]+(.*?)$
+ // filter.heading.print=
{1}
+
+ public void testStartEnd()
+ {
+ final Pattern p = compiler.compile("^A.*B$");
+ final Matcher m = Matcher.create("A1234567B", p);
+ assertTrue("^...$ pattern found", m.matches());
+ }
+
+ public void testHeading()
+ {
+ final FilterContext context = new BaseFilterContext();
+ context.setRenderContext(new BaseRenderContext());
+ final Filter filter = new HeadingFilter();
+ filter.setInitialContext(InitialRenderContext.defaultContext());
+ assertEquals("Heading replaced", "
test
",
+ filter.filter("1 test", context));
+ }
+
+ public void testByHandHeading()
+ {
+ final RegexTokenFilter filter = new RegexTokenFilter()
+ {
+ @Override
+ public void handleMatch(final StringBuffer buffer,
+ final MatchResult result, final FilterContext context)
+ {
+ final String outputTemplate = "
{1}
";
+ final MessageFormat formatter = new MessageFormat("");
+ formatter.applyPattern(outputTemplate);
+ buffer.append(formatter.format(new Object[] {
+ result.group(1).replace('.', '-'), result.group(3)}));
+ }
+ };
+ filter.addRegex("^[\\p{Space}]*(1(\\.1)*)[\\p{Space}]+(.*?)$", "");
+ final FilterContext context = new BaseFilterContext();
+ context.setRenderContext(new BaseRenderContext());
+ assertEquals("Heading replaced",
+ "
testHand
",
+ filter.filter("1 testHand", context));
+ }
+
+ public void testWordBorders()
+ {
+ final Pattern p = compiler.compile("\\bxsl\\b");
+ Matcher m = Matcher.create("test xsl test", p);
+ assertTrue("Word found", m.contains());
+ m = Matcher.create("testxsltest", p);
+ assertTrue("Word not found", !m.contains());
+ }
+
+ public void testByHandUrl()
+ {
+ // ([^\"'=]|^)
+ // Pattern p =
+ // Pattern.compile("((http|ftp)s?://(%[[:digit:]A-Fa-f][[:digit:]A-Fa-f]|[-_.!~*';/?:@#&=+$,[:alnum:]])+)",
+ // Pattern.MULTILINE);
+ final Pattern p = compiler
+ .compile("(http|ftp)s?://([-_.!~*';/?:@#&=+$,\\p{Alnum}])+");
+ final Matcher m = Matcher.create("http://snipsnap.org", p);
+ assertTrue("A Url found", m.matches());
+ }
+
+ public void testXmlCodeFilter()
+ {
+ final Pattern p = compiler.compile("\"(([^\"\\\\]|\\.)*)\"");
+ final Matcher m = Matcher.create("", p);
+
+ assertEquals("Quote replaced",
+ "\"attr\"/>",
+ m.substitute("\"$1\""));
+
+ final XmlCodeFilter xmlCodeFilter = new XmlCodeFilter();
+ final FilterContext context = new BaseFilterContext();
+ context.setRenderContext(new BaseRenderContext());
+ assertEquals("XmlCodeFilter works",
+ "\"attr\">text",
+ xmlCodeFilter.filter("text",
+ context));
+ }
+
+ public void testBackreference()
+ {
+ final java.util.regex.Pattern p = java.util.regex.Pattern.compile(
+ "\\{([^:}]+)(?::([^\\}]*))?\\}(.*?)\\{\\1\\}",
+ java.util.regex.Pattern.MULTILINE);
+ final java.util.regex.Matcher matcher = p
+ .matcher("{code:xml}text{code}");
+ assertTrue("A Backreference Regex found", matcher.find());
+ assertNotNull("Content not null", matcher.group(3));
+ assertEquals("Content found", "text",
+ matcher.group(3));
+ }
+
+ public void testRegexBasic()
+ {
+ final Pattern p = compiler.compile("A");
+ final Matcher m = Matcher.create("AB", p);
+
+ assertTrue("A Regex found", m.contains());
+ }
+
+ public void testMultiline()
+ {
+ compiler.setMultiline(false);
+ final Pattern p = compiler.compile("A.*B");
+ final Matcher m = Matcher.create("A123\n456B", p);
+
+ assertTrue("Multiline Regex found", m.matches());
+ }
+
+ public void testByHandBold()
+ {
+ final Pattern p = compiler.compile(BOLD_TEST_REGEX);
+ final Matcher m = Matcher.create("__test__", p);
+
+ assertEquals("Bold replaced by hand", "test",
+ m.substitute("$1$2$3"));
+ }
+
+ public void testRegexFilterBold()
+ {
+ final RegexReplaceFilter filter = new RegexReplaceFilter();
+ filter.addRegex(BOLD_TEST_REGEX, "$1$2$3");
+ final FilterContext context = new BaseFilterContext();
+ context.setRenderContext(new BaseRenderContext());
+ assertEquals("Bold replaced with RegexFilter", "test",
+ filter.filter("__test__", context));
+
+ }
+}
diff --git a/main/trunk/src/test/org/radeox/filter/BoldFilterTest.java b/src/test/java/org/radeox/filter/BoldFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/BoldFilterTest.java
rename to src/test/java/org/radeox/filter/BoldFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/EscapeFilterTest.java b/src/test/java/org/radeox/filter/EscapeFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/EscapeFilterTest.java
rename to src/test/java/org/radeox/filter/EscapeFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/FilterPipeTest.java b/src/test/java/org/radeox/filter/FilterPipeTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/FilterPipeTest.java
rename to src/test/java/org/radeox/filter/FilterPipeTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/FilterTestSupport.java b/src/test/java/org/radeox/filter/FilterTestSupport.java
similarity index 52%
rename from main/trunk/src/test/org/radeox/filter/FilterTestSupport.java
rename to src/test/java/org/radeox/filter/FilterTestSupport.java
index 2d71896..009b83b 100644
--- a/main/trunk/src/test/org/radeox/filter/FilterTestSupport.java
+++ b/src/test/java/org/radeox/filter/FilterTestSupport.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,47 +16,55 @@
* limitations under the License.
*/
-
package org.radeox.filter;
+import java.lang.reflect.Method;
+
import org.jmock.MockObjectTestCase;
-import org.radeox.engine.context.BaseInitialRenderContext;
+import org.radeox.api.engine.context.InitialRenderContext;
import org.radeox.engine.context.BaseRenderContext;
import org.radeox.filter.context.BaseFilterContext;
import org.radeox.filter.context.FilterContext;
-import java.lang.reflect.Method;
-
/**
* Support class for defning JUnit FilterTests.
*
* @author Stephan J. Schmidt
* @version $Id: FilterTestSupport.java,v 1.7 2003/08/14 07:46:04 stephan Exp $
*/
+abstract class FilterTestSupport extends MockObjectTestCase
+{
+ protected Filter filter;
+ protected Filter filterCreole;
+ protected FilterContext context;
-public class FilterTestSupport extends MockObjectTestCase {
- protected Filter filter;
- protected Filter filterCreole;
- protected FilterContext context;
-
- public FilterTestSupport() {
- context = new BaseFilterContext();
- context.setRenderContext(new BaseRenderContext());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- if (null != filter) {
- filter.setInitialContext(new BaseInitialRenderContext());
+ protected FilterTestSupport()
+ {
+ context = new BaseFilterContext();
+ context.setRenderContext(new BaseRenderContext());
}
- try {
- filterCreole = filter.getClass().newInstance();
- Method setModifierMethod = filterCreole.getClass().getMethod("setModifier", new Class[]{String.class});
- setModifierMethod.invoke(filterCreole, new Object[]{"Creole"});
- filterCreole.setInitialContext(new BaseInitialRenderContext());
-// System.out.println("Added Creole flavour filter: "+filterCreole);
- } catch (Exception e) {
- // ignore errors ...
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ final InitialRenderContext context = InitialRenderContext.defaultContext();
+ if(filter != null)
+ {
+ filter.setInitialContext(context);
+ }
+ try
+ {
+ filterCreole = filter.getClass().newInstance();
+ final Method setModifierMethod = filterCreole.getClass()
+ .getMethod("setModifier", String.class);
+ setModifierMethod.invoke(filterCreole, "Creole");
+ filterCreole.setInitialContext(context);
+ }
+ catch(final Exception e)
+ {
+ // ignore errors ...
+ }
}
- }
+
}
diff --git a/main/trunk/src/test/org/radeox/filter/HeadingFilterTest.java b/src/test/java/org/radeox/filter/HeadingFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/HeadingFilterTest.java
rename to src/test/java/org/radeox/filter/HeadingFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/HtmlRemoveFilterTest.java b/src/test/java/org/radeox/filter/HtmlRemoveFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/HtmlRemoveFilterTest.java
rename to src/test/java/org/radeox/filter/HtmlRemoveFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/InterWikiTest.java b/src/test/java/org/radeox/filter/InterWikiTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/InterWikiTest.java
rename to src/test/java/org/radeox/filter/InterWikiTest.java
diff --git a/main/trunk/src/test/org/radeox/macro/code/AllCodeMacroTests.java b/src/test/java/org/radeox/filter/ItalicFilterTest.java
similarity index 58%
rename from main/trunk/src/test/org/radeox/macro/code/AllCodeMacroTests.java
rename to src/test/java/org/radeox/filter/ItalicFilterTest.java
index ffdaee0..06d67fe 100644
--- a/main/trunk/src/test/org/radeox/macro/code/AllCodeMacroTests.java
+++ b/src/test/java/org/radeox/filter/ItalicFilterTest.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,22 +16,27 @@
* limitations under the License.
*/
+package org.radeox.filter;
-package org.radeox.macro.code;
+public class ItalicFilterTest extends FilterTestSupport
+{
+ @Override
+ protected void setUp() throws Exception
+ {
+ filter = new ItalicFilter();
+ super.setUp();
+ }
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+ public void testItalic()
+ {
+ assertEquals("Text",
+ filter.filter("~~Text~~", context));
+ }
-public class AllCodeMacroTests extends TestCase {
- public AllCodeMacroTests(String name) {
- super(name);
- }
+ public void testItalicCreole()
+ {
+ assertEquals("Text",
+ filterCreole.filter("//Text//", context));
+ }
- public static Test suite() {
- TestSuite s = new TestSuite();
- s.addTestSuite(XmlCodeMacroTest.class);
- s.addTestSuite(SqlCodeMacroTest.class);
- return s;
- }
}
diff --git a/main/trunk/src/test/org/radeox/filter/KeyFilterTest.java b/src/test/java/org/radeox/filter/KeyFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/KeyFilterTest.java
rename to src/test/java/org/radeox/filter/KeyFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/LineFilterTest.java b/src/test/java/org/radeox/filter/LineFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/LineFilterTest.java
rename to src/test/java/org/radeox/filter/LineFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/LinkTestFilterTest.java b/src/test/java/org/radeox/filter/LinkTestFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/LinkTestFilterTest.java
rename to src/test/java/org/radeox/filter/LinkTestFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/ListFilterTest.java b/src/test/java/org/radeox/filter/ListFilterTest.java
similarity index 77%
rename from main/trunk/src/test/org/radeox/filter/ListFilterTest.java
rename to src/test/java/org/radeox/filter/ListFilterTest.java
index 4114f69..c86b5f6 100644
--- a/main/trunk/src/test/org/radeox/filter/ListFilterTest.java
+++ b/src/test/java/org/radeox/filter/ListFilterTest.java
@@ -1,10 +1,10 @@
package org.radeox.filter;
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -27,23 +27,29 @@ public class ListFilterTest extends FilterTestSupport {
private static final String RESULT_UNNUMBERED_2 = "
\n
test
\n
test
\n
";
private static final String RESULT_ORDERED = "\n
test
\n
test
\n
test
\n";
private static final String RESULT_NESTED_SIMPLE = "
\n" +
- "
test
\n" +
+ "
test\n" +
"
\n" +
"
test
\n" +
"
test
\n" +
"
\n" +
- "
test
\n" +
+ "\n" +
"
";
private static final String RESULT_NESTED_LIST = "
", filter.filter("- [test]\n- [test1]\n- [test test2]\n", context));
}
+
+ public void testWrongListFormat() {
+ final String markup = "paragraph01\r\n"+
+ "\r\n" +
+ // wrong list element mark (no content)
+ "--- \n" +
+ "\r\n" +
+ "paragraph02\r\n" +
+ "\r\n" +
+ // wrong list element mark (no space and no content)
+ "---\n" +
+ "\r\n" +
+ "paragraph03\r\n";
+ final String out = filter.filter(markup, context);
+ // output should be the same as input
+ assertEquals(markup, out);
+ }
+
}
diff --git a/main/trunk/src/test/org/radeox/filter/ParamFilterTest.java b/src/test/java/org/radeox/filter/LiteralFilterTest.java
similarity index 53%
rename from main/trunk/src/test/org/radeox/filter/ParamFilterTest.java
rename to src/test/java/org/radeox/filter/LiteralFilterTest.java
index 82e3328..eb0661d 100644
--- a/main/trunk/src/test/org/radeox/filter/ParamFilterTest.java
+++ b/src/test/java/org/radeox/filter/LiteralFilterTest.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -18,28 +18,30 @@
package org.radeox.filter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.radeox.filter.ParamFilter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class ParamFilterTest extends FilterTestSupport {
+import org.radeox.filter.context.ParamContext;
- protected void setUp() throws Exception {
- filter = new ParamFilter();
- super.setUp();
- }
+/**
+ * JUnit test for {@link LiteralParamFilter}.
+ *
+ *
Created on 2025-05-28
+ *
+ * @author Marcin Golebski
+ * @version $Id$
+ */
+public class LiteralFilterTest extends FilterTestSupport
+{
+ @Override
+ protected void setUp() throws Exception
+ {
+ filter = new LiteralParamFilter();
+ super.setUp();
+ }
- public static Test suite() {
- return new TestSuite(ParamFilterTest.class);
- }
+ public void testParam()
+ {
+ final ParamContext params = ParamContext.getOrCreate(context.getRenderContext());
+ params.put("var1", "test");
+ assertEquals("test", filter.filter("{$$var1}", context));
+ }
- public void testParam() {
- Map params = new HashMap();
- params.put("var1","test");
- context.getRenderContext().setParameters(params);
- assertEquals("test", filter.filter("{$var1}", context));
- }
}
diff --git a/main/trunk/src/test/org/radeox/filter/NewlineFilterTest.java b/src/test/java/org/radeox/filter/NewlineFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/NewlineFilterTest.java
rename to src/test/java/org/radeox/filter/NewlineFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/ItalicFilterTest.java b/src/test/java/org/radeox/filter/ParamFilterTest.java
similarity index 56%
rename from main/trunk/src/test/org/radeox/filter/ItalicFilterTest.java
rename to src/test/java/org/radeox/filter/ParamFilterTest.java
index 151b6f8..eff738e 100644
--- a/main/trunk/src/test/org/radeox/filter/ItalicFilterTest.java
+++ b/src/test/java/org/radeox/filter/ParamFilterTest.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,28 +16,32 @@
* limitations under the License.
*/
-
package org.radeox.filter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ItalicFilterTest extends FilterTestSupport {
- protected void setUp() throws Exception {
- filter = new ItalicFilter();
- super.setUp();
- }
-
- public static Test suite() {
- return new TestSuite(FilterTestSupport.class);
- }
+import org.radeox.filter.context.ParamContext;
- public void testItalic() {
- assertEquals("Text", filter.filter("~~Text~~", context));
- }
-
- public void testItalicCreole() {
- assertEquals("Text", filterCreole.filter("//Text//", context));
- }
+/**
+ * JUnit test for {@link ParamFilter}.
+ *
+ *
Created on 2004-11-03
+ *
+ * @author stephan
+ * @version $Id$
+ */
+public class ParamFilterTest extends FilterTestSupport
+{
+ @Override
+ protected void setUp() throws Exception
+ {
+ filter = new ParamFilter();
+ super.setUp();
+ }
+
+ public void testParam()
+ {
+ final ParamContext params = ParamContext.getOrCreate(context.getRenderContext());
+ params.put("var1", "test");
+ assertEquals("test", filter.filter("{$var1}", context));
+ }
}
diff --git a/main/trunk/src/test/org/radeox/filter/SmileyFilterTest.java b/src/test/java/org/radeox/filter/SmileyFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/SmileyFilterTest.java
rename to src/test/java/org/radeox/filter/SmileyFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/StrikeThroughFilterTest.java b/src/test/java/org/radeox/filter/StrikeThroughFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/StrikeThroughFilterTest.java
rename to src/test/java/org/radeox/filter/StrikeThroughFilterTest.java
diff --git a/src/test/java/org/radeox/filter/TypographyFilterTest.java b/src/test/java/org/radeox/filter/TypographyFilterTest.java
new file mode 100644
index 0000000..d7bddf9
--- /dev/null
+++ b/src/test/java/org/radeox/filter/TypographyFilterTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter;
+
+public class TypographyFilterTest extends FilterTestSupport
+{
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ filter = new TypographyFilter();
+ super.setUp();
+ }
+
+ public void testElipsis()
+ {
+ assertEquals("Test … Text",
+ filter.filter("Test ... Text", context));
+ }
+
+ public void testNotAfter()
+ {
+ assertEquals("...Text", filter.filter("...Text", context));
+ }
+
+ public void testEndOfLine()
+ {
+ assertEquals("Text…", filter.filter("Text...", context));
+ }
+
+ public void test4Dots()
+ {
+ assertEquals("Test .... Text",
+ filter.filter("Test .... Text", context));
+ }
+
+ public void testLineStart()
+ {
+ assertEquals("… Text", filter.filter("... Text", context));
+ }
+
+ public void testLineEnd()
+ {
+ assertEquals("Test …", filter.filter("Test ...", context));
+ }
+
+}
diff --git a/main/trunk/src/test/org/radeox/filter/UrlFilterTest.java b/src/test/java/org/radeox/filter/UrlFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/UrlFilterTest.java
rename to src/test/java/org/radeox/filter/UrlFilterTest.java
diff --git a/main/trunk/src/test/org/radeox/filter/WikiLinkFilterTest.java b/src/test/java/org/radeox/filter/WikiLinkFilterTest.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/WikiLinkFilterTest.java
rename to src/test/java/org/radeox/filter/WikiLinkFilterTest.java
diff --git a/src/test/java/org/radeox/filter/mock/MockInterWikiRenderEngine.java b/src/test/java/org/radeox/filter/mock/MockInterWikiRenderEngine.java
new file mode 100644
index 0000000..4253e03
--- /dev/null
+++ b/src/test/java/org/radeox/filter/mock/MockInterWikiRenderEngine.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.mock;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.WikiRenderEngine;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.api.engine.context.RenderContext;
+
+public class MockInterWikiRenderEngine implements RenderEngine, WikiRenderEngine
+{
+
+ @Override
+ public InitialRenderContext getInitialRenderContext()
+ {
+ return null; // To change body of implemented methods use File |
+ // Settings | File Templates.
+ }
+
+ @Override
+ public boolean exists(final String name)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean showCreate()
+ {
+ return false;
+ }
+
+ @Override
+ public void appendLink(final StringBuffer buffer, final String name,
+ final String view, final String anchor)
+ {
+ }
+
+ @Override
+ public void appendLink(final StringBuffer buffer, final String name,
+ final String view)
+ {
+ }
+
+ @Override
+ public void appendCreateLink(final StringBuffer buffer, final String name,
+ final String view)
+ {
+ }
+
+ @Override
+ public String getName()
+ {
+ return "mock-wiki";
+ }
+
+ @Override
+ public String render(final String content, final RenderContext context)
+ {
+ return null;
+ }
+
+ @Override
+ public void render(final Writer out, final String content,
+ final RenderContext context) throws IOException
+ {
+ }
+
+ @Override
+ public String render(final Reader in, final RenderContext context)
+ throws IOException
+ {
+ return null;
+ }
+
+}
diff --git a/main/trunk/src/test/org/radeox/filter/mock/MockOldWikiRenderEngine.java b/src/test/java/org/radeox/filter/mock/MockOldWikiRenderEngine.java
similarity index 51%
rename from main/trunk/src/test/org/radeox/filter/mock/MockOldWikiRenderEngine.java
rename to src/test/java/org/radeox/filter/mock/MockOldWikiRenderEngine.java
index 6838d7b..0987517 100644
--- a/main/trunk/src/test/org/radeox/filter/mock/MockOldWikiRenderEngine.java
+++ b/src/test/java/org/radeox/filter/mock/MockOldWikiRenderEngine.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,34 +16,46 @@
* limitations under the License.
*/
-
package org.radeox.filter.mock;
import org.radeox.api.engine.context.InitialRenderContext;
-
-public class MockOldWikiRenderEngine extends MockWikiRenderEngine {
-
- public InitialRenderContext getInitialRenderContext() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void appendLink(StringBuffer buffer, String name, String view, String anchor) {
- buffer.append("link:"+view+"#"+anchor);
- }
-
- public void appendLink(StringBuffer buffer, String name, String view) {
- buffer.append("link:"+view);
- }
-
- public void appendCreateLink(StringBuffer buffer, String name, String view) {
- buffer.append(view);
- buffer.append("?");
- }
-
- public String getName() {
- return "mock-old-wiki";
- }
-
+public class MockOldWikiRenderEngine extends MockWikiRenderEngine
+{
+
+ @Override
+ public InitialRenderContext getInitialRenderContext()
+ {
+ return null; // To change body of implemented methods use File |
+ // Settings | File Templates.
+ }
+
+ @Override
+ public void appendLink(final StringBuffer buffer, final String name,
+ final String view, final String anchor)
+ {
+ buffer.append("link:" + view + "#" + anchor);
+ }
+
+ @Override
+ public void appendLink(final StringBuffer buffer, final String name,
+ final String view)
+ {
+ buffer.append("link:" + view);
+ }
+
+ @Override
+ public void appendCreateLink(final StringBuffer buffer, final String name,
+ final String view)
+ {
+ buffer.append(view);
+ buffer.append("?");
+ }
+
+ @Override
+ public String getName()
+ {
+ return "mock-old-wiki";
+ }
}
diff --git a/main/trunk/src/test/org/radeox/filter/mock/MockReplacedFilter.java b/src/test/java/org/radeox/filter/mock/MockReplacedFilter.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/mock/MockReplacedFilter.java
rename to src/test/java/org/radeox/filter/mock/MockReplacedFilter.java
diff --git a/main/trunk/src/test/org/radeox/filter/mock/MockReplacesFilter.java b/src/test/java/org/radeox/filter/mock/MockReplacesFilter.java
similarity index 100%
rename from main/trunk/src/test/org/radeox/filter/mock/MockReplacesFilter.java
rename to src/test/java/org/radeox/filter/mock/MockReplacesFilter.java
diff --git a/src/test/java/org/radeox/filter/mock/MockWikiRenderEngine.java b/src/test/java/org/radeox/filter/mock/MockWikiRenderEngine.java
new file mode 100644
index 0000000..ae23a3d
--- /dev/null
+++ b/src/test/java/org/radeox/filter/mock/MockWikiRenderEngine.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.filter.mock;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.api.engine.WikiRenderEngine;
+import org.radeox.api.engine.context.InitialRenderContext;
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.util.Encoder;
+
+public class MockWikiRenderEngine implements RenderEngine, WikiRenderEngine
+{
+
+ @Override
+ public InitialRenderContext getInitialRenderContext()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean exists(final String name)
+ {
+ return name.equals("SnipSnap") || name.equals("stephan");
+ }
+
+ @Override
+ public boolean showCreate()
+ {
+ return true;
+ }
+
+ @Override
+ public void appendLink(final StringBuffer buffer, final String name,
+ final String view, final String anchor)
+ {
+ buffer.append("link:" + name + "|" + view + "#" + anchor);
+ }
+
+ @Override
+ public void appendLink(final StringBuffer buffer, final String name,
+ final String view)
+ {
+ buffer.append("link:" + name + "|" + view);
+ }
+
+ @Override
+ public void appendCreateLink(final StringBuffer buffer, final String name,
+ final String view)
+ {
+ buffer.append("'").append(name).append("' - ");
+ buffer.append("'").append(Encoder.escape(name)).append("'");
+ }
+
+ @Override
+ public String getName()
+ {
+ return "mock-wiki";
+ }
+
+ @Override
+ public String render(final String content, final RenderContext context)
+ {
+ return null;
+ }
+
+ @Override
+ public void render(final Writer out, final String content,
+ final RenderContext context) throws IOException
+ {
+ }
+
+ @Override
+ public String render(final Reader in, final RenderContext context)
+ throws IOException
+ {
+ return null;
+ }
+
+}
diff --git a/main/trunk/src/test/org/radeox/groovy/RadeoxTemplateEngineTest.java b/src/test/java/org/radeox/groovy/RadeoxTemplateEngineTest.java
similarity index 51%
rename from main/trunk/src/test/org/radeox/groovy/RadeoxTemplateEngineTest.java
rename to src/test/java/org/radeox/groovy/RadeoxTemplateEngineTest.java
index bcc920b..becd9bb 100644
--- a/main/trunk/src/test/org/radeox/groovy/RadeoxTemplateEngineTest.java
+++ b/src/test/java/org/radeox/groovy/RadeoxTemplateEngineTest.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
* Fraunhofer Institute Computer Architecture and Software Technology
* (FIRST), Berlin, Germany
- *
+ *
* Licensed 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
@@ -16,40 +16,43 @@
* limitations under the License.
*/
-
package org.radeox.groovy;
-import groovy.text.Template;
-import groovy.text.TemplateEngine;
-import junit.framework.TestCase;
-
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.codehaus.groovy.control.CompilationFailedException;
import org.radeox.example.RadeoxTemplateEngine;
-public class RadeoxTemplateEngineTest extends TestCase {
+import groovy.lang.Writable;
+import groovy.text.Template;
+import groovy.text.TemplateEngine;
+import junit.framework.TestCase;
+
+public class RadeoxTemplateEngineTest extends TestCase
+{
+
+ public RadeoxTemplateEngineTest(final String name)
+ {
+ super(name);
+ }
- public RadeoxTemplateEngineTest(String name) {
- super(name);
- }
+ public void testRadeoxTemplate() throws CompilationFailedException,
+ FileNotFoundException, ClassNotFoundException, IOException
+ {
+ final String text = "__Dear__ ${firstname}";
- public void testRadeoxTemplate() {
- String text = "__Dear__ ${firstname}";
+ final Map binding = new HashMap<>();
+ binding.put("firstname", "stephan");
- Map binding = new HashMap();
- binding.put("firstname", "stephan");
+ final TemplateEngine engine = new RadeoxTemplateEngine();
+ final Template template = engine.createTemplate(text);
+ final Writable make = template.make(binding);
- TemplateEngine engine = new RadeoxTemplateEngine();
- Template template = null;
- try {
- template = engine.createTemplate(text);
- } catch (Exception e) {
- e.printStackTrace();
+ final String result = "Dear stephan";
+ assertEquals(result, make.toString());
}
- template.setBinding(binding);
- String result = "Dear stephan";
- assertEquals(result, template.toString());
- }
}
diff --git a/src/test/java/org/radeox/macro/ApiDocMacroTest.java b/src/test/java/org/radeox/macro/ApiDocMacroTest.java
new file mode 100644
index 0000000..99bf359
--- /dev/null
+++ b/src/test/java/org/radeox/macro/ApiDocMacroTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its
+ * Fraunhofer Institute Computer Architecture and Software Technology
+ * (FIRST), Berlin, Germany
+ *
+ * Licensed 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.radeox.macro;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ApiDocMacroTest extends MacroTestSupport
+{
+ public ApiDocMacroTest(final String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(ApiDocMacroTest.class);
+ }
+
+ public void testApi()
+ {
+ final String result = engine.render("{api-docs}", context);
+ // This must be moved to IoC to better test ApiDoc directly.
+ assertEquals("ApiDocs are rendered",
+ "