Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Cannot get the inserted element for Collection field
Cannot get the inserted element for Collection field [message #592570] 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:Cannot get the inserted element for Collection field
Next Topic:Getting Started
Goto Forum:
  


Current Time: Tue Nov 25 00:45:23 GMT 2014

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

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