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 :-) - *

- * /[A-Z][a-z]+([A-Z][a-z]+)+/ - * wikiPattern = "\\[(.*?)\\]"; - */ - - protected String getLocaleKey() { - return "filter.linktest"; - } - - protected void setUp(FilterContext context) { - context.getRenderContext().setCacheable(true); - } - - public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context) { - RenderEngine engine = context.getRenderContext().getRenderEngine(); - - if (engine instanceof WikiRenderEngine) { - WikiRenderEngine wikiEngine = (WikiRenderEngine) engine; - 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 (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('-'), "