⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doubanservice.java

📁 android开发入门与实践源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		query.setMaxResults(maxResult);		return query(query, SubjectFeed.class);	}	/**	 * @deprecated 受限制的api,如果需要使用请联系douban开发团队	 * 得到音乐的相关条目信息	 * 	 * @param musicId 	 *            音乐id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public SubjectFeed getMusicRelated(String musicId, int startIndex,			int maxResult) throws IOException, ServiceException {		SubjectQuery query = new SubjectQuery(new URL(				Namespaces.musicSubjectURL + "/" + musicId + "/related"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		return query(query, SubjectFeed.class);	}	/**	 * 得到评论信息	 * 	 * @param reviewId	 *            评论id	 * 	 */	public ReviewEntry getReview(String reviewId) throws IOException,			ServiceException {		String url = Namespaces.reviewURL + "/" + reviewId;		return getEntry(url, ReviewEntry.class);	}	/**	 * 获得用户的评论信息	 * 	 * @param userId	 *            要查询的用户id	 */	public ReviewFeed getUserReviews(String userId) throws IOException,			ServiceException {		String url = Namespaces.userURL + "/" + userId + "/reviews";		DoubanQuery query = new DoubanQuery(new URL(url));		return getFeed(query, ReviewFeed.class);	}	/**	 * 获得图书的评论信息	 * 	 * @param bookId	 *            要查询的图书id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public ReviewFeed getBookReviews(String bookId, int startIndex,			int maxResult, String orderby) throws IOException, ServiceException {		ReviewQuery query = new ReviewQuery(new URL(Namespaces.bookSubjectURL				+ "/" + bookId + "/reviews"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		query.setOrderby(orderby);		return query(query, ReviewFeed.class);	}	/**	 * 获得电影的评论信息	 * 	 * @param movieId	 *            要查询的电影id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public ReviewFeed getMovieReviews(String movieId, int startIndex,			int maxResult, String orderby) throws IOException, ServiceException {		ReviewQuery query = new ReviewQuery(new URL(Namespaces.movieSubjectURL				+ "/" + movieId + "/reviews"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		query.setOrderby(orderby);		return query(query, ReviewFeed.class);	}	/**	 * 获得音乐的评论信息	 * 	 * @param musicId	 *            要查询的音乐id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public ReviewFeed getMusicReviews(String musicId, int startIndex,			int maxResult, String orderby) throws IOException, ServiceException {		ReviewQuery query = new ReviewQuery(new URL(Namespaces.musicSubjectURL				+ "/" + musicId + "/reviews"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		query.setOrderby(orderby);		return query(query, ReviewFeed.class);	}	/**	 * 获得用户的收藏信息	 * 	 * @param userId	 *            用户id	 * @param cat	 * 				类别	 * @param tag	 *            标记的tag	 * @param status	 * 				收藏的状态	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public CollectionFeed getUserCollections(String userId, String cat,			String tag, String status, int startIndex, int maxResult)			throws IOException, ServiceException {		CollectionQuery query = new CollectionQuery(new URL(Namespaces.userURL				+ "/" + userId + "/collection"));		query.setCat(cat);		query.setTag(tag);		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		return query(query, CollectionFeed.class);	}	/**	 * 获得特定的收藏信息	 * 	 * @param cid	 *            收藏id	 */	public CollectionEntry getCollection(String cid)			throws IOException, ServiceException {		String url = Namespaces.collectionURL + "/" + cid;		return getEntry(url, CollectionEntry.class);	}	/**	 * 获取图书的标签信息	 * 	 * @param bookId	 *            图书Id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public TagFeed getBookTags(String bookId, int startIndex, int maxResult)			throws IOException, ServiceException {		TagQuery query = new TagQuery(new URL(Namespaces.bookSubjectURL + "/"				+ bookId + "/tags"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		return query(query, TagFeed.class);	}	/**	 * 获取电影的标签信息	 * 	 * @param movieId	 *            电影Id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public TagFeed getMovieTags(String movieId, int startIndex, int maxResult)			throws IOException, ServiceException {		TagQuery query = new TagQuery(new URL(Namespaces.movieSubjectURL + "/"				+ movieId + "/tags"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		return query(query, TagFeed.class);	}		/**	 * 获取音乐的标签信息	 * 	 * @param musicId 	 *            音乐Id	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public TagFeed getMusicTags(String musicId, int startIndex, int maxResult)			throws IOException, ServiceException {		TagQuery query = new TagQuery(new URL(Namespaces.musicSubjectURL + "/"				+ musicId + "/tags"));		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		return query(query, TagFeed.class);	}	/**	 * 获取用户的标签信息	 * 	 * @param userId	 *           用户Id	 * @param cat	 *            类别(movie|music|book )	 * @param startIndex	 *            开始索引	 * @param maxResult	 *            最大返回结果数目	 */	public TagFeed getUserTags(String userId, String cat, int startIndex,			int maxResult) throws IOException, ServiceException {		TagQuery query = new TagQuery(new URL(Namespaces.userURL + "/" + userId				+ "/tags"));		query.setCat(cat);		query.setStartIndex(startIndex);		query.setMaxResults(maxResult);		return query(query, TagFeed.class);	}	/**	 * 为一个条目创建评论	 * 	 * @param subjectEntry	 *            要创建评论的条目	 * @param title	 *            评论的标题	 * @param content	 *            内容(至少50字)	 * @param rating	 *			   对条目的打分(1-5)	 */	public ReviewEntry createReview(SubjectEntry subjectEntry,			TextConstruct title, TextConstruct content, Rating rating)			throws IOException, ServiceException {		String url = Namespaces.reviewCreateURL;		ReviewEntry re = new ReviewEntry();		Subject subject = new Subject();		subject.setId(subjectEntry.getId());		re.setSubject(subject);		if (title != null) {			re.setTitle(title);		}		if (content != null) {			re.setContent(content);		}		if (rating != null) {			re.setRating(rating);		}		return insert(new URL(url), re);	}	/**	 * 更新一个评论	 * 	 * @param reviewEntry	 *            待更新的评论	 * @param title	 *            标题	 * @param content	 *            评论内容(至少50字)	 * @param rating	 *            评分(1-5)	 */	public ReviewEntry updateReview(ReviewEntry reviewEntry,			TextConstruct title, TextConstruct content, Rating rating)			throws IOException, ServiceException {		ReviewEntry re = new ReviewEntry(reviewEntry);		if (title != null) {			re.setTitle(title);		}		if (content != null) {			re.setContent(content);		}		if (rating != null) {			re.setRating(rating);		}		return update(new URL(reviewEntry.getId()), re);	}	/**	 * 删除一条评论	 * 	 * @param reviewEntry	 *            待删除的评论	 */	public void deleteReview(ReviewEntry reviewEntry) throws IOException,			ServiceException {		delete(new URL(reviewEntry.getId()));	}	/**	 * 创建一个条目的收藏	 * 	 * @param status	 *            待收藏条目的状态(book:wish|reading|read	 *            movie:wish|watched tv:wish|watching|watched 	 *            music:wish|listening|listened)	 * @param se	 *            被搜藏的条目	 * @param tags	 *            收藏的标签	 * @param rating	 *            对条目的打分(1-5)	 */	public CollectionEntry createCollection(Status status, SubjectEntry se,			List<Tag> tags, Rating rating) throws MalformedURLException,			IOException, ServiceException {		String url = Namespaces.collectionCreateURL;		CollectionEntry ceNew = new CollectionEntry();		Subject subject = new Subject();		subject.setId(se.getId());		ceNew.setSubjectEntry(subject);		if (status != null) {			ceNew.setStatus(status);		}		if (tags != null) {			ceNew.setTags(tags);		}		if (rating != null) {			ceNew.setRating(rating);		}		return insert(new URL(url), ceNew);	}	/**	 * 更新收藏	 * 	 * @param ce	 *            要更新的收藏	 * @param status	 *            待收藏条目的状态(book:wish|reading|read	 *            movie:wish|watched tv:wish|watching|watched 	 *            music:wish|listening|listened)	 * @param tags	 *            收藏的标签	 * @param rating	 *            对条目的打分(1-5)	 */	public CollectionEntry updateCollection(CollectionEntry ce, Status status,			List<Tag> tags, Rating rating) throws MalformedURLException,			IOException, ServiceException {		CollectionEntry ceNew = new CollectionEntry();		ceNew.setId(ce.getId());		Subject subject = new Subject();		subject.setId(ce.getSubjectEntry().getId());		ceNew.setSubjectEntry(subject);		if (status != null) {			ceNew.setStatus(status);		} else {			ceNew.setStatus(ce.getStatus());		}		if (tags != null) {			ceNew.setTags(tags);		} else {			ceNew.setTags(ce.getTags());		}		if (rating != null) {			ceNew.setRating(rating);		} else {			ceNew.setRating(ce.getRating());		}		return update(new URL(ce.getId()), ceNew);	}	/**	 * 删除一条收藏	 * 	 * @param ce	 *           待删除的收藏	 */	public void deleteCollection(CollectionEntry ce)			throws MalformedURLException, IOException, ServiceException {		delete(new URL(ce.getId()));	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -