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