Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004, 2007 IBM Corporation and others. 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: IBM Corporation - initial API and implementation /
 
 package org.eclipse.ui.internal.intro.impl.html;
 
 import java.util.Map;
This class represents an HTML element. An HTML element has a name, a collection of attributes, and content
 
 public class HTMLElement {
 
 	// the name of the element
 	private String elementName;
 
 	// a collection of attributes that belong to this element (possibly empty)
 	private Map elementAttributes;
 
 	// a collection of other HTMLElements or Strings contained inside this
 	// element
 	private Vector elementContent;
 
 	public HTMLElement(String name) {
 		this. = name;
 		this. = new Hashtable();
 		this. = new Vector();
 	}
 
 	public HTMLElement(String nameMap attributesVector content) {
 		this. = name;
 		this. = attributes;
 		this. = content;
 	}

Add an attribute with the given name and value to this HTMLElement

Parameters:
attributeName
attributeValue
 
 	public void addAttribute(String attributeNameString attributeValue) {
 		if(attributeName != null && attributeValue != null)
 			getElementAttributes().put(attributeNameattributeValue);
 	}

Add content to this element. The content should be in the form of another HTMLElement, or a String
 
 	public void addContent(Object content) {
 		getElementContent().add(content);
 	}

Get the attributes associated with this element

Returns:
Returns the elementAttributes.
 
 	public Map getElementAttributes() {
 		if ( == null)
 
 	}

Set the attributes associated with this element

Parameters:
elementAttributes The elementAttributes to set.
 
 	public void setElementAttributes(Map elementAttributes) {
 		this. = elementAttributes;
 	}

Get this element's content

Returns:
Returns the elementContent.
 
 	public Vector getElementContent() {
 		if ( == null)
 			 = new Vector();
 
 		return ;
 	}

Set this element's content

Parameters:
elementContent The elementContent to set.
	public void setElementContent(Vector elementContent) {
		this. = elementContent;
	}

Get the name of this element

Returns:
Returns the elementName.
	public String getElementName() {
		return ;
	}

Set the name of this element

Parameters:
elementName The elementName to set.
	public void setElementName(String elementName) {
		this. = elementName;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		StringBuffer element = new StringBuffer();
		// add the start tag and attributes
		element.append(
				false));
		// include the element's content
		for (Iterator it = getElementContent().iterator(); it.hasNext();) {
			Object content = it.next();
			element.append(content);
		}
		// include an end tag
		element.append(HTMLUtil.createHTMLEndTag(getElementName(), false));
		return element.toString();
	}
New to GrepCode? Check out our FAQ X