KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > jmi > reflect > RefStructImpl


1 package org.objectweb.modfact.jmi.reflect;
2
3 import javax.jmi.reflect.*;
4 import java.util.*;
5
6 public class RefStructImpl implements javax.jmi.reflect.RefStruct, java.io.Serializable JavaDoc {
7     
8     List typeNames = null;
9     List fieldNames = null;
10     Object JavaDoc[] values = null;
11     
12     public RefStructImpl() {
13     }
14         
15     void setValues(List values) {
16         if(values==null) {
17           this.values = new Object JavaDoc[_refFieldNames().size()];
18         } else {
19           if(_refFieldNames().size()!=values.size()) {
20             throw new RuntimeException JavaDoc("Invalide arg size: "
21               +values.size() +" expect " +_refFieldNames().size()
22             );
23           }
24           this.values = values.toArray();
25         }
26     }
27     
28     public java.util.List JavaDoc refFieldNames() {
29         return new Vector(
30             _refFieldNames()
31         );
32     }
33     
34     List _refFieldNames() {
35         return fieldNames;
36     }
37     
38     public Object JavaDoc refGetValue(String JavaDoc str) {
39         return values[_refFieldNames().indexOf(str)];
40     }
41     
42     public java.util.List JavaDoc refTypeName() {
43         return typeNames;
44     }
45     
46     public int hashCode() {
47         return RefBaseObjectImpl.arrayToList(values).hashCode();
48     }
49     
50     public boolean equals(Object JavaDoc obj) {
51         if(!(obj instanceof RefStructImpl)) return false;
52         RefStructImpl other = (RefStructImpl)obj;
53         if(! this.refTypeName().equals(other.refTypeName()) ) return false;
54         for(int i=0; i<values.length; i++) {
55           
56         }
57         return true;
58     }
59     
60     public static List getAllValues(RefStruct s) {
61         List r = new Vector();
62         Iterator it = s.refFieldNames().iterator();
63         while(it.hasNext()) {
64           r.add(s.refGetValue((String JavaDoc)it.next()));
65         }
66         return r;
67     }
68     
69 }
70
Popular Tags