一个问题jive

04-07-20 maer2003
下边这段代码,看过好几天了,太笨了就是搞不懂,请看看:

elements为构造的一个Long型数组参数,但Forum forum = factory.getForum(id);//注1 处参数id 为一个long 数,

此处并没有用循环如:

for(int i=0;i<elements.length;i++){

Forum forum = factory.getForum(elements.get(i));

}

为啥会自动取出所有的Forum对象呢?

public DatabaseObjectIterator(int type, long [] elements,

final Object extraObject)

{

this.elements = elements;

switch (type) {

case JiveGlobals.FORUM:

this.objectFactory = new DatabaseObjectFactory() {

ForumFactory factory = (ForumFactory)extraObject;

public Object loadObject(long id) {

try {

Forum forum = factory.getForum(id);//注1

return forum;

}

catch (ForumNotFoundException mnfe) { }

catch (UnauthorizedException ue) { }

return null;

}

};

break;

}

}

maer2003
2004-07-21 12:41
下边这段代码,看过好几天了,太笨了就是搞不懂,请看看:

elements为构造的一个Long型数组参数,但Forum forum = factory.getForum(id);//注1 处参数id 为一个long 数,

此处并没有用循环如:

for(int i=0;i<elements.length();i++)

Forum forum = factory.getForum(elements.get(i));

}

为啥会自动取出所有的Forum对象呢?

public DatabaseObjectIterator(int type, long [] elements,

final Object extraObject)

{

this.elements = elements;

switch (type) {

case JiveGlobals.FORUM:

this.objectFactory = new DatabaseObjectFactory() {

ForumFactory factory = (ForumFactory)extraObject;

public Object loadObject(long id) {

try {

Forum forum = factory.getForum(id);//注1

return forum;

}

catch (ForumNotFoundException mnfe) { }

catch (UnauthorizedException ue) { }

return null;

}

};

break;

}

}

maer2003
2004-07-21 13:31
哦,看懂了,DatabaseObjectIterator本身作为一个迭代器

song_z_j
2005-01-19 11:13
请问DatabaseObjectFactory怎么实现对

loadObject()的调用的

猜你喜欢