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.1 2004-09-02 18:26:55 jsurfer 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;
34 private String namespaceURI;
35 private String prefix;
37 private IXMLElement parent;
39 // Constructors ------------------------------------------------------------
41 public XMLElement(IDocument document) {
45 public XMLElement(IDocument document, int offset) {
46 super(document, offset);
49 public XMLElement(IDocument document, int offset, int length) {
50 super(document, offset, length);
53 // IXMLElement Implementation -------------------------------------------------
56 * @see IXMLElement#getChildren()
58 public IXMLElement[] getChildren() {
59 if (children != null) {
60 return (IXMLElement[]) children.toArray(
61 new IXMLElement[children.size()]);
63 return new IXMLElement[0];
67 * @see IXMLElement#getLocalName()
69 public String getLocalName() {
74 * @see IXMLElement#getNamespaceURI()
76 public String getNamespaceURI() {
81 * @see IXMLElement#getPrefix()
83 public String getPrefix() {
88 * @see IXMLElement#getParent()
90 public IXMLElement getParent() {
94 // Public Methods ----------------------------------------------------------
96 public void addChild(IXMLElement child) {
97 if (children == null) {
98 children = new ArrayList();
103 public void setLocalName(String localName) {
104 this.localName = localName;
107 public void setNamespaceURI(String namespaceURI) {
108 this.namespaceURI = namespaceURI;
111 public void setPrefix(String prefix) {
112 this.prefix = prefix;
115 public void setParent(IXMLElement parent) {
116 this.parent = parent;