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: * Macro to easily link to RFCs. The website to link to is currently hard wired.
34: * @author stephan @team sonicteam
35: *
36: * @version $Id: RfcMacro.java 29159 2007-04-19 01:46:15Z ajpoland@iupui.edu $
37: */
38:
39: public class RfcMacro extends BaseLocaleMacro {
40:
41: public String getLocaleKey() {
42: return "macro.rfc"; //$NON-NLS-1$
43: }
44:
45: public void execute(Writer writer, MacroParameter params)
46: throws IllegalArgumentException, IOException {
47:
48: if (params.getLength() == 1) {
49: String number = params.get("0"); //$NON-NLS-1$
50: String view = "RFC" + number; //$NON-NLS-1$
51: // ftp://ftp.rfc-editor.org/in-notes/rfc3300.txt
52: // http://zvon.org/tmRFC/RFC3300/Output/index.html
53: appendRfc(writer, number, view);
54: return;
55: } else if (params.getLength() == 2) {
56: String number = params.get(0);
57: String view = params.get(1);
58: appendRfc(writer, number, view);
59: } else {
60: throw new IllegalArgumentException(Messages
61: .getString("RfcMacro.3")); //$NON-NLS-1$
62: }
63: }
64:
65: public void appendRfc(Writer writer, String number, String view)
66: throws IOException, IllegalArgumentException {
67: // writer.write("<a href=\"ftp://ftp.rfc-editor.org/in-notes/rfc");
68: try {
69:
70: Integer dummy = Integer.getInteger(number);
71: } catch (Exception e) {
72: throw new IllegalArgumentException();
73: }
74: writer.write("<a href=\"http://zvon.org/tmRFC/RFC"); //$NON-NLS-1$
75: writer.write(number);
76: writer.write("/Output/index.html\">"); //$NON-NLS-1$
77: writer.write(view);
78: writer.write("</a>"); //$NON-NLS-1$
79: return;
80: }
81: }
|