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