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;
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;
25 public class PHPValue implements IValue {
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;
40 private int fValueType;
41 private boolean hasChildren;
42 private String fValueString;
43 private Vector fVariables;
44 private PHPStackFrame fStackFrame;
47 this(null,"",PEVT_UNKNOWN,null);
50 PHPValue(PHPStackFrame frame,String value,int fValueType,Vector subitems)
52 this.fValueType=fValueType;
53 this.fValueString=value;
54 this.fStackFrame=frame;
56 this.fVariables=new Vector(subitems);
58 this.fVariables = new Vector();
61 Vector addVariable(Vector item)
64 this.fVariables.addAll(item);
65 return this.fVariables;
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);
79 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
81 public String getReferenceTypeName(){
82 return PEV_NAMES[fValueType];
85 public int getReferenceType(){
89 public int setReferenceType(int type){
90 return fValueType=type;
94 * @see org.eclipse.debug.core.model.IValue#getfValueString()
96 public String getValueString() {
101 * @see org.eclipse.debug.core.model.IValue#isAllocated()
103 public boolean isAllocated() throws DebugException {
108 * @see org.eclipse.debug.core.model.IValue#getVariables()
110 public IVariable[] getVariables() {
111 return (PHPVariable[])fVariables.toArray(new PHPVariable[fVariables.size()]);
112 // return (IVariable[])fVariables.toArray();
116 * @see org.eclipse.debug.core.model.IValue#hasVariables()
118 public boolean hasVariables() throws DebugException {
119 return (!fVariables.isEmpty());
123 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
125 public String getModelIdentifier() {
126 // TODO Auto-generated method stub
131 * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
133 public IDebugTarget getDebugTarget() {
134 return fStackFrame.getDebugTarget();
138 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
140 public ILaunch getLaunch() {
141 return getDebugTarget().getLaunch();
145 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
147 public Object getAdapter(Class adapter) {