added class fields to outline
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / SourceField.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation 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  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
12
13 import net.sourceforge.phpdt.core.IJavaElement;
14 import net.sourceforge.phpdt.internal.core.JavaElement;
15
16 import net.sourceforge.phpdt.core.IField;
17 import net.sourceforge.phpdt.core.JavaModelException;
18 import net.sourceforge.phpdt.core.Signature;
19 import net.sourceforge.phpdt.core.jdom.IDOMNode;
20
21 /**
22  * @see IField
23  */
24
25 /* package */ class SourceField extends Member implements IField {
26
27         /**
28          * Constructs a handle to the field with the given name in the specified type. 
29          */
30         protected SourceField(JavaElement parent, String name) {
31                 super(parent, name);
32         }
33         public boolean equals(Object o) {
34                 if (!(o instanceof SourceField)) return false;
35                 return super.equals(o);
36         }
37 /**
38  * @see JavaElement#equalsDOMNode
39  */
40 protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException {
41         return (node.getNodeType() == IDOMNode.FIELD) && super.equalsDOMNode(node);
42 }
43 /**
44  * @see IField
45  */
46 public Object getConstant() throws JavaModelException {
47         SourceFieldElementInfo info = (SourceFieldElementInfo) getElementInfo();
48         return info.initializationSource;
49 }
50 /**
51  * @see IJavaElement
52  */
53 public int getElementType() {
54         return FIELD;
55 }
56 /**
57  * @see JavaElement#getHandleMemento()
58  */
59 protected char getHandleMementoDelimiter() {
60         return JavaElement.JEM_FIELD;
61 }
62 /**
63  * @see IField
64  */
65 public String getTypeSignature() throws JavaModelException {
66 //      SourceFieldElementInfo info = (SourceFieldElementInfo) getElementInfo();
67 //      return info.getTypeSignature();
68         return "";
69 }
70 /**
71  * @private Debugging purposes
72  */
73 protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
74         buffer.append(this.tabString(tab));
75         if (info == null) {
76                 buffer.append(getElementName());
77                 buffer.append(" (not open)"); //$NON-NLS-1$
78         } else if (info == NO_INFO) {
79                 buffer.append(getElementName());
80         } else {
81                 try {
82                         buffer.append(Signature.toString(this.getTypeSignature()));
83                         buffer.append(" "); //$NON-NLS-1$
84                         buffer.append(this.getElementName());
85                 } catch (JavaModelException e) {
86                         buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
87                 }
88         }
89 }
90 }