| Cannot get the inserted element for Collection field [message #62798] | 
Wed, 15 March 2006 23:16  | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
 
I am trying to get the new contents for a field of Collection type, such  
as java.util.Vector, after an element is added or deleted each time. Here  
is what I did: 
 
pointcut fieldGet() : get(* *); 
 
after() returning(Object field): fieldGet() { 
          if (field instanceof Collection) 
          { 
		Collection collField = (Collection)field; 
		Iterator it = collField.iterator(); 
		while (it.hasNext()) 
		{ 
			System.out.println("after " + it.next()); 
		} 
          } 
			 
} 
 
Matched code: 
 
public class A 
{ 
	Vector v = new Vector(); 
	public void addB() 
	{ 
		v.add(new B()); 
		// v.add(new B()); 
	} 
} 
 
I had expected to get object B's reference after the first v.add(new B());  
but there is nothing returned from the collection. But if I add another  
v.add(new B());, I can only see one B's instance from the collection. How  
may I get the most up-to-date contents of the Vector v after it is  
accessed? Thanks very much for any help! 
 
SunnyDay
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.03330 seconds