org.rhq.enterprise.server.plugins.rhnhosted.certificate
Class XmlTag

java.lang.Object
  extended by org.rhq.enterprise.server.plugins.rhnhosted.certificate.XmlTag

public class XmlTag
extends Object

XmlTag a simple class to render an XML tag


Field Summary
static String XML_HDR
          Standard xml header with no encoding.
static String XML_HDR_UTF8
          Standard xml header with utf-8 encoding.
 
Constructor Summary
protected XmlTag(String tagIn)
          Public constructor
protected XmlTag(String tagIn, boolean spaceBefore)
          Constructs an XmlTag.
 
Method Summary
 void addBody(String bodyIn)
          set the body of the tag
 void addBody(XmlTag bodyTag)
          Adds the given tag to the body of this tag.
 boolean hasBody()
          Returns true if this tag has a body defined.
 void removeAttribute(String name)
          Removes an attribute of the html tag.
 String render()
          render the tag into a string
 String renderBody()
          render the tag body
 String renderCloseTag()
          render the close tag
 String renderOpenTag()
          render the open tag and attributes
 void setAttribute(String name, String value)
          set an attribute of the html tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_HDR_UTF8

public static final String XML_HDR_UTF8
Standard xml header with utf-8 encoding. Example usage:
StringBuffer buf = new StringBuffer(); buf.append(XmlTag.XML_HDR_UTF8); buf.append(new XmlTag("foo").render());

See Also:
Constant Field Values

XML_HDR

public static final String XML_HDR
Standard xml header with no encoding. Example usage:
StringBuffer buf = new StringBuffer(); buf.append(XmlTag.XML_HDR); buf.append(new XmlTag("foo").render());

See Also:
Constant Field Values
Constructor Detail

XmlTag

protected XmlTag(String tagIn)
Public constructor

Parameters:
tagIn - the name of the tag

XmlTag

protected XmlTag(String tagIn,
                 boolean spaceBefore)
Constructs an XmlTag. The spaceBefore attribute controls whether a space is inserted before the closing tag of a single line element.
For example, a true value for spaceBefore and a tagIn of "foo" will render <foo />. A spaceBefore value of false would've rendered <foo/>.

Parameters:
tagIn - the name of the tag
spaceBefore - true if you want a space before the closing tag.
Method Detail

setAttribute

public void setAttribute(String name,
                         String value)
set an attribute of the html tag

Parameters:
name - the attribute name
value - the attribute value

removeAttribute

public void removeAttribute(String name)
Removes an attribute of the html tag.

Parameters:
name - the attribute name to be removed.

addBody

public void addBody(String bodyIn)
set the body of the tag

Parameters:
bodyIn - the new body

addBody

public void addBody(XmlTag bodyTag)
Adds the given tag to the body of this tag.

Parameters:
bodyTag - Tag to be added to the body of this tag.

render

public String render()
render the tag into a string

Returns:
the string version

renderOpenTag

public String renderOpenTag()
render the open tag and attributes

Returns:
the open tag as a string

renderBody

public String renderBody()
render the tag body

Returns:
the tag body as a string

renderCloseTag

public String renderCloseTag()
render the close tag

Returns:
the close tag as a string

hasBody

public boolean hasBody()
Returns true if this tag has a body defined.

Returns:
true if this tag has a body defined.


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.