| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| Macro | 40 | 0 | - | 0 | 0 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.rendering.macro; | |
| 21 | ||
| 22 | import java.util.List; | |
| 23 | ||
| 24 | import org.xwiki.component.annotation.ComponentRole; | |
| 25 | import org.xwiki.rendering.block.Block; | |
| 26 | import org.xwiki.rendering.macro.descriptor.MacroDescriptor; | |
| 27 | import org.xwiki.rendering.transformation.MacroTransformationContext; | |
| 28 | ||
| 29 | /** | |
| 30 | * Represents a Macro, ie a mechanism to generate Rendering {@link Block}s, that we use as a way to either generate | |
| 31 | * dynamic content or simply as a way to reuse Blocks in content. | |
| 32 | * | |
| 33 | * @param <P> the type of the macro parameters bean | |
| 34 | * @version $Id: 6a5f0943063c6139ccc474ebd46ec6184de33560 $ | |
| 35 | * @since 1.5M2 | |
| 36 | */ | |
| 37 | // Note: We cannot replace @ComponentRole with @Role ATM since @Role supports generics and we have Macro<P>. Changing | |
| 38 | // it will thus break all code looking up components implementing this role. | |
| 39 | @ComponentRole | |
| 40 | public interface Macro<P> extends Comparable<Macro<?>> | |
| 41 | { | |
| 42 | /** | |
| 43 | * The priority of execution relative to the other Macros. The lowest values have the highest priorities and execute | |
| 44 | * first. For example a Macro with a priority of 100 will execute before one with a priority of 500. | |
| 45 | * | |
| 46 | * @return the execution priority | |
| 47 | */ | |
| 48 | int getPriority(); | |
| 49 | ||
| 50 | /** | |
| 51 | * @return the macro descriptor | |
| 52 | */ | |
| 53 | MacroDescriptor getDescriptor(); | |
| 54 | ||
| 55 | /** | |
| 56 | * @return true if the macro can be inserted in some existing content such as a paragraph, a list item etc. For | |
| 57 | * example if I have <code>== hello {{velocity}}world{{/velocity}}</code> then the Velocity macro must | |
| 58 | * support the inline mode and not generate a paragraph. | |
| 59 | */ | |
| 60 | boolean supportsInlineMode(); | |
| 61 | ||
| 62 | /** | |
| 63 | * Executes the macro. | |
| 64 | * | |
| 65 | * @param parameters the macro parameters in the form of a bean defined by the {@link Macro} implementation | |
| 66 | * @param content the content of the macro | |
| 67 | * @param context the context of the macros transformation process | |
| 68 | * @return the result of the macro execution as a list of Block elements | |
| 69 | * @throws MacroExecutionException error when executing the macro | |
| 70 | */ | |
| 71 | List<Block> execute(P parameters, String content, MacroTransformationContext context) | |
| 72 | throws MacroExecutionException; | |
| 73 | } |