beca6a33955f57b6ba0c0e0f1fe9d37a207c8846
[phpeclipse.git] /
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 **********************************************************************/
12 package net.sourceforge.phpdt.internal.debug.core.model;
13
14 import org.eclipse.debug.core.DebugException;
15 import org.eclipse.debug.core.ILaunch;
16 import org.eclipse.debug.core.model.IDebugTarget;
17 import org.eclipse.debug.core.model.IValue;
18 import org.eclipse.debug.core.model.IVariable;
19
20 /**
21  * @author Administrator
22  *
23  * To change this generated comment edit the template variable "typecomment":
24  * Window>Preferences>Java>Templates.
25  * To enable and disable the creation of type comments go to
26  * Window>Preferences>Java>Code Generation.
27  */
28 public class PHPValue implements IValue {
29
30         private String valueString ;
31         private String referenceTypeName ;
32         private boolean hasChildren= false ;
33         private PHPVariable owner ;
34         private PHPVariable[] variables ;
35         
36         public PHPValue(PHPVariable owner) {
37                 this(owner, "nil", null, false) ;
38         }       
39         
40         public PHPValue(PHPVariable owner, String valueString, String type, boolean hasChildren) {
41                 this.valueString = valueString ;        
42                 this.owner = owner ;
43                 this.hasChildren = hasChildren ;
44                 this.referenceTypeName = type ;
45         }
46         
47
48         /**
49          * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
50          */
51         public String getReferenceTypeName()  {
52                 return this.referenceTypeName;
53         }
54
55         /**
56          * @see org.eclipse.debug.core.model.IValue#getValueString()
57          */
58         public String getValueString() {
59                 return valueString;
60         }
61
62         /**
63          * @see org.eclipse.debug.core.model.IValue#isAllocated()
64          */
65         public boolean isAllocated() throws DebugException {
66                 return false;
67         }
68
69         /**
70          * @see org.eclipse.debug.core.model.IValue#getVariables()
71          */
72         public IVariable[] getVariables() throws DebugException {
73                 if (!hasChildren) {
74                         return new PHPVariable[0] ;     
75                 }
76                 if (variables == null) {
77                         variables = ((PHPDebugTarget) this.getDebugTarget()).getPHPDBGProxy().readInstanceVariables(owner);
78                 }
79                 return variables;
80         }
81
82         /**
83          * @see org.eclipse.debug.core.model.IValue#hasVariables()
84          */
85         public boolean hasVariables() throws DebugException {
86                 return hasChildren;
87         }
88
89         /**
90          * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
91          */
92         public String getModelIdentifier() {
93                 return owner.getModelIdentifier();
94         }
95
96         /**
97          * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
98          */
99         public IDebugTarget getDebugTarget() {
100                 return owner.getDebugTarget();
101         }
102
103         /**
104          * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
105          */
106         public ILaunch getLaunch() {
107                 return this.getDebugTarget().getLaunch();
108         }
109
110         /**
111          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
112          */
113         public Object getAdapter(Class adapter) {
114                 return null;
115         }
116         
117         public String toString() {
118                 if (this.getReferenceTypeName() == null) {                      
119                         return this.getValueString() ;                          
120                 }       
121                 return this.getValueString() ;
122         }
123
124 }