拷贝分页对象

@param clazz        目标类型
@param pageResponse 原对象
@param <T>          原数据类型
@param <R>          目标数据类型
@return 目标对象
183968
public static <T, R> PageResponse<R> processPage(Class<R> clazz, PageResponse<T> pageResponse) {
        return processPage(clazz, pageResponse, (r1, src1) -> {
        });
    }
909244
public static <T> GenericResponseBuilder<T> seeOther(URI location) {
    return GenericResponses.<T>status(Response.Status.SEE_OTHER).location(location);
  }
967697
public static <T extends AlipayResponse> T parseResponse(String json, Class<T> clazz)
                                                                                         throws AlipayApiException {
        ObjectJsonParser<T> parser = new ObjectJsonParser<T>(clazz);
        return parser.parse(json);
    }
1067523
public static List<Field> listFields(Class<?> clazz) {
    	assert clazz != null;
        Class<?> entityClass = clazz;
        List<Field> list = new ArrayList<Field>();
        while (!Object.class.equals(entityClass) && entityClass != null) {
            list.addAll(Arrays.asList(entityClass.getDeclaredFields()));
            entityClass = entityClass.getSuperclass();
        }
        return list;
    }
315614
public static  <E> List<E> pageQuery(Dialect dialect, Executor executor, MappedStatement ms, Object parameter,
                                 RowBounds rowBounds, ResultHandler resultHandler,
                                 BoundSql boundSql, CacheKey cacheKey) throws SQLException {
        //判断是否需要进行分页查询
        if (dialect.beforePage(ms, parameter, rowBounds)) {
            //生成分页的缓存 key
            CacheKey pageKey = cacheKey;
            //处理参数对象
            parameter = dialect.processParameterObject(ms, parameter, boundSql, pageKey);
            //调用方言获取分页 sql
            String pageSql = dialect.getPageSql(ms, boundSql, parameter, rowBounds, pageKey);
            BoundSql pageBoundSql = new BoundSql(ms.getConfiguration(), pageSql, boundSql.getParameterMappings(), parameter);

            Map<String, Object> additionalParameters = getAdditionalParameter(boundSql);
            //设置动态参数
            for (String key : additionalParameters.keySet()) {
                pageBoundSql.setAdditionalParameter(key, additionalParameters.get(key));
            }
            //执行分页查询
            return executor.query(ms, parameter, RowBounds.DEFAULT, resultHandler, pageKey, pageBoundSql);
        } else {
            //不执行分页的情况下，也不执行内存分页
            return executor.query(ms, parameter, RowBounds.DEFAULT, resultHandler, cacheKey, boundSql);
        }
    }
1022509
public List<ENTITY> page(List<Match> matches, List<Order> order, int curPage, int pageSize) {

        if (curPage < 0 || pageSize < 0) {
            return find(matches, order);
        }

        int offset = (curPage) * pageSize;
        int limit = pageSize;
        return find(matches, order, offset, limit);
    }
345340
def _wrap_paginated_response(cls, request, response, controls, data,
                                 head=None):
        
        paging_response = response['paging']
        if head is None:
            head = response['head_id']
        link = cls._build_url(
            request,
            head=head,
            start=paging_response['start'],
            limit=paging_response['limit'])

        paging = {}
        limit = controls.get('limit')
        start = controls.get("start")
        paging["limit"] = limit
        paging["start"] = start
        # If there are no resources, there should be nothing else in paging
        if paging_response.get("next") == "":
            return cls._wrap_response(
                request,
                data=data,
                metadata={
                    'head': head,
                    'link': link,
                    'paging': paging
                })

        next_id = paging_response['next']
        paging['next_position'] = next_id

        # Builds paging urls specific to this response
        def build_pg_url(start=None):
            return cls._build_url(request, head=head, limit=limit, start=start)

        paging['next'] = build_pg_url(paging_response['next'])

        return cls._wrap_response(
            request,
            data=data,
            metadata={
                'head': head,
                'link': link,
                'paging': paging
            })
440156
public <T> T getResponseBody(Class<T> clazz) {
        final ByteBuf byteBuf = httpInputMessage.getBody();
        if(byteBuf.readableBytes() == 0 || Void.class.isAssignableFrom(clazz)) return null;

        final MediaType mediaType = MediaType.parseMediaType(httpInputMessage.getHeaders().get(HttpHeaders.CONTENT_TYPE));
        for (HttpMessageConverter httpMessageConverter : httpMessageConverters) {
            if (httpMessageConverter.canRead(clazz, mediaType)) {
                return (T) httpMessageConverter.read(clazz, httpInputMessage);
            }
        }
        return null;
    }
