Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

ObjectValue.java

00001 package gov.nasa.arc.ase.jpf.jvm.examine;
00002 
00003 import gov.nasa.arc.ase.jpf.jvm.ElementInfo;
00004 import gov.nasa.arc.ase.jpf.jvm.SystemState;
00005 import gov.nasa.arc.ase.jpf.jvm.Types;
00006 
00007 public class ObjectValue implements iValue {
00008   ElementInfo e;
00009 
00010   public ObjectValue(int objref, SystemState ss) {
00011     if (objref == -1) {
00012       e = null;
00013     } else {
00014       e = ss.ks.da.get(objref);
00015     }
00016   }  
00017   public boolean equals(Object o) {
00018     if(o == null) return false;
00019     if(!(o instanceof ObjectValue)) return false;
00020     ObjectValue ov = (ObjectValue)o;
00021 
00022     if(e == null)
00023       return (ov.e == null);
00024 
00025     return e.index == ov.e.index;
00026   }  
00027   public iValue getFieldValue(String fieldName) {
00028     long value = e.getField(fieldName);
00029 
00030     if(Types.getTypeSize(e.getFieldType(fieldName)) == 1)
00031       return State.createValue(e.getFieldType(fieldName), e.getField(fieldName), e.area.ks.ss);
00032     else
00033       return State.createValue(e.getFieldType(fieldName), e.getLongField(fieldName), e.area.ks.ss);
00034   }  
00035   public int getHoldingThread() {
00036     return e.getLockingThread();
00037   }  
00038   public String getTypeName() {
00039     return e.getClassInfo().getName();
00040   }  
00041   public int[] getWaitingThreads() {
00042     return e.getWaitingThreads();
00043   }  
00044   public int hashCode() {
00045     return toString().hashCode();
00046   }  
00047   public String toString() {
00048     if (e == null) return "null";
00049 
00050     StringBuffer sb = new StringBuffer();
00051     sb.append("#");
00052     sb.append(e.index);
00053     sb.append('\n');
00054 
00055     sb.append("Holding: ");
00056     if(getHoldingThread() == -1)
00057       sb.append("-");
00058     else {
00059       sb.append("Thread#");
00060       sb.append(getHoldingThread());
00061     }
00062     sb.append('\n');
00063 
00064     sb.append("Waiting: ");
00065     int[] wt = getWaitingThreads();
00066     if(wt.length == 0)
00067       sb.append("-");
00068     else
00069       for(int i = 0; i < wt.length; i++) {
00070     if(i != 0) sb.append(", ");
00071     sb.append("Thread#");
00072     sb.append(wt[i]);
00073       }
00074 
00075     return sb.toString();
00076   }  
00077 }

Generated at Thu Feb 7 06:50:52 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001