001/*
002 *  Copyright 2010 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.cms.transformation.docbook;
017
018/**
019 * This class represent a enhancement to docbook 
020 */
021public class DocbookEnhancer
022{
023    private String _htmleditor2DocbookXSLT;
024    private String _docbook2HTMLEditorXSLT;
025    private String _docbook2outgoingReferencesXSLT;
026    private String _docbook2HTMLXSLT;
027    private String _docbook2HTMLHandler;
028    private String _htmleditor2docbookHandler;
029    
030    /**
031     * Create a docbook enhancer
032     * @param pluginName The name of the plugin declaring the enhancer
033     * @param htmleditor2DocbookXSLT The fullpath to the xslt file or relative to the current plugin
034     * @param docbook2HTMLEditorXSLT The fullpath to the xslt file or relative to the current plugin
035     * @param docbook2HTMLXSLT The fullpath to the xslt file or relative to the current plugin
036     * @param docbook2outgoingReferencesXSLT The fullpath to the xslt file or relative to the current plugin
037     * @param docbook2HTMLHandler The role of a component that implements EnhancementTransformer
038     * @param htmleditor2DocbookHandler The role of a component that implements EnhancementTransformer
039     */
040    public DocbookEnhancer(String pluginName, String htmleditor2DocbookXSLT, String docbook2HTMLEditorXSLT, String docbook2HTMLXSLT, String docbook2outgoingReferencesXSLT, String docbook2HTMLHandler, String htmleditor2DocbookHandler)
041    {
042        if (htmleditor2DocbookXSLT != null && htmleditor2DocbookXSLT.indexOf("://") == -1 && !htmleditor2DocbookXSLT.startsWith("/"))
043        {
044            _htmleditor2DocbookXSLT = "plugin:" + pluginName + "://" + htmleditor2DocbookXSLT;
045        }
046        else
047        {
048            _htmleditor2DocbookXSLT = htmleditor2DocbookXSLT;
049        }
050
051        if (docbook2HTMLEditorXSLT != null && docbook2HTMLEditorXSLT.indexOf("://") == -1 && !docbook2HTMLEditorXSLT.startsWith("/"))
052        {
053            _docbook2HTMLEditorXSLT = "plugin:" + pluginName + "://" + docbook2HTMLEditorXSLT;
054        }
055        else
056        {
057            _docbook2HTMLEditorXSLT = docbook2HTMLEditorXSLT;
058        }
059
060        if (docbook2HTMLXSLT != null && docbook2HTMLXSLT.indexOf("://") == -1 && !docbook2HTMLXSLT.startsWith("/"))
061        {
062            _docbook2HTMLXSLT = "plugin:" + pluginName + "://" + docbook2HTMLXSLT;
063        }
064        else
065        {
066            _docbook2HTMLXSLT = docbook2HTMLXSLT;
067        }
068        
069        if (docbook2outgoingReferencesXSLT != null && docbook2outgoingReferencesXSLT.indexOf("://") == -1 && !docbook2outgoingReferencesXSLT.startsWith("/"))
070        {
071            _docbook2outgoingReferencesXSLT = "plugin:" + pluginName + "://" + docbook2outgoingReferencesXSLT;
072        }
073        else
074        {
075            _docbook2outgoingReferencesXSLT = docbook2outgoingReferencesXSLT;
076        }
077        
078        _docbook2HTMLHandler = docbook2HTMLHandler;
079        _htmleditor2docbookHandler = htmleditor2DocbookHandler;
080    }
081    
082    /**
083     * Get the xslt to use when transforming from htmleditor to docbook
084     * @return The fullpath to a xslt file
085     */
086    public String getHTMLEditor2DocbookXSLT()
087    {
088        return _htmleditor2DocbookXSLT;
089    }
090
091    /**
092     * Get the xslt to use when transforming from docbook to htmleditor 
093     * @return The fullpath to a xslt file
094     */
095    public String getDocbook2HTMLEditorXSLT()
096    {
097        return _docbook2HTMLEditorXSLT;
098    }
099
100    /**
101     * Get the xslt to use when transforming from docbook to html
102     * @return The fullpath to a xslt file
103     */
104    public String getDocbook2HTMLXSLT()
105    {
106        return _docbook2HTMLXSLT;
107    }
108    
109    /**
110     * Get the xslt to use when transforming from docbook to html
111     * @return The fullpath to a xslt file
112     */
113    public String getDocbook2outgoingReferencesXSLT()
114    {
115        return _docbook2outgoingReferencesXSLT;
116    }
117    
118    /**
119     * Get the component role to use when transforming from docbook to html
120     * @return The component role
121     */
122    public String getDocbook2HTMLHandler()
123    {
124        return _docbook2HTMLHandler;
125    }
126
127    /**
128     * Get the component role to use when transforming from htmleditor to docbook
129     * @return The component role
130     */
131    public String getHTMLEditor2DocbookHandler()
132    {
133        return _htmleditor2docbookHandler;
134    }
135}