A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.xml.core / src / net / sourceforge / phpeclipse / xml / core / internal / model / XMLElement.java
1 /*
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
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial API
10  * 
11  * $Id: XMLElement.java,v 1.2 2006-10-21 23:13:43 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpeclipse.xml.core.internal.model;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import net.sourceforge.phpeclipse.core.model.SourceReference;
20 import net.sourceforge.phpeclipse.xml.core.model.IXMLElement;
21
22 import org.eclipse.jface.text.IDocument;
23
24 /**
25  * 
26  */
27 public class XMLElement extends SourceReference implements IXMLElement {
28
29         // Instance Variables ------------------------------------------------------
30
31         private List children;
32
33         private String localName;
34
35         private String namespaceURI;
36
37         private String prefix;
38
39         private IXMLElement parent;
40
41         // Constructors ------------------------------------------------------------
42
43         public XMLElement(IDocument document) {
44                 super(document);
45         }
46
47         public XMLElement(IDocument document, int offset) {
48                 super(document, offset);
49         }
50
51         public XMLElement(IDocument document, int offset, int length) {
52                 super(document, offset, length);
53         }
54
55         // IXMLElement Implementation
56         // -------------------------------------------------
57
58         /*
59          * @see IXMLElement#getChildren()
60          */
61         public IXMLElement[] getChildren() {
62                 if (children != null) {
63                         return (IXMLElement[]) children.toArray(new IXMLElement[children
64                                         .size()]);
65                 }
66                 return new IXMLElement[0];
67         }
68
69         /*
70          * @see IXMLElement#getLocalName()
71          */
72         public String getLocalName() {
73                 return localName;
74         }
75
76         /*
77          * @see IXMLElement#getNamespaceURI()
78          */
79         public String getNamespaceURI() {
80                 return namespaceURI;
81         }
82
83         /*
84          * @see IXMLElement#getPrefix()
85          */
86         public String getPrefix() {
87                 return prefix;
88         }
89
90         /*
91          * @see IXMLElement#getParent()
92          */
93         public IXMLElement getParent() {
94                 return parent;
95         }
96
97         // Public Methods ----------------------------------------------------------
98
99         public void addChild(IXMLElement child) {
100                 if (children == null) {
101                         children = new ArrayList();
102                 }
103                 children.add(child);
104         }
105
106         public void setLocalName(String localName) {
107                 this.localName = localName;
108         }
109
110         public void setNamespaceURI(String namespaceURI) {
111                 this.namespaceURI = namespaceURI;
112         }
113
114         public void setPrefix(String prefix) {
115                 this.prefix = prefix;
116         }
117
118         public void setParent(IXMLElement parent) {
119                 this.parent = parent;
120         }
121
122 }