Skip to main content



      Home
Home » Language IDEs » AspectJ » Cannot get the inserted element for Collection field
Cannot get the inserted element for Collection field [message #62798] Wed, 15 March 2006 23:16
Eclipse UserFriend
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: Tue May 06 15:56:56 EDT 2025

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

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

Back to the top