--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.message.util;\r
+\r
+import java.net.URI;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public final class HtmlUtil {\r
+\r
+ /**\r
+ * Encloses the specified text within a <code><form></code> tag.\r
+ * \r
+ * @param text the text to enclose\r
+ * @return the enclosed text \r
+ */\r
+ public static String html(String text) {\r
+ return TagUtil.tag(TagUtil.tag("", "head") + TagUtil.tag(TagUtil.tag(text, "pre"), "body"), "html");\r
+ }\r
+\r
+ /**\r
+ * Produces a standard HTML <code><a></code> anchor tag with the specified\r
+ * contents.\r
+ * \r
+ * @param href the <code>href</code> attribute value of the produced anchor\r
+ * (<a href="<code>href</code>"></a>)\r
+ * @param text the <code>text</code> inside the anchor element (<a>\r
+ * <code>text</code></a>)\r
+ * @return the anchor\r
+ */\r
+ public static String a(String href, String text) {\r
+ return TagUtil.tag(text, "a", "href", href);\r
+ }\r
+\r
+ /**\r
+ * Produces a standard HTML <code><a></code> anchor tag with the specified\r
+ * contents.\r
+ * \r
+ * @param href the <code>href</code> attribute value of the produced anchor\r
+ * (<a href="<code>href</code>"></a>)\r
+ * @param text the <code>text</code> inside the anchor element (<a>\r
+ * <code>text</code></a>)\r
+ * @return the anchor\r
+ */\r
+ public static String a(URI href, String text) {\r
+ return a(href.toASCIIString(), text);\r
+ }\r
+\r
+ /**\r
+ * Produces a standard HTML <code><a></code> anchor tag with the\r
+ * specified contents.\r
+ * \r
+ * @param scheme the <code><scheme></code> part of the URI of form\r
+ * <code><scheme>:<scheme-specific-part></code>\r
+ * @param identifier the <code><scheme-specific-part></code> part of\r
+ * the URI of form\r
+ * <code><scheme>:<scheme-specific-part></code>\r
+ * @param text the <code>text</code> inside the anchor element (<a>\r
+ * <code>text</code></a>)\r
+ * @return the anchor\r
+ */\r
+ public static String a(String scheme, String identifier, String text) {\r
+ return TagUtil.tag(text, "a", "href", scheme + ":" + identifier);\r
+ }\r
+\r
+ /**\r
+ * Encloses the specified text within a <code><p></code> tag.\r
+ * \r
+ * @param text the text to enclose\r
+ * @return the enclosed text\r
+ */\r
+ public static String p(String text) {\r
+ return TagUtil.tag(text, "p");\r
+ }\r
+\r
+}\r