Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » Cannot get the inserted element for Collection field
Cannot get the inserted element for Collection field [message #62798] Thu, 16 March 2006 04:16
Sunfire is currently offline SunfireFriend
Messages: 71
Registered: July 2009
Member
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
Previous Topic:How to get all argument values?
Next Topic:Cannot get the inserted element for Collection field
Goto Forum:
  


Current Time: Sat Nov 09 03:08:55 GMT 2024

Powered by FUDForum. Page generated in 0.03904 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top