FileDocCategorySizeDatePackage
HTMLDocument.javaAPI DocGlassfish v2 API5043Fri May 04 22:34:48 BST 2007com.sun.enterprise.diagnostics.report.html

HTMLDocument

public class HTMLDocument extends Object implements Document

Fields Summary
private Element
html
The root HTML element.
private Element
head
The head element.
private Element
body
The body element.
private String
doctype
The doctype.
Constructors Summary
Methods Summary
public ElementgetBody()

  
         
       
        return body;
    
public java.lang.StringgetDoctype()

        return doctype;
    
public ElementgetHead()

        return head;
    
public voidset(Element head, Element body)

        if (head == null) {
            throw new NullPointerException("Head element is null.");
        }
        if (body == null) {
            throw new NullPointerException("Body element is null.");
        }
        
        // Check the element names.
        if (!head.getName().equalsIgnoreCase(HTMLReportConstants.HEAD)) {
            new HTMLElement("HEAD").add(head);
        }
        if (!body.getName().equalsIgnoreCase(HTMLReportConstants.BODY)) {
            new HTMLElement("BODY").add(head);
        }
        
        // Discard old elements.
        List<Element> elements = html.getElements("BODY");
        for (Element element : elements) {
            html.delete(element);
        } // Loop discarding body elements.
        elements = html.getElements("HEAD");
        for (Element element : elements) {
            html.delete(element);
        } // Loop discarding head elements.
        
        // Add the new elements.
        html.add(head);
        html.add(body);
        this.head = head;
        this.body = body;
    
public voidsetDoctype(java.lang.String raw)

        if (raw == null) {
            throw new NullPointerException("Doctype string is null.");
        }
        doctype = raw;
    
public java.lang.StringtoString()

see
java.lang.Object#toString()

        StringBuffer buf = new StringBuffer();
        buf.append("<!DOCTYPE html PUBLIC \"")
        	.append(Escape.getInstance().encodeEntities(doctype, ""))
        	.append("\">\n")
        	.append(html.toString());
        return buf.toString();
    
public voidwrite(java.io.Writer output)

        output.append("<!DOCTYPE html PUBLIC \"")
    		.append(Escape.getInstance().encodeEntities(doctype, ""))
    		.append("\">\n")
    		.append(html.toString());
        output.flush();
    
public voidwrite(java.io.File file)

        FileWriter fw = new FileWriter(file);
        write(fw);
        fw.close();