当前位置: 首页>>代码示例>>Java>>正文


Java Connection.iterator方法代码示例

本文整理汇总了Java中com.restfb.Connection.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.iterator方法的具体用法?Java Connection.iterator怎么用?Java Connection.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.restfb.Connection的用法示例。


在下文中一共展示了Connection.iterator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAlbums

import com.restfb.Connection; //导入方法依赖的package包/类
/**
 * Gets a User's album
 *
 * @param id user id
 */
private void getAlbums(String id) {
    Connection<Album> albums = client.fetchConnection(id + "/albums", Album.class);
    Iterator<List<Album>> iterator = albums.iterator();        
    int no_pics = 0;
    while(iterator.hasNext()){
        List<Album> data = iterator.next();
        this.noAlbums+=data.size();
        for (Album al : data) {
        if (al.getCount() != null) {
            this.noPictures += al.getCount();
        }
    }
    }                              
    
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:21,代码来源:FcbkCrawler.java

示例2: getFriends

import com.restfb.Connection; //导入方法依赖的package包/类
/**
 * Get the friends of a user
 *
 * @param id The FaceBook user id for the getFriends request The user with
 * starting id is 'me'
 */
public void getFriends(String id) {
    try {
        //Create a temporary string arraylist
        ArrayList<String> temp;
        temp = new ArrayList<String>();
        //Initialize a facebook graph explorer request
        Connection<User> myFriends;
        myFriends = client.fetchConnection(id + "/friends", User.class);
        //Create an Iterator to traverse the list
        Iterator<List<User>> iterator = myFriends.iterator();
        while (iterator.hasNext()) {
            List<User> friends = iterator.next();
            //Loop the list            
            for (User u : friends) {
                //add the user id to the friends's list
                if (!friendsList.contains(u.getId())) {
                    friendsList.add(u.getId());
                    //add the new user id to the temporary list
                    temp.add(u.getId());
                }
            }

            //Recursive Call to get Friends of friends
            for (final String i : temp) {
                Thread t = new Thread(tGroup, new Runnable() {
                    public void run() {
                        getFriends(i);
                        Thread.currentThread().interrupt();
                    }
                });

                t.start();
            }
        }

    } catch (Exception e) {
        //Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, e);
    }
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:46,代码来源:FcbkCrawler.java

示例3: getNoGroups

import com.restfb.Connection; //导入方法依赖的package包/类
/**
 * Get No of groups the user belong to
 *
 * @param id user id
 * @return the Number of groups
 */
public int getNoGroups(String id) {
    Connection<Group> groups = client.fetchConnection(id + "/groups", Group.class);
    Iterator<List<Group>> iterator =groups.iterator();
    int size = 0;
    while(iterator.hasNext()){
        List<Group> data = iterator.next();
        size+=data.size();
    }
    return size;
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:17,代码来源:FcbkCrawler.java

示例4: getNoPosts

import com.restfb.Connection; //导入方法依赖的package包/类
/**
 * No of User Posts
 *
 * @param id user id
 * @return Returns the no of posts
 */
public int getNoPosts(String id) {
    Connection<Post> posts = client.fetchConnection(id + "/posts", Post.class);
    Iterator<List<Post>> iterator = posts.iterator();
    int size = 0;
    while(iterator.hasNext()){
        List<Post> data = iterator.next();
        size+=data.size();
    }
    return size;
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:17,代码来源:FcbkCrawler.java

示例5: getPosts

import com.restfb.Connection; //导入方法依赖的package包/类
/**
 * Gets User Posts
 *
 * @param id user id
 * @return Returns an array of user posts
 */
public ArrayList<Post> getPosts(String id) {        
    ArrayList<Post> data = new ArrayList<Post>();
    Connection<Post> posts = client.fetchConnection(id + "/posts", Post.class);
    Iterator<List<Post>> iterator = posts.iterator();
    while (iterator.hasNext()) {
        List<Post> data1 = iterator.next();
        for (Post p : data1)
            data.add(p);
    }

    return data;
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:19,代码来源:FcbkCrawler.java

示例6: albumInfo

import com.restfb.Connection; //导入方法依赖的package包/类
public static HashMap<SerializerKey, Object> albumInfo(Album album, FacebookClient fcb, File albumXml, long maxPics, boolean fakeAlbum, Connection<Photo> fakePhotos)
{
	HashMap<SerializerKey, Object> infos = new HashMap<>();
	if (album == null)
		return infos;
	infos.put(AlbumInfoKey.COUNT, album.getCount());
	infos.put(AlbumInfoKey.COVER_PHOTO_ID, album.getCoverPhoto());
	infos.put(AlbumInfoKey.CREATED, album.getCreatedTime());
	infos.put(AlbumInfoKey.DESCRIPTION, album.getDescription());
	infos.put(AlbumInfoKey.PHOTO_DIR, "./photos");
	infos.put(AlbumInfoKey.PHOTO_INFO, "./photoinfo.xml");
	infos.put(AlbumInfoKey.LAST_UPDATE, album.getUpdatedTime());
	infos.put(AlbumInfoKey.ORIGINAL_LINK, album.getLink());
	infos.put(AlbumInfoKey.PRIVACY, album.getPrivacy());
	infos.put(AlbumInfoKey.NAME, album.getName());
	infos.put(AlbumInfoKey.COMES_FROM, album.getFrom());
	infos.put(AlbumInfoKey.LOCATION, album.getLocation());
	infos.put(AlbumInfoKey.ID, album.getId());
	File dir = albumXml.getParentFile();
	Connection<Photo> photosConn = null;
	if (fakeAlbum && fakePhotos != null)
		photosConn = fakePhotos;
	else
		photosConn = fcb.fetchConnection(album.getId() + "/photos", Photo.class, MasterParameter.getParameterByClass(Photo.class));
	System.out.print("Fetching Photos from " + album.getName() + ". This may take a while...\t\t");
	long iterator = 0;
	Iterator<List<Photo>> it = photosConn.iterator();
	boolean breakLoop = false;
	if (!albumXml.getParentFile().exists())
		albumXml.getParentFile().mkdirs();
	File albumPhotos = FileUtils.resolveRelativePath(albumXml.getParentFile(), infos.get(AlbumInfoKey.PHOTO_DIR).toString());
	while (it.hasNext())
	{
		List<Photo> photos = it.next();
		for (Photo photo : photos)
		{
			if (iterator >= maxPics && maxPics >= 0)
			{
				breakLoop = true;
				break;
			}
			ConsoleDrawer.drawProgress(20, (int) ((iterator / (((maxPics < 0) ? album.getCount() : maxPics) * 1.0)) * 20), iterator == 0);
			if (!dir.exists())
				dir.mkdirs();
			File photoDir = new File("" + albumPhotos + "/" + photo.getId());
			if (!photoDir.exists())
				photoDir.mkdirs();
			File photoXml = FileUtils.resolveRelativePath(photoDir, infos.get(AlbumInfoKey.PHOTO_INFO).toString());
			photoInfo(photo, photoXml, fcb);
			iterator++;
		}
		if (breakLoop)
			break;
	}
	ConsoleDrawer.drawProgress(20, 20, false);
	infos.put(AlbumInfoKey.LOCAL_COUNT, iterator);
	System.out.println();
	writeInfos(infos, albumXml, "Represents an album");
	return infos;
}
 
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:61,代码来源:Serializer.java


注:本文中的com.restfb.Connection.iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。