1 11 package org.eclipse.ui.internal.intro.impl.html; 12 13 import java.util.Hashtable ; 14 import java.util.Iterator ; 15 import java.util.Map ; 16 import java.util.Vector ; 17 18 22 public class HTMLElement { 23 24 private String elementName; 26 27 private Map elementAttributes; 29 30 private Vector elementContent; 33 34 public HTMLElement(String name) { 35 this.elementName = name; 36 this.elementAttributes = new Hashtable (); 37 this.elementContent = new Vector (); 38 } 39 40 public HTMLElement(String name, Map attributes, Vector content) { 41 this.elementName = name; 42 this.elementAttributes = attributes; 43 this.elementContent = content; 44 } 45 46 52 public void addAttribute(String attributeName, String attributeValue) { 53 if(attributeName != null && attributeValue != null) 54 getElementAttributes().put(attributeName, attributeValue); 55 } 56 57 61 public void addContent(Object content) { 62 getElementContent().add(content); 63 } 64 65 70 public Map getElementAttributes() { 71 if (elementAttributes == null) 72 elementAttributes = new Hashtable (); 73 74 return elementAttributes; 75 } 76 77 83 public void setElementAttributes(Map elementAttributes) { 84 this.elementAttributes = elementAttributes; 85 } 86 87 92 public Vector getElementContent() { 93 if (elementContent == null) 94 elementContent = new Vector (); 95 96 return elementContent; 97 } 98 99 105 public void setElementContent(Vector elementContent) { 106 this.elementContent = elementContent; 107 } 108 109 114 public String getElementName() { 115 return elementName; 116 } 117 118 124 public void setElementName(String elementName) { 125 this.elementName = elementName; 126 } 127 128 133 public String toString() { 134 StringBuffer element = new StringBuffer (); 135 136 element.append( 138 HTMLUtil.createHTMLStartTag( 139 getElementName(), 140 getElementAttributes(), 141 false)); 142 143 for (Iterator it = getElementContent().iterator(); it.hasNext();) { 145 Object content = it.next(); 146 element.append(content); 147 } 148 149 element.append(HTMLUtil.createHTMLEndTag(getElementName(), false)); 151 return element.toString(); 152 } 153 } 154 | Popular Tags |