| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2009 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.pde.api.tools.internal.search; |
| 12 | |
| 13 | /** |
| 14 | * Contains strings and methods for writing HTML markup |
| 15 | * |
| 16 | * @since 1.0.1 |
| 17 | */ |
| 18 | public abstract class HTMLConvertor { |
| 19 | |
| 20 | /** |
| 21 | * Default file extension for HTML files: <code>.html</code> |
| 22 | */ |
| 23 | public static final String HTML_EXTENSION = ".html"; //$NON-NLS-1$ |
| 24 | /** |
| 25 | * Default file extension for XML files: <code>.xml</code> |
| 26 | */ |
| 27 | public static final String XML_EXTENSION = ".xml"; //$NON-NLS-1$ |
| 28 | /** |
| 29 | * Standard HTML file prefix |
| 30 | */ |
| 31 | public static final String HTML_HEADER = "<!doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"; //$NON-NLS-1$ |
| 32 | /** |
| 33 | * Meta tag for default HTML content type |
| 34 | */ |
| 35 | public static final String CONTENT_TYPE_META = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"; //$NON-NLS-1$ |
| 36 | /** |
| 37 | * Standard W3C footer image + link |
| 38 | */ |
| 39 | public static final String W3C_FOOTER = "<p>\n\t<a href=\"http://validator.w3.org/check?uri=referer\">\n<img src=\"http://www.w3.org/Icons/valid-html401-blue\" alt=\"Valid HTML 4.01 Transitional\" height=\"31\" width=\"88\"></a>\n</p>\n"; //$NON-NLS-1$ |
| 40 | /** |
| 41 | * Opening title tag: <code><title></code> |
| 42 | */ |
| 43 | public static final String OPEN_TITLE = "<title>"; //$NON-NLS-1$ |
| 44 | /** |
| 45 | * Closing title tag: <code></title></code> |
| 46 | */ |
| 47 | public static final String CLOSE_TITLE = "</title>\n"; //$NON-NLS-1$ |
| 48 | /** |
| 49 | * Opening head tag: <code><head></code> |
| 50 | */ |
| 51 | public static final String OPEN_HEAD = "<head>\n"; //$NON-NLS-1$ |
| 52 | /** |
| 53 | * Closing head tag: <code></head></code> |
| 54 | */ |
| 55 | public static final String CLOSE_HEAD = "</head>\n"; //$NON-NLS-1$ |
| 56 | /** |
| 57 | * Opening body tag: <code><body></code> |
| 58 | */ |
| 59 | public static final String OPEN_BODY = "<body>\n"; //$NON-NLS-1$ |
| 60 | /** |
| 61 | * Closing body tag: <code></body></code> |
| 62 | */ |
| 63 | public static final String CLOSE_BODY = "</body>\n"; //$NON-NLS-1$ |
| 64 | /** |
| 65 | * Opening h3 tag: <code><h3></code> |
| 66 | */ |
| 67 | public static final String OPEN_H3 = "<h3>"; //$NON-NLS-1$ |
| 68 | /** |
| 69 | * Closing h3 tag: <code></h3></code> |
| 70 | */ |
| 71 | public static final String CLOSE_H3 = "</h3>\n"; //$NON-NLS-1$ |
| 72 | /** |
| 73 | * Opening html tag: <code><html></code> |
| 74 | */ |
| 75 | public static final String OPEN_HTML = "<html>\n"; //$NON-NLS-1$ |
| 76 | /** |
| 77 | * Closing html tag: <code><html></code> |
| 78 | */ |
| 79 | public static final String CLOSE_HTML = "</html>\n"; //$NON-NLS-1$ |
| 80 | /** |
| 81 | * Closing table tag: <code></table></code> |
| 82 | */ |
| 83 | public static final String CLOSE_TABLE = "</table>\n"; //$NON-NLS-1$ |
| 84 | /** |
| 85 | * Opening td tag: <code><td></code> |
| 86 | */ |
| 87 | public static final String OPEN_TD = "<td>"; //$NON-NLS-1$ |
| 88 | /** |
| 89 | * Closing td tag: <code></td></code> |
| 90 | */ |
| 91 | public static final String CLOSE_TD = "</td>\n"; //$NON-NLS-1$ |
| 92 | /** |
| 93 | * Opening li tag: <code><li></code> |
| 94 | */ |
| 95 | public static final String OPEN_LI = "\t<li>"; //$NON-NLS-1$ |
| 96 | /** |
| 97 | * Closing li tag: <code></li></code> |
| 98 | */ |
| 99 | public static final String CLOSE_LI = "</li>\n"; //$NON-NLS-1$ |
| 100 | /** |
| 101 | * Opening p tag: <code><p></code> |
| 102 | */ |
| 103 | public static final String OPEN_P = "<p>"; //$NON-NLS-1$ |
| 104 | /** |
| 105 | * Closing p tag: <code></p></code> |
| 106 | */ |
| 107 | public static final String CLOSE_P = "</p>\n"; //$NON-NLS-1$ |
| 108 | /** |
| 109 | * Opening ol tag: <code><ol></code> |
| 110 | */ |
| 111 | public static final String OPEN_OL = "<ol>\n"; //$NON-NLS-1$ |
| 112 | /** |
| 113 | * Closing ol tag: <code></ol></code> |
| 114 | */ |
| 115 | public static final String CLOSE_OL = "</ol>\n"; //$NON-NLS-1$ |
| 116 | /** |
| 117 | * Opening ul tag: <code><ul></code> |
| 118 | */ |
| 119 | public static final String OPEN_UL = "<ul>\n"; //$NON-NLS-1$ |
| 120 | /** |
| 121 | * Closing ul tag: <code></ul></code> |
| 122 | */ |
| 123 | public static final String CLOSE_UL = "</ul>\n"; //$NON-NLS-1$ |
| 124 | /** |
| 125 | * Opening tr tag: <code><tr></code> |
| 126 | */ |
| 127 | public static final String OPEN_TR = "<tr>\n"; //$NON-NLS-1$ |
| 128 | /** |
| 129 | * Closing tr tag: <code></tr></code> |
| 130 | */ |
| 131 | public static final String CLOSE_TR = "</tr>\n"; //$NON-NLS-1$ |
| 132 | /** |
| 133 | * Closing div tag: <code></div></code> |
| 134 | */ |
| 135 | public static final String CLOSE_DIV = "</div>\n"; //$NON-NLS-1$ |
| 136 | /** |
| 137 | * Break tag: <code><br></code> |
| 138 | */ |
| 139 | public static final String BR = "<br>"; //$NON-NLS-1$ |
| 140 | /** |
| 141 | * Closing a tag: <code></a></code> |
| 142 | */ |
| 143 | public static final String CLOSE_A = "</a>\n"; //$NON-NLS-1$ |
| 144 | /** |
| 145 | * Opening b tag: <code><b></code> |
| 146 | */ |
| 147 | public static final String OPEN_B = "<b>"; //$NON-NLS-1$ |
| 148 | /** |
| 149 | * Closing b tag: <code></b></code> |
| 150 | */ |
| 151 | public static final String CLOSE_B = "</b>"; //$NON-NLS-1$ |
| 152 | /** |
| 153 | * Closing h4 tag: <code></h4></code> |
| 154 | */ |
| 155 | public static final String CLOSE_H4 = "</h4>\n"; //$NON-NLS-1$ |
| 156 | /** |
| 157 | * Opening h4 tag: <code><h4></code> |
| 158 | */ |
| 159 | public static final String OPEN_H4 = "<h4>"; //$NON-NLS-1$ |
| 160 | |
| 161 | /** |
| 162 | * Opens a new <code><td></code> with the given width attribute set |
| 163 | * @param width |
| 164 | * @return a new open <code><td></code> tag |
| 165 | */ |
| 166 | public static String openTD(int width) { |
| 167 | StringBuffer buffer = new StringBuffer(); |
| 168 | buffer.append("<td width=\"").append(width).append("%\">"); //$NON-NLS-1$//$NON-NLS-2$ |
| 169 | return buffer.toString(); |
| 170 | } |
| 171 | } |