View Javadoc

1   /*
2    * Copyright © 2007  Red Hat Middleware, LLC. All rights reserved.
3    *
4    * This copyrighted material is made available to anyone wishing to use, modify,
5    * copy, or redistribute it subject to the terms and conditions of the GNU
6    * Lesser General Public License, v. 2.1. This program is distributed in the
7    * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
8    * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9    * Lesser General Public License for more details. You should have received a
10   * copy of the GNU Lesser General Public License, v.2.1 along with this
11   * distribution; if not, write to the Free Software Foundation, Inc.,
12   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
13   *
14   * Red Hat Author(s): Steve Ebersole
15   */
16  package org.jboss.maven.plugins.jdocbook.gen.util;
17  
18  /**
19   * The basic definition of the standard docbook formats.
20   *
21   * @author Steve Ebersole
22   */
23  public class StandardDocBookFormatSpecification {
24  	public static final StandardDocBookFormatSpecification ECLIPSE =
25  			new HtmlBasedStandardDocBookFormat( "eclipse", "/eclipse/eclipse.xsl" );
26  
27  	public static final StandardDocBookFormatSpecification HTML =
28  			new HtmlBasedStandardDocBookFormat( "html", "/html/chunk.xsl" );
29  
30  	public static final StandardDocBookFormatSpecification HTML_SINGLE =
31  			new HtmlBasedStandardDocBookFormat( "html_single", "/html/docbook.xsl", false );
32  
33  	public static final StandardDocBookFormatSpecification HTMLHELP =
34  			new HtmlBasedStandardDocBookFormat( "htmlhelp", "/htmlhelp/htmlhelp.xsl" );
35  
36  	public static final StandardDocBookFormatSpecification JAVAHELP =
37  			new HtmlBasedStandardDocBookFormat( "javahelp", "/javahelp/javahelp.xsl" );
38  
39  	public static final StandardDocBookFormatSpecification MAN =
40  			new HtmlBasedStandardDocBookFormat( "man", "/manpages/docbook.xsl", false );
41  
42  	public static final StandardDocBookFormatSpecification PDF =
43  			new StandardDocBookFormatSpecification( "pdf", "pdf", "/fo/docbook.xsl", true, false, false );
44  
45  	public static final StandardDocBookFormatSpecification WEBSITE =
46  			new HtmlBasedStandardDocBookFormat( "website", "/website/website.xsl", false );
47  
48  // I'd rather not support this...
49  //	public static final FormatType WORDML =
50  //			new FormatType( "wordml", "doc", "/wordml/wordml.xsl", ?, ?, ? );
51  
52  	public static final StandardDocBookFormatSpecification XHTML =
53  			new StandardDocBookFormatSpecification( "xhtml", "xhtml", "/xhtml/docbook.xsl", false, true, false );
54  
55  	private final String name;
56  	private final String standardFileExtension;
57  	private final String stylesheetResource;
58  	private final boolean imagePathSettingRequired;
59  	private final boolean imageCopyingRequired;
60  	private final boolean doingChunking;
61  
62  	public StandardDocBookFormatSpecification(
63  			String name,
64  			String standardFileExtension,
65  			String stylesheetResource,
66  			boolean imagePathSettingRequired,
67  			boolean imageCopyingRequired,
68  			boolean doingChunking) {
69  		this.name = name;
70  		this.standardFileExtension = standardFileExtension;
71  		this.stylesheetResource = stylesheetResource;
72  		this.imagePathSettingRequired = imagePathSettingRequired;
73  		this.imageCopyingRequired = imageCopyingRequired;
74  		this.doingChunking = doingChunking;
75  	}
76  
77  	public String getName() {
78  		return name;
79  	}
80  
81  	public String getStandardFileExtension() {
82  		return standardFileExtension;
83  	}
84  
85  	public String getStylesheetResource() {
86  		return stylesheetResource;
87  	}
88  
89  	public boolean isImagePathSettingRequired() {
90  		return imagePathSettingRequired;
91  	}
92  
93  	public boolean isImageCopyingRequired() {
94  		return imageCopyingRequired;
95  	}
96  
97  	public boolean isDoingChunking() {
98  		return doingChunking;
99  	}
100 
101 	public static StandardDocBookFormatSpecification parse(String name) {
102 		if ( ECLIPSE.name.equals( name ) ) {
103 			return ECLIPSE;
104 		}
105 		else if ( HTML.name.equals( name ) ) {
106 			return HTML;
107 		}
108 		else if ( HTML_SINGLE.name.equals( name ) ) {
109 			return HTML_SINGLE;
110 		}
111 		else if ( HTMLHELP.name.equals( name ) ) {
112 			return HTMLHELP;
113 		}
114 		else if ( JAVAHELP.name.equals( name ) ) {
115 			return JAVAHELP;
116 		}
117 		else if ( MAN.name.equals( name ) ) {
118 			return MAN;
119 		}
120 		else if ( PDF.name.equals( name ) ) {
121 			return PDF;
122 		}
123 		else if ( WEBSITE.name.equals( name ) ) {
124 			return WEBSITE;
125 		}
126 //		else if ( WORDML.name.equals( name ) ) {
127 //			return WORDML;
128 //		}
129 		else if ( XHTML.name.equals( name ) ) {
130 			return XHTML;
131 		}
132 		else {
133 			return null;
134 		}
135 	}
136 
137 
138 	// convenience for html based formats to simplify ctors ~~~~~~~~~~~~~~~~~~~
139 
140 	private static class HtmlBasedStandardDocBookFormat extends StandardDocBookFormatSpecification {
141 		private HtmlBasedStandardDocBookFormat(String name, String stylesheetResource) {
142 			this( name, stylesheetResource, true );
143 		}
144 		private HtmlBasedStandardDocBookFormat(String name, String stylesheetResource, boolean doingChunking) {
145 			super( name, "html", stylesheetResource, false, true, doingChunking );
146 		}
147 	}
148 }