001/* 002 Licensed to the Apache Software Foundation (ASF) under one 003 or more contributor license agreements. See the NOTICE file 004 distributed with this work for additional information 005 regarding copyright ownership. The ASF licenses this file 006 to you under the Apache License, Version 2.0 (the 007 "License"); you may not use this file except in compliance 008 with the License. You may obtain a copy of the License at 009 010 http://www.apache.org/licenses/LICENSE-2.0 011 012 Unless required by applicable law or agreed to in writing, 013 software distributed under the License is distributed on an 014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 KIND, either express or implied. See the License for the 016 specific language governing permissions and limitations 017 under the License. 018*/ 019package org.apache.wiki.api.plugin; 020 021import org.apache.wiki.api.core.Context; 022import org.apache.wiki.api.exceptions.PluginException; 023 024import java.util.Map; 025 026 027/** 028 * Exposes the contents of a plugin in a WikiDocument DOM tree. 029 */ 030public interface PluginElement { 031 032 /** 033 * Returns the name of the plugin invoked by the DOM element. 034 * 035 * @return Name of the plugin 036 * @since 2.5.7 037 */ 038 String getPluginName(); 039 040 /** 041 * Returns a parameter value from the parameter map. 042 * 043 * @param name the name of the parameter. 044 * @return The value from the map, or null, if no such parameter exists. 045 */ 046 String getParameter( String name); 047 048 /** 049 * Returns the parameter map given in the constructor. 050 * 051 * @return The parameter map. 052 */ 053 Map< String, String > getParameters(); 054 055 /** 056 * Returns the rendered plugin. Only calls getText(). 057 * 058 * @return HTML 059 */ 060 String getValue(); 061 062 /** 063 * The main invocation for the plugin. When the getText() is called, it invokes the plugin and returns its contents. If there is 064 * no Document yet, only returns the plugin name itself. 065 * 066 * @return The plugin rendered according to the options set in the WikiContext. 067 */ 068 String getText(); 069 070 /** 071 * Performs plugin invocation and return its contents. 072 * 073 * @param context WikiContext in which the plugin is executed. Must NOT be null. 074 * @return plugin contents. 075 */ 076 String invoke( Context context ); 077 078 /** 079 * Executes the executeParse() method. 080 * 081 * @param context The WikiContext 082 * @throws PluginException If something goes wrong. 083 */ 084 void executeParse( Context context ) throws PluginException; 085 086}