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.apache.commons.logging.Log;
30: import org.apache.commons.logging.LogFactory;
31: import org.radeox.Messages;
32: import org.radeox.api.macro.MacroParameter;
33:
34: /*
35: * Displays a file path. This is used to store a filepath in an OS independent
36: * way and then display the file path as needed. This macro also solves the
37: * problems with to many backslashes in Windows filepaths when they are entered
38: * in Snipsnap. @author stephan @team sonicteam
39: *
40: * @version $Id: FilePathMacro.java 7707 2006-04-12 17:30:19Z
41: * ian@caret.cam.ac.uk $
42: */
43:
44: public class FilePathMacro extends LocalePreserved {
45: private static Log log = LogFactory.getLog(FilePathMacro.class);
46:
47: private String[] paramDescription = { Messages
48: .getString("FilePathMacro.0") }; //$NON-NLS-1$
49:
50: public String getLocaleKey() {
51: return "macro.filepath"; //$NON-NLS-1$
52: }
53:
54: public FilePathMacro() {
55: addSpecial('\\');
56: }
57:
58: public String getDescription() {
59: return Messages.getString("FilePathMacro.2"); //$NON-NLS-1$
60: }
61:
62: public String[] getParamDescription() {
63: return paramDescription;
64: }
65:
66: public void execute(Writer writer, MacroParameter params)
67: throws IllegalArgumentException, IOException {
68:
69: if (params.getLength() == 1) {
70: String path = params.get("0").replace('/', '\\'); //$NON-NLS-1$
71: writer.write(replace(path));
72: }
73: return;
74: }
75: }
|