本文整理汇总了Java中com.restfb.types.NamedFacebookType类的典型用法代码示例。如果您正苦于以下问题:Java NamedFacebookType类的具体用法?Java NamedFacebookType怎么用?Java NamedFacebookType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamedFacebookType类属于com.restfb.types包,在下文中一共展示了NamedFacebookType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getIdsOfPaginatedFriends
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
private List<String> getIdsOfPaginatedFriends(RenderRequest request, RenderResponse response, PortletSession session,
FacebookClientWrapper facebookClient) throws PortletException, IOException {
// Count total number of friends
Integer friendsCount = getFriendsCount(session, facebookClient);
// Obtain number of current page
Integer currentPage = getCurrentPageNumber(request, session);
Integer indexStart = (currentPage - 1) * ITEMS_PER_PAGE;
List<NamedFacebookType> friendsToDisplay = facebookClient.getPageOfFriends(indexStart, ITEMS_PER_PAGE);
getPaginatorUrls(friendsCount, response);
// Collect IDS of friends to display
List<String> ids = new ArrayList<String>();
for (NamedFacebookType current : friendsToDisplay) {
ids.add(current.getId());
}
return ids;
}
开发者ID:exo-samples,项目名称:docs-samples,代码行数:21,代码来源:FacebookFriendsPortlet.java
示例2: getIdsOfFilteredFriends
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
/**
* Filter string, which will be used for filtering of users by "contains" rule.
*
* <p>
* For example: You have 3 friends on Facebook with names: "John Woo", "Marc Boo", "Susie Cole" and filter will be "oo" Then
* output of this method will return "John Woo" and "Marc Boo"
* </p>
*
* @param filter Filter string, which will be used for filtering of users by "contains" rule. For example
* @return ids of filtered friends
*/
public List<String> getIdsOfFilteredFriends(String filter) throws PortletException, IOException {
// Not good to obtain all friends within each request, but we don't have better way atm (limitation of facebook search
// api...)
Connection<NamedFacebookType> connection = this.fetchConnection("me/friends", NamedFacebookType.class);
if (connection == null) {
return new ArrayList<String>();
}
List<NamedFacebookType> allFriends = connection.getData();
List<String> result = new ArrayList<String>();
for (NamedFacebookType current : allFriends) {
if (current.getName().contains(filter)) {
result.add(current.getId());
}
}
return result;
}
开发者ID:exo-samples,项目名称:docs-samples,代码行数:29,代码来源:FacebookClientWrapper.java
示例3: mapNamedType
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
protected Topic mapNamedType(NamedFacebookType type, TopicMap tm) throws TopicMapException{
Topic t;
// ToDo: resolve appropriate wrapper automatically
if(type instanceof Place){
Place place = (Place)type;
PlaceWrapper placeWrapper = new PlaceWrapper(place);
t = placeWrapper.mapToTopicMap(tm);
} else if (type instanceof Page){
Page page = (Page)type;
PageWrapper pageWrapper = new PageWrapper(page);
t = pageWrapper.mapToTopicMap(tm);
} else {
StubWrapper stub = new StubWrapper(type);
t = stub.mapToTopicMap(tm);
}
return t;
}
开发者ID:wandora-team,项目名称:wandora,代码行数:19,代码来源:AbstractFBWrapper.java
示例4: getPageOfFriends
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
/**
* get Page of friends according to given offset and limit
*
* @param offset
* @param limit
* @return friends starting from offset and number of returned friends will be limit
*/
public List<NamedFacebookType> getPageOfFriends(int offset, int limit) throws PortletException, IOException {
Connection<NamedFacebookType> con = this.fetchConnection("me/friends", NamedFacebookType.class,
Parameter.with("offset", offset), Parameter.with("limit", limit));
if (con != null) {
return con.getData();
} else {
return new ArrayList<NamedFacebookType>();
}
}
开发者ID:exo-samples,项目名称:docs-samples,代码行数:17,代码来源:FacebookClientWrapper.java
示例5: getStatusesOfPerson
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
/**
* return FacebookUserBean with filled status messages
*
* @param friendId
* @param myId This parameter is used only to recognize Facebook scope, which we need
* @param accessToken
* @return FacebookUserBean with filled status messages
*/
public FacebookUserBean getStatusesOfPerson(String friendId, String myId, AccessToken accessToken) throws PortletException,
IOException {
Connection<StatusMessage> statusMessageConnection = this.fetchConnection(friendId + "/statuses", StatusMessage.class,
Parameter.with("limit", 5));
if (statusMessageConnection == null) {
return null;
}
List<StatusMessage> statuses = statusMessageConnection.getData();
FacebookUserBean ffb = new FacebookUserBean();
ffb.setId(friendId);
ffb.setScope(false);
ffb.setStatuses(statuses);
if (statuses.size() == 0) {
// Different scope is needed for me and different for my friends
String neededScope = friendId.equals(myId) ? "user_status" : "friends_status";
if (accessToken.isScopeAvailable(neededScope)) {
ffb.setScope(true);
} else {
ffb.setNeededScope(neededScope);
}
} else {
NamedFacebookType currentFriendToDisplay = this.fetchObject(friendId, NamedFacebookType.class,
Parameter.with("fields", "id,name"));
if (currentFriendToDisplay != null) {
ffb.setName(currentFriendToDisplay.getName());
}
}
return ffb;
}
开发者ID:exo-samples,项目名称:docs-samples,代码行数:43,代码来源:FacebookClientWrapper.java
示例6: genLikes
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
public static String genLikes(List<NamedFacebookType> likes)
{
if (likes == null)
return "";
StringBuilder sb = new StringBuilder();
for (NamedFacebookType nft : likes)
{
sb.append(nft.getName() + ";");
}
if (sb.length() > 0)
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:14,代码来源:Serializer.java
示例7: associateNamedType
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
protected void associateNamedType(TopicMap tm, NamedFacebookType type, String name, Topic parent, Topic parentType) throws TopicMapException{
Topic topic = mapNamedType(type, tm);
if(topic == null) return;
Topic topicType = getOrCreateType(tm, name);
Association employerAssoc = tm.createAssociation(topicType);
employerAssoc.addPlayer(parent, parentType);
employerAssoc.addPlayer(topic, topicType);
}
开发者ID:wandora-team,项目名称:wandora,代码行数:12,代码来源:AbstractFBWrapper.java
示例8: printField
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
public static void printField(PrintStream out, List<NamedFacebookType> values, boolean last) {
if (values == null) {
out.print("N/A" + ((last) ? "" : ", "));
} else {
for (NamedFacebookType value : values) {
out.print(value.getName().replaceAll("\n", "").replaceAll("\r", "").replaceAll(" ", "") + " ");
}
out.print(((last) ? "" : ", "));
}
}
开发者ID:theofilis,项目名称:tutorial-facebook-java-sdk,代码行数:11,代码来源:App.java
示例9: getFriendsCount
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
/**
* @return number of all your friends on Facebook or -1 if error occured
*/
public int getFriendsCount() throws IOException, PortletException {
Connection<NamedFacebookType> myFriends = this.fetchConnection("me/friends", NamedFacebookType.class);
return myFriends != null ? myFriends.getData().size() : -1;
}
开发者ID:exo-samples,项目名称:docs-samples,代码行数:8,代码来源:FacebookClientWrapper.java
示例10: dataValidator
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
public static HashMap<String, String> dataValidator(HashMap<SerializerKey, Object> map)
{
HashMap<String, String> newMap = new HashMap<>();
if (map == null)
return newMap;
Iterator<SerializerKey> it = map.keySet().iterator();
while (it.hasNext())
{
SerializerKey key = it.next();
if (key != null && map.get(key) != null && key.getType() != null)
{
Object value = map.get(key);
String stringKey = key.toString();
String stringValue = null;
switch (key.getType())
{
case OTHER:
{
stringValue = packList(value);
break;
}
case DATE:
{
if (value instanceof Date)
stringValue = "" + ((Date) value).getTime();
break;
}
case LIST:
{
if (value instanceof List<?>)
stringValue = packList((List<?>) value);
break;
}
case NFT:
{
if (value instanceof NamedFacebookType)
stringValue = ((NamedFacebookType) value).getName();
break;
}
case CFT:
{
if (value instanceof CategorizedFacebookType)
stringValue = ((CategorizedFacebookType) value).getName();
break;
}
default:
{
stringValue = value.toString();
}
}
if (stringValue != null)
newMap.put(stringKey, stringValue);
}
}
return newMap;
}
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:57,代码来源:Serializer.java
示例11: accumulateUserActivity
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
private void accumulateUserActivity(HashMap<String, Integer> likedFriendsPosts,
HashMap<String, Integer> commentedFriendsPosts,
HashMap<String, Integer> sharedFriendsPosts,
HashMap<String, Integer> commonActivityUsers,
HashMap<String, Integer> postsPerUser,
ExtendedPost post) {
HashSet<String> activeUsers = new HashSet<String>();
boolean isActionedByUser = false;
if (!postsPerUser.containsKey(post.getFrom().getId())) {
postsPerUser.put(post.getFrom().getId(), 0);
}
postsPerUser.put(post.getFrom().getId(), postsPerUser.get(post.getFrom().getId()) + 1);
if (post.getLikes() != null) {
for (NamedFacebookType likedUser : post.getLikes().getData()) {
activeUsers.add(likedUser.getId());
if (likedUser.getId().equals(userId)) {
isActionedByUser = true;
if (!likedFriendsPosts.containsKey(post.getFrom().getId())) {
likedFriendsPosts.put(post.getFrom().getId(), 0);
}
likedFriendsPosts.put(post.getFrom().getId(), likedFriendsPosts.get(post.getFrom().getId()) + 1);
}
}
}
if (post.getComments() != null) {
for (Comment comment : post.getComments().getData()) {
activeUsers.add(comment.getFrom().getId());
if (comment.getFrom().getId().equals(userId) & !isActionedByUser) {
isActionedByUser = true;
if (!commentedFriendsPosts.containsKey(post.getFrom().getId())) {
commentedFriendsPosts.put(post.getFrom().getId(), 0);
}
commentedFriendsPosts.put(post.getFrom().getId(), commentedFriendsPosts.get(post.getFrom().getId()) + 1);
}
}
}
if (isActionedByUser) {
for (String id : activeUsers) {
if (!commonActivityUsers.containsKey(id)) {
commonActivityUsers.put(id, 0);
}
commonActivityUsers.put(id, commonActivityUsers.get(id) + 1);
}
}
}
开发者ID:milenchechev,项目名称:RecommendedStream,代码行数:46,代码来源:UserDataCollector.java
示例12: testNulls
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
/**
* Makes sure we handle "null" when inside of a list instead of throwing a mapping exception.
*/
public void testNulls() {
List<NamedFacebookType> types =
createJsonMapper().toJavaList(jsonFromClasspath("nulls-in-list"), NamedFacebookType.class);
assertTrue(types.size() == 3);
}
开发者ID:oleke,项目名称:Gender-Mining,代码行数:9,代码来源:JsonMapperToJavaTest.java
示例13: mapToTopicMap
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
@Override
public Topic mapToTopicMap(TopicMap tm) throws TopicMapException{
Topic langTopic = getLangTopic(tm);
Topic userTopic = super.mapToTopicMap(tm);
Topic userType = getOrCreateType(tm, getType());
userTopic.setSubjectLocator(new Locator(AbstractFBGraphExtractor.URL_ROOT + user.getId()));
// Simple strings to map as occurrence data
final String[][] occurrenceData = {
{"Name", user.getName()},
{"About", user.getAbout()},
{"Bio", user.getBio()},
{"Birthday", user.getBirthday()},
{"Email", user.getEmail()},
{"Gender", user.getGender()},
{"Link", user.getLink()},
{"Locale", user.getLocale()},
{"Political", user.getPolitical()},
{"RelationshipStatus", user.getRelationshipStatus()},
{"Religion", user.getReligion()},
{"Quotes", user.getQuotes()},
{"Website", user.getWebsite()},
{"Currency", user.getCurrency() != null ? user.getCurrency().getUserCurrency() : null}
};
for (String[] datum : occurrenceData) {
Topic type = getOrCreateType(tm, datum[0]);
userTopic.setData(type, langTopic, datum[1]);
}
NamedFacebookType userLocation = user.getLocation();
associateNamedType(tm, userLocation, "Location", userTopic, userType);
List<NamedFacebookType> athletes = user.getFavoriteAthletes();
for(NamedFacebookType athlete: athletes){
associateNamedType(tm, athlete, "Athlete", userTopic, userType);
}
List<NamedFacebookType> teams = user.getFavoriteTeams();
for(NamedFacebookType team: teams){
associateNamedType(tm, team, "Team", userTopic, userType);
}
NamedFacebookType hometown = user.getHometown();
associateNamedType(tm, hometown, "Hometown", userTopic, userType);
List<User.Work> works = user.getWork();
Topic workType = getOrCreateType(tm, "Work");
for(User.Work work: works){
Topic workTopic = mapUserWork(work, tm);
Association workAssoc = tm.createAssociation(workType);
workAssoc.addPlayer(userTopic, userType);
workAssoc.addPlayer(workTopic, workType);
}
addPicture(tm, userTopic);
return userTopic;
}
开发者ID:wandora-team,项目名称:wandora,代码行数:67,代码来源:UserWrapper.java
示例14: mapToTopicMap
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
@Override
public Topic mapToTopicMap(TopicMap tm) throws TopicMapException {
Topic langTopic = getLangTopic(tm);
Topic workTopic = super.mapToTopicMap(tm);
Topic workType = getOrCreateType(tm, "Work");
final String[][] occurrenceData = {
{"startDate", work.getStartDate() != null ? work.getStartDate().toString() : null},
{"endDate", work.getEndDate() != null ? work.getEndDate().toString() : null},
{"description", work.getDescription()}
};
for (String[] datum : occurrenceData) {
Topic type = getOrCreateType(tm, datum[0]);
workTopic.setData(type, langTopic, datum[1]);
}
NamedFacebookType location = work.getLocation();
associateNamedType(tm, location, "Location", workTopic, workType);
NamedFacebookType employer = work.getEmployer();
associateNamedType(tm, employer, "Employer", workTopic, workType);
NamedFacebookType position = work.getPosition();
associateNamedType(tm, position, "Position", workTopic, workType);
return workTopic;
}
开发者ID:wandora-team,项目名称:wandora,代码行数:34,代码来源:UserWorkWrapper.java
示例15: mapToTopicMap
import com.restfb.types.NamedFacebookType; //导入依赖的package包/类
@Override
Topic mapToTopicMap(TopicMap tm) throws TopicMapException {
FacebookType entity = getEnclosedEntity();
if(entity == null) return null;
String id = entity.getId();
String name;
if(entity instanceof NamedFacebookType){
name = ((NamedFacebookType)entity).getName();
} else {
name = id;
}
logger.log("Processing graph object: " + name);
Topic entityTopic = getOrCreateTopic(tm, getSIBase() + id, name + " (" + id + ")");
Topic entityType = getOrCreateType(tm, getType());
Topic facebookTopic = getFacebookTopic(tm);
makeSubclassOf(tm, entityType, facebookTopic);
entityTopic.addType(entityType);
Topic idType = getOrCreateType(tm, "id");
entityTopic.setData(idType, getLangTopic(tm), id);
return entityTopic;
}
开发者ID:wandora-team,项目名称:wandora,代码行数:32,代码来源:AbstractFBTypeWrapper.java
注:本文中的com.restfb.types.NamedFacebookType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论