Google新特性--源代码搜索功能 程序员们有福了

     俺们这些个敲代码的民工们有福了,Google推出了源代码搜索功能,顾名思义就是搜索网上大量的开源代码,以后不用再费劲叭啦的奔波于各大开源网站、论坛(还不一定找到)了,google一下吧,而且还支持正则表达式

 

     下面的就是我用这个功能搜索到的google自已的分页代码

 

/**
 * Copyright 2009 Adam Ruggles.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.sapien.action;

import java.util.List;

import com.google.code.sapien.model.Category;
import com.google.code.sapien.model.Discussion;
import com.google.code.sapien.service.CategoryService;
import com.google.code.sapien.service.DiscussionService;
import com.google.code.sapien.util.PaginatedResult;
import com.google.inject.Inject;
import com.opensymphony.xwork2.ActionSupport;

/**
 * Index Action, controls the view of the main index page.
 * @author Adam
 * @version $Id$
 *
 * Created on Feb 18, 2009 at 10:08:16 PM
 */
public class IndexAction extends ActionSupport {
        /**
         * The default number of results per page.
         */
        public static final int RESULTS_PER_PAGE = 50;

        /**
         * Serial Version UID.
         */
        private static final long serialVersionUID = -2980491615589545156L;

        /**
         * A List of categories for displaying in the view.
         */
        private List<Category> categories;

        /**
         * The category service.
         */
        private final CategoryService categoryService;

        /**
         * The discussion service.
         */
        private final DiscussionService discussionService;

        /**
         * The page number.
         */
        private int page = 1;

        /**
         * A PaginatedResult of discussions.
         */
        private PaginatedResult<Discussion> paginatedResult;

        /**
         * Constructs a index action.
         * @param discussionService The discussion service.
         * @param categoryService The categoryService.
         */
        @Inject
        public IndexAction(final DiscussionService discussionService, final CategoryService categoryService) {
                super();
                this.discussionService = discussionService;
                this.categoryService = categoryService;
        }

        /**
         *
         * {@inheritDoc}
         * @see com.opensymphony.xwork2.ActionSupport#execute()
         */
        @Override
        public String execute() {
                paginatedResult = discussionService.getModifiedDesc(page, RESULTS_PER_PAGE);
                categories = categoryService.getAll();
                return SUCCESS;
        }

        /**
         * Returns categories.
         * @return the categories.
         */
        public List<Category> getCategories() {
                return categories;
        }

        /**
         * Returns page.
         * @return the page.
         */
        public int getPage() {
                return page;
        }

        /**
         * Returns paginatedResult.
         * @return the paginatedResult.
         */
        public PaginatedResult<Discussion> getPaginatedResult() {
                return paginatedResult;
        }

        /**
         * Sets page.
         * @param page the page to set.
         */
        public void setPage(final int page) {
                if (page <= 0) {
                        this.page = 1;
                } else {
                        this.page = page;
                }
        }
}

 

快去体验一下吧!

哈哈,欢呼吧同胞们....

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值