01: /*
02: * This file is part of "SnipSnap Radeox Rendering Engine".
03: *
04: * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
05: * All Rights Reserved.
06: *
07: * Please visit http://radeox.org/ for updates and contact.
08: *
09: * --LICENSE NOTICE--
10: * Licensed under the Apache License, Version 2.0 (the "License");
11: * you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: * --LICENSE NOTICE--
22: */
23:
24: package org.radeox.macro;
25:
26: import java.io.IOException;
27: import java.io.Writer;
28:
29: import org.radeox.Messages;
30: import org.radeox.api.macro.MacroParameter;
31:
32: /*
33: * Hello world example macro. This Macro displays a hello world string. @author
34: * stephan
35: *
36: * @version $Id: HelloWorldMacro.java 7707 2006-04-12 17:30:19Z
37: * ian@caret.cam.ac.uk $
38: */
39:
40: public class HelloWorldMacro extends BaseMacro {
41: private String[] paramDescription = { Messages
42: .getString("HelloWorldMacro.0") }; //$NON-NLS-1$
43:
44: public String getName() {
45: return "hello"; //$NON-NLS-1$
46: }
47:
48: public String getDescription() {
49: return Messages.getString("HelloWorldMacro.2"); //$NON-NLS-1$
50: }
51:
52: public String[] getParamDescription() {
53: return paramDescription;
54: }
55:
56: public void execute(Writer writer, MacroParameter params)
57: throws IllegalArgumentException, IOException {
58: if (params.getLength() == 1) {
59: writer.write(Messages.getString("HelloWorldMacro.3")); //$NON-NLS-1$
60: writer.write(params.get("0")); //$NON-NLS-1$
61: writer.write("</b>"); //$NON-NLS-1$
62: } else {
63: throw new IllegalArgumentException(Messages
64: .getString("HelloWorldMacro.6")); //$NON-NLS-1$
65: }
66: }
67: }
|