989506
public static ScopedResponse unwrapResponse( ServletResponse response )
    {
        while ( response instanceof ServletResponseWrapper )
         {
             if ( response instanceof ScopedResponse )
             {
                 return ( ScopedResponse ) response;
             }
             else
             {
                 response = ( ( ServletResponseWrapper ) response ).getResponse();
             }
         }
        
         return null;
     }
951086
private function getPagedListResponse(
        $methodName,
        array $optionalArgs,
        $decodeType,
        Message $request,
        $interfaceName = null
    ) {
        $callStack = $this->createCallStack(
            $this->configureCallConstructionOptions($methodName, $optionalArgs)
        );
        $descriptor = new PageStreamingDescriptor(
            $this->descriptors[$methodName]['pageStreaming']
        );
        $callStack = new PagedMiddleware($callStack, $descriptor);

        $call = new Call(
            $this->buildMethod($interfaceName, $methodName),
            $decodeType,
            $request,
            [],
            Call::UNARY_CALL
        );

        $this->modifyUnaryCallable($callStack);
        return $callStack($call, $optionalArgs)->wait();
    }
1319635
public function getCmsResponse(
        Site $site,
        Page $page,
        $revisionId = null
    ) {
        $pageRenderer = $this->getPageRenderer();

        $response = new \Rcm\Http\Response();
        $layoutView = $this->layout();
        $viewModel = new ViewModel();

        return $pageRenderer->renderZf2ByName(
            $response,
            $layoutView,
            $viewModel,
            $site,
            $page->getName(),
            $page->getPageType(),
            $revisionId
        );
    }
760062
protected void getPage(final JSONObject params) {
		
		if (this.client == null)
			client = BandwidthClient.getInstance();
    	
        try {
	        final RestResponse response = client.get(resourceUri, params);
	        
	        final JSONArray array = Utils.response2JSONArray(response);
	        
	        for (final Object obj : array) {	
        		final E elem = clazz.getConstructor(BandwidthClient.class, JSONObject.class).newInstance(client, (JSONObject) obj);
        		add(elem);
	        }
	        
	        // if anything comes back, reset the index
	        if (array.size() > 0)
	        	this.index = 0;
	        
	        // set the next links
	        this.setNextLink(response.getNextLink());	        
	        this.setFirstLink(response.getFirstLink());
	        this.setPreviousLink(response.getPreviousLink());
        }
        catch(final Exception e) {
        	e.printStackTrace();
        }
	}
