1
package org.apache.maven.doxia.sink.render;
4
* Licensed to the Apache Software Foundation (ASF) under one
5
* or more contributor license agreements. See the NOTICE file
6
* distributed with this work for additional information
7
* regarding copyright ownership. The ASF licenses this file
8
* to you under the Apache License, Version 2.0 (the
9
* "License"); you may not use this file except in compliance
10
* with the License. You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing,
15
* software distributed under the License is distributed on an
16
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
* KIND, either express or implied. See the License for the
18
* specific language governing permissions and limitations
23
import java.util.HashMap;
26
import org.codehaus.plexus.util.PathTool;
27
import org.codehaus.plexus.util.StringUtils;
30
* <p>RenderingContext class.</p>
32
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
33
* @version $Id: RenderingContext.java 747735 2009-02-25 10:43:09Z ltheussl $
36
public class RenderingContext
38
private final File basedir;
40
private final String inputName;
42
private final String outputName;
44
private final String parserId;
46
private final String relativePath;
48
private final String extension;
50
private Map attributes;
53
* <p>Constructor for RenderingContext.</p>
55
* @param basedir a {@link java.io.File} object.
56
* @param document a {@link java.lang.String} object.
58
public RenderingContext( File basedir, String document )
60
this( basedir, document, null );
64
* <p>Constructor for RenderingContext.</p>
66
* @param basedir a {@link java.io.File} object.
67
* @param document a {@link java.lang.String} object.
68
* @param parserId a {@link java.lang.String} object.
70
public RenderingContext( File basedir, String document, String parserId )
72
this( basedir, document, null, null );
77
* <p>Constructor for RenderingContext.</p>
79
* @param basedir a {@link java.io.File} object.
80
* @param document a {@link java.lang.String} object.
81
* @param parserId a {@link java.lang.String} object.
82
* @param extension a {@link java.lang.String} object.
84
public RenderingContext( File basedir, String document, String parserId, String extension )
86
this.basedir = basedir;
87
this.extension = extension;
88
if ( StringUtils.isNotEmpty( extension ) )
90
// here we now the parserId we can play with this
91
// index.xml -> index.html
92
// index.xml.vm -> index.html
93
// download.apt.vm --> download.html
94
int startIndexOfExtension = document.indexOf( "." + extension );
95
String fileNameWithoutExt = document.substring( 0, startIndexOfExtension );
96
this.outputName = fileNameWithoutExt + ".html";
100
this.outputName = document.substring( 0, document.indexOf( "." ) ).replace( '\\', '/' ) + ".html";
102
this.relativePath = PathTool.getRelativePath( basedir.getPath(), new File( basedir, document ).getPath() );
104
this.inputName = document;
106
this.parserId = parserId;
108
this.attributes = new HashMap();
112
* <p>Getter for the field <code>basedir</code>.</p>
114
* @return a {@link java.io.File} object.
116
public File getBasedir()
122
* <p>Getter for the field <code>inputName</code>.</p>
124
* @return a {@link java.lang.String} object.
126
public String getInputName()
132
* <p>Getter for the field <code>outputName</code>.</p>
134
* @return a {@link java.lang.String} object.
136
public String getOutputName()
142
* <p>Getter for the field <code>parserId</code>.</p>
144
* @return a {@link java.lang.String} object.
146
public String getParserId()
152
* <p>Getter for the field <code>relativePath</code>.</p>
154
* @return a {@link java.lang.String} object.
156
public String getRelativePath()
162
* <p>setAttribute</p>
164
* @param key a {@link java.lang.String} object.
165
* @param value a {@link java.lang.String} object.
167
public void setAttribute( String key, String value )
169
attributes.put( key, value );
173
* <p>getAttribute</p>
175
* @param key a {@link java.lang.String} object.
176
* @return a {@link java.lang.String} object.
178
public String getAttribute( String key )
180
return (String) attributes.get( key );
184
* <p>Getter for the field <code>extension</code>.</p>
186
* @return a {@link java.lang.String} object.
188
public String getExtension()