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