1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.message.util;
\r
14 import java.net.URI;
\r
17 * @author Tuukka Lehtonen
\r
19 public final class HtmlUtil {
\r
22 * Encloses the specified text within a <code><form></code> tag.
\r
24 * @param text the text to enclose
\r
25 * @return the enclosed text
\r
27 public static String html(String text) {
\r
28 return TagUtil.tag(TagUtil.tag("", "head") + TagUtil.tag(TagUtil.tag(text, "pre"), "body"), "html");
\r
32 * Produces a standard HTML <code><a></code> anchor tag with the specified
\r
35 * @param href the <code>href</code> attribute value of the produced anchor
\r
36 * (<a href="<code>href</code>"></a>)
\r
37 * @param text the <code>text</code> inside the anchor element (<a>
\r
38 * <code>text</code></a>)
\r
39 * @return the anchor
\r
41 public static String a(String href, String text) {
\r
42 return TagUtil.tag(text, "a", "href", href);
\r
46 * Produces a standard HTML <code><a></code> anchor tag with the specified
\r
49 * @param href the <code>href</code> attribute value of the produced anchor
\r
50 * (<a href="<code>href</code>"></a>)
\r
51 * @param text the <code>text</code> inside the anchor element (<a>
\r
52 * <code>text</code></a>)
\r
53 * @return the anchor
\r
55 public static String a(URI href, String text) {
\r
56 return a(href.toASCIIString(), text);
\r
60 * Produces a standard HTML <code><a></code> anchor tag with the
\r
61 * specified contents.
\r
63 * @param scheme the <code><scheme></code> part of the URI of form
\r
64 * <code><scheme>:<scheme-specific-part></code>
\r
65 * @param identifier the <code><scheme-specific-part></code> part of
\r
67 * <code><scheme>:<scheme-specific-part></code>
\r
68 * @param text the <code>text</code> inside the anchor element (<a>
\r
69 * <code>text</code></a>)
\r
70 * @return the anchor
\r
72 public static String a(String scheme, String identifier, String text) {
\r
73 return TagUtil.tag(text, "a", "href", scheme + ":" + identifier);
\r
77 * Encloses the specified text within a <code><p></code> tag.
\r
79 * @param text the text to enclose
\r
80 * @return the enclosed text
\r
82 public static String p(String text) {
\r
83 return TagUtil.tag(text, "p");
\r