Changes for variablemodificatin
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPValue.java
index beca6a3..ba349af 100644 (file)
@@ -8,55 +8,93 @@ http://www.eclipse.org/legal/cpl-v10.html
 Contributors:
     IBM Corporation - Initial implementation
     Vicente Fernando - www.alfersoft.com.ar
+    Christian Perkonig - cperkonig@gmx.at
 **********************************************************************/
 package net.sourceforge.phpdt.internal.debug.core.model;
 
+
+import java.util.Iterator;
+import java.util.Vector;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IDebugTarget;
 import org.eclipse.debug.core.model.IValue;
 import org.eclipse.debug.core.model.IVariable;
 
-/**
- * @author Administrator
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class PHPValue implements IValue {
 
-       private String valueString ;
-       private String referenceTypeName ;
-       private boolean hasChildren= false ;
-       private PHPVariable owner ;
-       private PHPVariable[] variables ;
+public class PHPValue implements IValue {
+       
+       final static String[] PEV_NAMES={"undefined","long","double","string","array",
+                        "object","boolean","resource","reference","soft reference"}; 
+       final static int PEVT_UNKNOWN =0;
+       final static int PEVT_LONG = 1;
+       final static int PEVT_DOUBLE=2;
+       final static int PEVT_STRING=3;
+       final static int PEVT_ARRAY=4;
+       final static int PEVT_OBJECT=5;
+       final static int PEVT_BOOLEAN=6;
+       final static int PEVT_RESOURCE=7;
+       final static int PEVT_REF=8;
+       final static int PEVT_SOFTREF=9;
+       
+       private int fValueType;
+       private boolean hasChildren;
+       private String fValueString;
+       private Vector fVariables;
+       private PHPStackFrame fStackFrame;
        
-       public PHPValue(PHPVariable owner) {
-               this(owner, "nil", null, false) ;
-       }       
+       PHPValue() {
+               this(null,"",PEVT_UNKNOWN,null);
+       }
+       
+       PHPValue(PHPStackFrame frame,String value,int fValueType,Vector subitems)
+       {
+               this.fValueType=fValueType;
+               this.fValueString=value;
+               this.fStackFrame=frame;
+               if (subitems !=null)
+                       this.fVariables=new Vector(subitems);
+               else
+                       this.fVariables = new Vector();
+       }
        
-       public PHPValue(PHPVariable owner, String valueString, String type, boolean hasChildren) {
-               this.valueString = valueString ;        
-               this.owner = owner ;
-               this.hasChildren = hasChildren ;
-               this.referenceTypeName = type ;
+       Vector addVariable(Vector item)
+       {       
+               if (item!=null)
+                       this.fVariables.addAll(item);
+               return this.fVariables;
        }
        
+       public void setParent(PHPVariable parent) {
+               if (!fVariables.isEmpty()) {
+                       Iterator iter=fVariables.iterator();
+                       while (iter.hasNext()) {
+                               ((PHPVariable)iter.next()).setParent(parent);
+                       }
+               
+               }
+       }
 
        /**
         * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
         */
-       public String getReferenceTypeName()  {
-               return this.referenceTypeName;
+       public String getReferenceTypeName(){
+               return PEV_NAMES[fValueType];
+       }
+       
+       public int getReferenceType(){
+               return fValueType;
+       }
+       
+       public int setReferenceType(int type){
+               return fValueType=type;
        }
 
        /**
-        * @see org.eclipse.debug.core.model.IValue#getValueString()
+        * @see org.eclipse.debug.core.model.IValue#getfValueString()
         */
        public String getValueString() {
-               return valueString;
+               return fValueString;
        }
 
        /**
@@ -69,56 +107,45 @@ public class PHPValue implements IValue {
        /**
         * @see org.eclipse.debug.core.model.IValue#getVariables()
         */
-       public IVariable[] getVariables() throws DebugException {
-               if (!hasChildren) {
-                       return new PHPVariable[0] ;     
-               }
-               if (variables == null) {
-                       variables = ((PHPDebugTarget) this.getDebugTarget()).getPHPDBGProxy().readInstanceVariables(owner);
-               }
-               return variables;
+       public IVariable[] getVariables() {
+               return (PHPVariable[])fVariables.toArray(new PHPVariable[fVariables.size()]);
+//             return  (IVariable[])fVariables.toArray();
        }
 
        /**
         * @see org.eclipse.debug.core.model.IValue#hasVariables()
         */
        public boolean hasVariables() throws DebugException {
-               return hasChildren;
+               return (!fVariables.isEmpty());
        }
 
        /**
         * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
         */
        public String getModelIdentifier() {
-               return owner.getModelIdentifier();
+               // TODO Auto-generated method stub
+               return null;
        }
 
-       /**
+       /** 
         * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
         */
        public IDebugTarget getDebugTarget() {
-               return owner.getDebugTarget();
+               return fStackFrame.getDebugTarget();
        }
 
        /**
         * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
         */
        public ILaunch getLaunch() {
-               return this.getDebugTarget().getLaunch();
+               return getDebugTarget().getLaunch();
        }
 
        /**
-        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
         */
        public Object getAdapter(Class adapter) {
                return null;
        }
-       
-       public String toString() {
-               if (this.getReferenceTypeName() == null) {                      
-                       return this.getValueString() ;                          
-               }       
-               return this.getValueString() ;
-       }
 
 }