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