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
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;
16 import java.util.Iterator;
17 import java.util.Vector;
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;
26 public class PHPValue implements IValue {
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;
41 private int fValueType;
42 private boolean hasChildren;
43 private String fValueString;
44 private Vector fVariables;
45 private PHPStackFrame fStackFrame;
48 this(null,"",PEVT_UNKNOWN,null);
51 PHPValue(PHPStackFrame frame,String value,int fValueType,Vector subitems)
53 this.fValueType=fValueType;
54 this.fValueString=value;
55 this.fStackFrame=frame;
57 this.fVariables=new Vector(subitems);
59 this.fVariables = new Vector();
62 Vector addVariable(Vector item)
65 this.fVariables.addAll(item);
66 return this.fVariables;
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);
80 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
82 public String getReferenceTypeName(){
83 return PEV_NAMES[fValueType];
86 public int getReferenceType(){
90 public int setReferenceType(int type){
91 return fValueType=type;
95 * @see org.eclipse.debug.core.model.IValue#getfValueString()
97 public String getValueString() {
102 * @see org.eclipse.debug.core.model.IValue#isAllocated()
104 public boolean isAllocated() throws DebugException {
109 * @see org.eclipse.debug.core.model.IValue#getVariables()
111 public IVariable[] getVariables() {
112 return (PHPVariable[])fVariables.toArray(new PHPVariable[fVariables.size()]);
113 // return (IVariable[])fVariables.toArray();
117 * @see org.eclipse.debug.core.model.IValue#hasVariables()
119 public boolean hasVariables() throws DebugException {
120 return (!fVariables.isEmpty());
124 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
126 public String getModelIdentifier() {
127 // TODO Auto-generated method stub
132 * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
134 public IDebugTarget getDebugTarget() {
135 return fStackFrame.getDebugTarget();
139 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
141 public ILaunch getLaunch() {
142 return getDebugTarget().getLaunch();
146 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
148 public Object getAdapter(Class adapter) {