399895
public CmsContainerPageBean getPage(Object page, Object locale) {

        CmsResource pageResource = null;
        CmsContainerPageBean result = null;
        if (m_cms != null) {
            try {
                pageResource = CmsJspElFunctions.convertRawResource(m_cms, page);
                Locale l = CmsJspElFunctions.convertLocale(locale);
                result = getPage(pageResource);
                if (result != null) {
                    CmsADEConfigData adeConfig = OpenCms.getADEManager().lookupConfiguration(
                        m_cms,
                        pageResource.getRootPath());
                    for (CmsContainerBean container : result.getContainers().values()) {
                        for (CmsContainerElementBean element : container.getElements()) {
                            boolean isGroupContainer = element.isGroupContainer(m_cms);
                            boolean isInheritedContainer = element.isInheritedContainer(m_cms);
                            I_CmsFormatterBean formatterConfig = null;
                            if (!isGroupContainer && !isInheritedContainer) {
                                element.initResource(m_cms);
                                // ensure that the formatter configuration id is added to the element settings, so it will be persisted on save
                                formatterConfig = CmsJspTagContainer.getFormatterConfigurationForElement(
                                    m_cms,
                                    element,
                                    adeConfig,
                                    container.getName(),
                                    "",
                                    0);
                                if (formatterConfig != null) {
                                    element.initSettings(m_cms, formatterConfig, l, m_request, null);
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                LOG.warn(e.getLocalizedMessage(), e);
            }

        }
        return result;
    }
160021
protected Page newPage(final HttpServletRequest req, final HttpServletResponse resp,
      final Session session, final String template) {
    final Page page = new Page(req, resp, getApplication().getVelocityEngine(), template);
    page.add("version", jarVersion);
    page.add("azkaban_name", this.name);
    page.add("azkaban_label", this.label);
    page.add("azkaban_color", this.color);
    page.add("note_type", NoteServlet.type);
    page.add("note_message", NoteServlet.message);
    page.add("note_url", NoteServlet.url);
    page.add("timezone", TimeZone.getDefault().getID());
    page.add("currentTime", (new DateTime()).getMillis());
    page.add("size", getDisplayExecutionPageSize());
    page.add("System", System.class);
    page.add("TimeUtils", TimeUtils.class);
    page.add("WebUtils", WebUtils.class);

    if (session != null && session.getUser() != null) {
      page.add("user_id", session.getUser().getUserId());
    }

    final String errorMsg = getErrorMessageFromCookie(req);
    page.add("error_message", errorMsg == null || errorMsg.isEmpty() ? "null"
        : errorMsg);
    setErrorMessageInCookie(resp, null);

    final String warnMsg = getWarnMessageFromCookie(req);
    page.add("warn_message", warnMsg == null || warnMsg.isEmpty() ? "null"
        : warnMsg);
    setWarnMessageInCookie(resp, null);

    final String successMsg = getSuccessMessageFromCookie(req);
    page.add("success_message",
        successMsg == null || successMsg.isEmpty() ? "null" : successMsg);
    setSuccessMessageInCookie(resp, null);

    // @TODO, allow more than one type of viewer. For time sake, I only install
    // the first one
    if (this.viewerPlugins != null && !this.viewerPlugins.isEmpty()) {
      page.add("viewers", this.viewerPlugins);
    }

    if (this.triggerPlugins != null && !this.triggerPlugins.isEmpty()) {
      page.add("triggerPlugins", this.triggerPlugins);
    }

    return page;
  }
1192485
public void doBrowse(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException
    {
        if (!common.checkGet(request, response)) return;
        User user = common.getLoggedInUser(request);
        if (user == null) {
            common.pageSoftError(response, "Can't do /browse.  Nobody is logged in.");
            return;
        }

        DbxClientV2 dbxClient = requireDbxClient(request, response, user);
        if (dbxClient == null) return;

        String path = request.getParameter("path");
        if (path == null || path.length() == 0) {
            renderFolder(response, user, dbxClient, "");
        } else {
            String pathError = DbxPathV2.findError(path);
            if (pathError != null) {
                response.sendError(400, "Invalid path: " + jq(path) + ": " + pathError);
                return;
            }
            Metadata metadata;
            try {
                metadata = dbxClient.files()
                    .getMetadata(path);
            }
            catch (GetMetadataErrorException ex) {
                if (ex.errorValue.isPath()) {
                    LookupError le = ex.errorValue.getPathValue();
                    if (le.isNotFound()) {
                        response.sendError(400, "Path doesn't exist on Dropbox: " + jq(path));
                        return;
                    }
                }
                common.handleException(response, ex, "getMetadata(" + jq(path) + ")");
                return;
            }
            catch (DbxException ex) {
                common.handleDbxException(response, user, ex, "getMetadata(" + jq(path) + ")");
                return;
            }

            path = DbxPathV2.getParent(path) + "/" + metadata.getName();
            if (metadata instanceof FolderMetadata) {
                renderFolder(response, user, dbxClient, path);
            }
            else {
                renderFile(response, path, (FileMetadata) metadata);
            }
        }
    }
341775
public static List<Method> getAccessors(Class<?> clazz) {
    if (clazz == null) {
      throw new IllegalArgumentException("The 'clazz' parameter cannot be null.");
    }

    List<Method> methods = new ArrayList<>();
    for (Method method : clazz.getMethods()) {
      String methodName = method.getName();
      if (!"getClass".equals(methodName) && !"hashCode".equals(methodName) && method.getReturnType() != null
          && !Void.class.equals(method.getReturnType()) && method.getParameterTypes().length == 0
          && ((methodName.startsWith("get") && methodName.length() > 3)
              || (methodName.startsWith("is") && methodName.length() > 2)
              || (methodName.startsWith("has") && methodName.length() > 3))) {
        methods.add(method);
      }
    }

    // Order the methods alphabetically by name
    sort(methods, new Comparator<Method>() {
      /**
       * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
       */
      @Override
      public int compare(Method method1, Method method2) {
        return method1.getName().compareTo(method2.getName());
      }
    });

    return unmodifiableList(methods);
  }
905465
public static Method getMethod(Class clazz, String methodName, Class<?>... parameterTypes) {
        if (clazz == null) {
            return null;
        }
        try {
            return clazz.getDeclaredMethod(methodName, parameterTypes);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return null;
    }