com.st.p2012.mind.HTMLRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mindoc Show documentation
Show all versions of mindoc Show documentation
Document generator for MIND
The newest version!
/**
\file com/st/p2012/mind/HTMLRenderer.java
\brief A StringTemplate renderer for HTML documentation templates.
\n
This file is part of the Platform 2012 program,
a cooperation between STMicroelectronics and CEA.\n
Redistribution of this file to outside parties is
strictly prohibited without the written consent
of the module owner indicated below.\n
\par Module owner: [email protected]
\par Copyright (C) 2009 STMicroelectronics
\par Authors: [email protected]
\par Id: $Id$
\par Date: $Date$
\par Revision: $Rev$
*/
package com.st.p2012.mind;
import static com.st.p2012.mind.HTMLDocumentationHelper.getShortName;
import static org.objectweb.fractal.mind.NameHelper.getPackageName;
import static org.objectweb.fractal.mind.NameHelper.toValidName;
import java.io.File;
import org.antlr.stringtemplate.AttributeRenderer;
public class HTMLRenderer implements AttributeRenderer {
public static final String SHORT_NAME = "shortName";
public static final String PACKAGE_NAME = "packageName";
public static final String NAME_TO_PATH = "nameToPath";
public static final String TO_LOWER = "toLower";
public String toString(final Object o, final String format) {
if (SHORT_NAME.equals(format)) {
return getShortName(o.toString());
} else if (PACKAGE_NAME.equals(format)) {
final String pName = getPackageName(o.toString());
return pName == null ? "" : pName;
} else if (NAME_TO_PATH.equals(format)) {
return toValidName(o.toString()).replace('.', File.separatorChar);
} else if (TO_LOWER.equals(format)) {
return o.toString().toLowerCase();
}
return o.toString();
}
public String toString(final Object o) {
return o.toString();
}
}