Avoid "uninitialized variable" message after new keyword
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPValue.java
1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. 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 implementation
10     Vicente Fernando - www.alfersoft.com.ar
11     Christian Perkonig - cperkonig@gmx.at
12 **********************************************************************/
13 package net.sourceforge.phpdt.internal.debug.core.model;
14
15
16 import java.util.Iterator;
17 import java.util.Vector;
18
19 import org.eclipse.debug.core.DebugException;
20 import org.eclipse.debug.core.ILaunch;
21 import org.eclipse.debug.core.model.IDebugTarget;
22 import org.eclipse.debug.core.model.IValue;
23 import org.eclipse.debug.core.model.IVariable;
24
25
26 public class PHPValue implements IValue {
27         
28         final static String[] PEV_NAMES={"undefined","long","double","string","array",
29                          "object","boolean","resource","reference","soft reference"}; 
30         final static int PEVT_UNKNOWN =0;
31         final static int PEVT_LONG = 1;
32         final static int PEVT_DOUBLE=2;
33         final static int PEVT_STRING=3;
34         final static int PEVT_ARRAY=4;
35         final static int PEVT_OBJECT=5;
36         final static int PEVT_BOOLEAN=6;
37         final static int PEVT_RESOURCE=7;
38         final static int PEVT_REF=8;
39         final static int PEVT_SOFTREF=9;
40         
41         private int fValueType;
42         private boolean hasChildren;
43         private String fValueString;
44         private Vector fVariables;
45         private PHPStackFrame fStackFrame;
46         
47         PHPValue() {
48                 this(null,"",PEVT_UNKNOWN,null);
49         }
50         
51         PHPValue(PHPStackFrame frame,String value,int fValueType,Vector subitems)
52         {
53                 this.fValueType=fValueType;
54                 this.fValueString=value;
55                 this.fStackFrame=frame;
56                 if (subitems !=null)
57                         this.fVariables=new Vector(subitems);
58                 else
59                         this.fVariables = new Vector();
60         }
61         
62         Vector addVariable(Vector item)
63         {       
64                 if (item!=null)
65                         this.fVariables.addAll(item);
66                 return this.fVariables;
67         }
68         
69         public void setParent(PHPVariable parent) {
70                 if (!fVariables.isEmpty()) {
71                         Iterator iter=fVariables.iterator();
72                         while (iter.hasNext()) {
73                                 ((PHPVariable)iter.next()).setParent(parent);
74                         }
75                 
76                 }
77         }
78
79         /**
80          * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
81          */
82         public String getReferenceTypeName(){
83                 return PEV_NAMES[fValueType];
84         }
85         
86         public int getReferenceType(){
87                 return fValueType;
88         }
89         
90         public int setReferenceType(int type){
91                 return fValueType=type;
92         }
93
94         /**
95          * @see org.eclipse.debug.core.model.IValue#getfValueString()
96          */
97         public String getValueString() {
98                 return fValueString;
99         }
100
101         /**
102          * @see org.eclipse.debug.core.model.IValue#isAllocated()
103          */
104         public boolean isAllocated() throws DebugException {
105                 return false;
106         }
107
108         /**
109          * @see org.eclipse.debug.core.model.IValue#getVariables()
110          */
111         public IVariable[] getVariables() {
112                 return (PHPVariable[])fVariables.toArray(new PHPVariable[fVariables.size()]);
113 //              return  (IVariable[])fVariables.toArray();
114         }
115
116         /**
117          * @see org.eclipse.debug.core.model.IValue#hasVariables()
118          */
119         public boolean hasVariables() throws DebugException {
120                 return (!fVariables.isEmpty());
121         }
122
123         /**
124          * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
125          */
126         public String getModelIdentifier() {
127                 // TODO Auto-generated method stub
128                 return null;
129         }
130
131         /** 
132          * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
133          */
134         public IDebugTarget getDebugTarget() {
135                 return fStackFrame.getDebugTarget();
136         }
137
138         /**
139          * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
140          */
141         public ILaunch getLaunch() {
142                 return getDebugTarget().getLaunch();
143         }
144
145         /**
146          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
147          */
148         public Object getAdapter(Class adapter) {
149                 return null;
150         }
151
152 }