new version with WorkingCopy Management
[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.IType;
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(IType parent, String name) {
29         super(FIELD, parent, name);
30 }
31 /**
32  * @see JavaElement#equalsDOMNode
33  */
34 protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException {
35         return (node.getNodeType() == IDOMNode.FIELD) && super.equalsDOMNode(node);
36 }
37 /**
38  * @see IField
39  */
40 public Object getConstant() throws JavaModelException {
41         SourceFieldElementInfo info = (SourceFieldElementInfo) getElementInfo();
42         return info.initializationSource;
43 }
44 /**
45  * @see JavaElement#getHandleMemento()
46  */
47 protected char getHandleMementoDelimiter() {
48         return JavaElement.JEM_FIELD;
49 }
50 /**
51  * @see IField
52  */
53 public String getTypeSignature() throws JavaModelException {
54         SourceFieldElementInfo info = (SourceFieldElementInfo) getElementInfo();
55         return info.getTypeSignature();
56 }
57 /**
58  * @private Debugging purposes
59  */
60 protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
61         buffer.append(this.tabString(tab));
62         if (info == null) {
63                 buffer.append(getElementName());
64                 buffer.append(" (not open)"); //$NON-NLS-1$
65         } else if (info == NO_INFO) {
66                 buffer.append(getElementName());
67         } else {
68                 try {
69                         buffer.append(Signature.toString(this.getTypeSignature()));
70                         buffer.append(" "); //$NON-NLS-1$
71                         buffer.append(this.getElementName());
72                 } catch (JavaModelException e) {
73                         buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
74                 }
75         }
76 }
77 }