2 * Copyright (c) 2004 Christopher Lenz and others
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Christopher Lenz - initial API
11 * $Id: XMLElement.java,v 1.2 2006-10-21 23:13:43 pombredanne Exp $
14 package net.sourceforge.phpeclipse.xml.core.internal.model;
16 import java.util.ArrayList;
17 import java.util.List;
19 import net.sourceforge.phpeclipse.core.model.SourceReference;
20 import net.sourceforge.phpeclipse.xml.core.model.IXMLElement;
22 import org.eclipse.jface.text.IDocument;
27 public class XMLElement extends SourceReference implements IXMLElement {
29 // Instance Variables ------------------------------------------------------
31 private List children;
33 private String localName;
35 private String namespaceURI;
37 private String prefix;
39 private IXMLElement parent;
41 // Constructors ------------------------------------------------------------
43 public XMLElement(IDocument document) {
47 public XMLElement(IDocument document, int offset) {
48 super(document, offset);
51 public XMLElement(IDocument document, int offset, int length) {
52 super(document, offset, length);
55 // IXMLElement Implementation
56 // -------------------------------------------------
59 * @see IXMLElement#getChildren()
61 public IXMLElement[] getChildren() {
62 if (children != null) {
63 return (IXMLElement[]) children.toArray(new IXMLElement[children
66 return new IXMLElement[0];
70 * @see IXMLElement#getLocalName()
72 public String getLocalName() {
77 * @see IXMLElement#getNamespaceURI()
79 public String getNamespaceURI() {
84 * @see IXMLElement#getPrefix()
86 public String getPrefix() {
91 * @see IXMLElement#getParent()
93 public IXMLElement getParent() {
97 // Public Methods ----------------------------------------------------------
99 public void addChild(IXMLElement child) {
100 if (children == null) {
101 children = new ArrayList();
106 public void setLocalName(String localName) {
107 this.localName = localName;
110 public void setNamespaceURI(String namespaceURI) {
111 this.namespaceURI = namespaceURI;
114 public void setPrefix(String prefix) {
115 this.prefix = prefix;
118 public void setParent(IXMLElement parent) {
119 this.parent = parent;