@Override public <T> Page<T> searchPage(String sql, Class<T> clazz, List<Object> params, Page<T> page) throws Exception { if (StringUtils.isBlank(sql)) { List<T> list = new ArrayList<>(); page.setTotalCount(0); page.setResult(list); return page; } if (params == null) { params = new ArrayList<>(); } StringBuilder sb = new StringBuilder(sql); int count = getCount(sb.toString(), params); page.setTotalCount(count); if (!StringUtils.isBlank(page.getOrder())) { sb.append(" ORDER BY ").append(page.getOrder()); if (!StringUtils.isBlank(page.getSort())) { sb.append(" ").append(page.getSort()); } } sb.append(" LIMIT "); sb.append(String.valueOf(page.getFirstResult())); sb.append(","); sb.append(String.valueOf(page.getPageSize())); List<T> list = searchForList(sb.toString(), clazz, params); page.setResult(list); return page; }
@Test public void savePageWithSameBaseCommitAndConflictingChanges() throws IOException, GitAPIException { register(globalRepoManager.createProjectCentralRepository(PROJECT, USER)); ILockedRepository repo = globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null); register(repo); Page page = Page.fromText("title", "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$ pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, null, USER); String baseCommit = pageStore.getPageMetadata(PROJECT, BRANCH_1, PAGE).getCommit(); page = Page.fromText("title", "a\nbbb\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$ pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, baseCommit, USER); page = Page.fromText("title", "a\nxxx\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$ MergeConflict conflict = pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, baseCommit, USER); Page result = pageStore.getPage(PROJECT, BRANCH_1, PAGE, true); assertNotNull(conflict); assertEquals( "a\nbbb\nc\nd\ne\nf\ng\nh\ni\nj\n", ((PageTextData) result.getData()).getText()); // $NON-NLS-1$ assertEquals( "a\n<<<<<<< OURS\nbbb\n=======\nxxx\n>>>>>>> THEIRS\nc\nd\ne\nf\ng\nh\ni\nj\n", conflict.getText()); // $NON-NLS-1$ assertClean(repo.r()); }
public GroupByIdBlock getGroupIds(Page page) { int positionCount = page.getPositionCount(); int groupIdBlockSize = SINGLE_LONG.getFixedSize() * positionCount; BlockBuilder blockBuilder = new BlockBuilder( SINGLE_LONG, groupIdBlockSize, Slices.allocate(groupIdBlockSize).getOutput()); // open cursors for group blocks BlockCursor[] cursors = new BlockCursor[channels.length]; for (int i = 0; i < channels.length; i++) { cursors[i] = page.getBlock(channels[i]).cursor(); } // use cursors in hash strategy to provide value for "current" row hashStrategy.setCurrentRow(cursors); for (int position = 0; position < positionCount; position++) { for (BlockCursor cursor : cursors) { checkState(cursor.advanceNextPosition()); } int groupId = pagePositionToGroupId.get(CURRENT_ROW_ADDRESS); if (groupId < 0) { groupId = addNewGroup(cursors); } blockBuilder.append(groupId); } UncompressedBlock block = blockBuilder.build(); return new GroupByIdBlock(nextGroupId, block); }
/** @see org.eclipse.jface.wizard.IWizard#addPages() */ public void addPages() { super.addPages(); mainPage = new Page(); // $NON-NLS-1$ mainPage.setTitle("New Clojure " + kind(false)); mainPage.setDescription("Create new top-level Clojure " + kind(true)); addPage(mainPage); }
@Override protected RemoteDetectionResult detectRemoteRepository( final ScrapeContext context, final Page page) { // cheap checks first, to quickly eliminate target without doing any remote requests if (page.getHttpResponse().getStatusLine().getStatusCode() == 200) { final Elements elements = page.getDocument().getElementsByTag("a"); if (!elements.isEmpty()) { // get "template" parent link final Element templateParentLink = getParentDirectoryElement(page); // get the page parent link (note: usually it's 1st elem, but HTTPD for example has extra // links for // column // sorting for (Element element : elements) { // if text is same and abs URLs points to same place, we got it if (templateParentLink.text().equals(element.text()) && templateParentLink.absUrl("href").equals(element.absUrl("href"))) { return new RemoteDetectionResult( RemoteDetectionOutcome.RECOGNIZED_SHOULD_BE_SCRAPED, getTargetedServer(), "Remote is a generated index page of " + getTargetedServer()); } } } } // um, we were not totally positive, this might be some web server with index page similar to // Nexus one return new RemoteDetectionResult( RemoteDetectionOutcome.UNRECOGNIZED, getTargetedServer(), "Remote is not a generated index page of " + getTargetedServer()); }
public Bundle save() { Bundle bundle = new Bundle(); for (Page page : getPageList()) { bundle.putBundle(page.getKey(), page.getData()); } return bundle; }
public void popTopNPages( int n, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (mAnimating) { return; } if (n <= 0 || mPageStack.size() <= 0) { return; } Page oldPage = mPageStack.removeLast(); --n; // for mPageStack.removeLast() above while (--n >= 0) { Page page = mPageStack.removeLast(); page.onHide(); mContainerView.removeView(page.getView()); page.onDetached(); page.onHidden(); if (mEnableDebug) { Log.d(TAG, String.format(">>>> popPage, pagestack=%d, %s", mPageStack.size(), page)); } } popPageInternal(oldPage, animated, animationDirection); }
public void testIsBinary() throws Exception { Page indexPage = getPage("index.html"); Page jpgPage = getPage("picture.jpg"); assertFalse(indexPage.isBinary()); System.out.println(jpgPage.getMimeType()); assertTrue(jpgPage.isBinary()); }
/** * 自己做的分页 * * @param page 页脚对象 * @return 查询到得新闻集合 */ public List<News> findByPage(Page page, News news) { // String field="news_title"; Object keyword = ""; String condition = null; boolean isNull = true; try { for (Method m : getMethods) { keyword = m.invoke(news, new Object[] {}); if (keyword != null) { condition = "news_" + m.getName().substring(7) + " like '%" + keyword + "%'"; isNull = false; break; } } } catch (Exception e) { throw new RuntimeException("这是什么异常?", e); } if (isNull) { condition = "1=1"; } String sql = "select top " + page.getPageSize() + " * from tb_news where " + condition + " and news_id not in(select top " + (page.getCurrentPage() - 1) * page.getPageSize() + " news_id from tb_news where " + condition + ")"; return this.template.executeQuery(sql, News.class); }
@Override public Page createView(Context context, int position) { int dayAdjustment = position - startingPos; Page page = new Page(context); page.setDate(BADateUtil.addDays(date, dayAdjustment)); return page; }
/** * Remove the specified tuple from the buffer pool. Will acquire a write lock on the page the * tuple is removed from. May block if the lock cannot be acquired. * * <p>Marks any pages that were dirtied by the operation as dirty by calling their markDirty bit. * Does not need to update cached versions of any pages that have been dirtied, as it is not * possible that a new page was created during the deletion (note difference from addTuple). * * @param tid the transaction deleting the tuple. * @param t the tuple to delete */ public void deleteTuple(TransactionId tid, Tuple t) throws DbException, TransactionAbortedException { HeapFile heapFile = (HeapFile) Database.getCatalog().getDatabaseFile(t.getRecordId().getPageId().getTableId()); Page dirtiedPage = heapFile.deleteTuple(tid, t); dirtiedPage.markDirty(true, tid); }
@Override public void addInput(Page page) { checkNotNull(page, "page is null"); checkState(!finished, "Already finished"); inMemoryExchange.addPage(page); operatorContext.recordGeneratedOutput(page.getDataSize(), page.getPositionCount()); }
// 管理 查询 public String manageKbDiseaseFull() { log.info("exec action method:manageKbDiseaseFull"); // 分页查询 if (pageNo <= 0) { pageNo = 1; } page.setTotalCount(kbDiseaseService.countKbDiseaseRow()); if (page.getTotalpage() < pageNo) { pageNo = page.getTotalpage(); } page.setPageNo(pageNo); if (page.getTotalCount() != 0) { kbDiseaseFullList = kbDiseaseService.selectKbDiseaseFullByConditionAndPage("", page); } kbkeshiList = kbkeshiService.selectKbkeshiByCondition(""); System.out.println("kbkeshiList:" + kbkeshiList.size()); if (kbkeshiList == null) { kbkeshiList = new ArrayList<Kbkeshi>(); } if (kbDiseaseFullList == null) { kbDiseaseFullList = new ArrayList<KbDiseaseFull>(); } // for(int i = 0; i < computerhomeworkFullList.size(); i++){ // System.out.println("id="); // } if (callType != null && callType.equals("ajaxType")) { return "success2"; } else { return "success1"; } }
/** Write a document out */ public void writeDocument(DocumentImpl doc) throws ShutdownException { int start = doc.getIndex(); int offset = BufferManager.getOffset(start); Page page = BufferManager.getPage(start); int size = page.documentSize(offset); while (size > 0) { // Fill our buffer with events short nRead = (short) Math.min(size, MAX_EVENTS - current_offset); page.copyEvents(offset, nRead, current_offset, types, strings); size -= nRead; offset += nRead; int pageSize = BufferManager.getPageSize(); if (size > 0 && offset >= pageSize) do { offset -= pageSize; page = page.getNext(); } while (offset >= pageSize); current_offset += nRead; assert current_offset == MAX_EVENTS || size == 0; // Write out as many full pages as possible writeOutPages(false); } }
/** * "pop" operation ends if destPage is found, if destPage is not found, the method call is a no-op * * @param destPage page as the destination for this pop operation * @param animated true to animate the transition */ public void popToPage( Page destPage, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (mAnimating) { return; } if (destPage == null) { throw new IllegalArgumentException("cannot call popToPage() with null destPage."); } if (mPageStack.size() <= 0 || mPageStack.lastIndexOf(destPage) == -1 || mPageStack.peekLast() == destPage) { return; } Page oldPage = mPageStack.removeLast(); if (mEnableDebug) { Log.d(TAG, String.format(">>>> popPage, pagestack=%d, %s", mPageStack.size(), oldPage)); } while (mPageStack.size() > 1) { if (mPageStack.peekLast() == destPage) { break; } Page page = mPageStack.removeLast(); page.onHide(); mContainerView.removeView(page.getView()); page.onDetached(); page.onHidden(); } popPageInternal(oldPage, animated, animationDirection); }
private void displayNonLeadSection(int index) { activity.updateProgressBar( true, false, PageActivity.PROGRESS_BAR_MAX_VALUE / model.getPage().getSections().size() * index); try { final Page page = model.getPage(); JSONObject wrapper = new JSONObject(); wrapper.put("sequence", pageSequenceNum); if (index < page.getSections().size()) { JSONObject section = page.getSections().get(index).toJSON(); wrapper.put("section", section); wrapper.put("index", index); if (sectionTargetFromIntent > 0 && sectionTargetFromIntent < page.getSections().size()) { // if we have a section to scroll to (from our Intent): wrapper.put("fragment", page.getSections().get(sectionTargetFromIntent).getAnchor()); } else if (sectionTargetFromTitle != null) { // if we have a section to scroll to (from our PageTitle): wrapper.put("fragment", sectionTargetFromTitle); } Log.d(TAG, "Added request for section " + section.getString("line")); } else { wrapper.put("noMore", true); } // give it our expected scroll position, in case we need the page to be pre-scrolled upon // loading. wrapper.put( "scrollY", (int) (stagedScrollY / activity.getResources().getDisplayMetrics().density)); bridge.sendMessage("displaySection", wrapper); } catch (JSONException e) { ACRA.getErrorReporter().handleException(e); } }
public void onDestroy() { if (mCurPage != null) { mCurPage.onHide(); // we do not pop the top page, we simply call onHidden on it mCurPage.onHidden(); } }
/** * Renderes a list or table cell value if the value contains an OWLAnnotation. * * @param page The page that the value will be rendered into. * @param value The value that may or may not contain an OWLAnnotation. The annotation will be * extracted from this value. * @param foreground The default foreground color. * @param background The default background color. * @param isSelected Whether or not the cell containing the value is selected. */ private void renderCellValue( Page page, Object value, Color foreground, Color background, boolean isSelected) { OWLAnnotation annotation = extractOWLAnnotationFromCellValue(value); if (annotation != null) { renderAnnotationProperty(page, annotation, foreground, background, isSelected); renderAnnotationValue(page, annotation, foreground, background, isSelected); if (inlineAnnotationRendering == RENDER_COMPOUND_ANNOTATIONS_INLINE && value instanceof HasAnnotations) { Page subAnnotationPage = new Page(); for (OWLAnnotation anno : ((HasAnnotations) value).getAnnotations()) { renderCellValue(subAnnotationPage, anno, foreground, background, isSelected); } subAnnotationPage.setMarginLeft(40); subAnnotationPage.setOpacity(0.6); page.add(subAnnotationPage); } } switch (annotationRenderingStyle) { case COMFORTABLE: page.setMargin(2); page.setMarginBottom(6); break; case COSY: page.setMargin(1); page.setMarginBottom(3); break; case COMPACT: page.setMargin(0); page.setMarginBottom(1); } }
private void assertCheckins(List<Checkin> checkins) { assertEquals(2, checkins.size()); assertSingleCheckin(checkins.get(0)); Checkin checkin2 = checkins.get(1); assertEquals("10150140239512040", checkin2.getId()); assertEquals("533477039", checkin2.getFrom().getId()); assertEquals("Raymie Walls", checkin2.getFrom().getName()); assertEquals(1, checkin2.getTags().size()); assertEquals("738140579", checkin2.getTags().get(0).getId()); assertEquals("Craig Walls", checkin2.getTags().get(0).getName()); assertEquals("With my favorite people! ;-)", checkin2.getMessage()); Page place2 = checkin2.getPlace(); assertEquals("150366431753543", place2.getId()); assertEquals("Somewhere", place2.getName()); assertEquals(35.0231428, place2.getLocation().getLatitude(), 0.0001); assertEquals(-98.740305416667, place2.getLocation().getLongitude(), 0.0001); assertEquals("6628568379", checkin2.getApplication().getId()); assertEquals("Facebook for iPhone", checkin2.getApplication().getName()); assertEquals(toDate("2011-02-11T20:59:41+0000"), checkin2.getCreatedTime()); assertEquals(2, checkin2.getLikes().size()); assertEquals("1524405653", checkin2.getLikes().get(0).getId()); assertEquals("Samuel Hugh Parsons", checkin2.getLikes().get(0).getName()); assertEquals("1580082219", checkin2.getLikes().get(1).getId()); assertEquals("Kris Len Nicholson", checkin2.getLikes().get(1).getName()); assertEquals(1, checkin2.getComments().size()); assertEquals("10150140239512040_15204657", checkin2.getComments().get(0).getId()); assertEquals("100000094813002", checkin2.getComments().get(0).getFrom().getId()); assertEquals("Otis Nelson", checkin2.getComments().get(0).getFrom().getName()); assertEquals("You are not with me!!!!", checkin2.getComments().get(0).getMessage()); assertEquals( toDate("2011-02-11T21:31:31+0000"), checkin2.getComments().get(0).getCreatedTime()); }
public void removePage(int id, Session session) { Page page = findPage(id); if (page != null && page.getModule() != null && page.getModule().getPageList() != null) { page.getModule().getPageList().remove(page); session.delete(page); } }
private void openNewPage() throws Exception { lock.writeLock().lock(); try { numberOfPages++; int tmpCurrentPageId = currentPageId + 1; if (currentPage != null) { currentPage.close(); } currentPage = createPage(tmpCurrentPageId); LivePageCache pageCache = new LivePageCacheImpl(currentPage); currentPage.setLiveCache(pageCache); cursorProvider.addPageCache(pageCache); currentPageSize.set(0); currentPage.open(); currentPageId = tmpCurrentPageId; if (currentPageId < firstPageId) { firstPageId = currentPageId; } } finally { lock.writeLock().unlock(); } }
/** * Get the index of the given key in the map. * * <p>This is a O(log(size)) operation. * * <p>If the key was found, the returned value is the index in the key array. If not found, the * returned value is negative, where -1 means the provided key is smaller than any keys. See also * Arrays.binarySearch. * * @param key the key * @return the index */ public long getKeyIndex(K key) { checkOpen(); if (size() == 0) { return -1; } Page p = root; long offset = 0; while (true) { int x = p.binarySearch(key); if (p.isLeaf()) { if (x < 0) { return -offset + x; } return offset + x; } if (x < 0) { x = -x - 1; } else { x++; } for (int i = 0; i < x; i++) { offset += p.getCounts(i); } p = p.getChildPage(x); } }
private void goToPageImpl(final int toPage) { int scrollX = getScrollX(); Page page = pages.get(toPage); int scrollY = page.getTop(); Log.d( VIEW_LOG_TAG, "goToPageImpl:" + xToScroll + " scroll:" + scrollX + " yToScroll:" + yToScroll + " scrollY:" + scrollY + " page:" + page); if (xToScroll != 0) { scrollX = xToScroll; xToScroll = 0; } if (yToScroll != 0) { if (page.getBottom() > yToScroll) { scrollY = yToScroll; } yToScroll = 0; } scrollTo(scrollX, scrollY); }
// @Override public void render(Page page, Writer out) throws IOException { final Desktop desktop = _exec.getDesktop(); out.write("<script type=\"text/javascript\">zkpb('"); out.write(page.getUuid()); out.write("','"); out.write(desktop.getId()); out.write("','"); out.write(getContextURI()); out.write("','"); out.write(desktop.getUpdateURI(null)); out.write("','"); out.write(desktop.getRequestPath()); out.write('\''); String style = page.getStyle(); if (style != null && style.length() > 0) { out.write(",{style:'"); out.write(style); out.write("'}"); } out.write(");zkpe();</script>\n"); for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) { // HtmlPageRenders.outStandalone(_exec, root, out); } }
@Override public Page getPage(int pageNum, String lastMod) throws ContentGetException, ContentParseException { String[] wgetReply = this.wgetText(this.linkPage(pageNum), lastMod); String pageText = wgetReply[0]; String newLastMod = wgetReply[1]; Page p = new Page(pageNum); Topic t = null; Matcher mat = postGetPattern.matcher(pageText); while (mat.find()) { String text = mat.group(1); String type = mat.group(2); if (type.equals("opContainer")) { t = this.parseThread(text); p.addThread(t); } else { if (t != null) t.addPost(this.parsePost(text, t.getNum())); } } p.setLastMod(newLastMod); return p; }
public void delete(Hashtable<String, String> htblColNameValue, String strOperator) throws ClassNotFoundException, IOException, DBEngineException { ArrayList<Location> locs = search(htblColNameValue, strOperator); if (strOperator.equalsIgnoreCase("OR")) { for (int i = 0; i < locs.size(); i++) { Location loc = locs.get(i); Page p = (Page) DBApp.readObj("src/classes/Datei/" + tableName + loc.getPageNumber() + ".class"); p.deleteRow(loc.getRowNumber()); } } else if (strOperator.equalsIgnoreCase("AND")) { if (!(locs.size() == 0)) { Location l1 = locs.get(0); boolean areSame = true; for (int i = 1; i < locs.size(); i++) if (l1.compareTo(locs.get(i)) != 0) { areSame = false; break; } if (areSame) { Page p = (Page) DBApp.readObj("src/classes/Datei/" + tableName + l1.getPageNumber() + ".class"); p.deleteRow(l1.getRowNumber()); } } } else throw new DBEngineException(); }
protected void addRequest(Page page) { if (CollectionUtils.isNotEmpty(page.getTargetRequests())) { for (Request request : page.getTargetRequests()) { scheduler.push(request, this); } } }
private boolean openSeekable() { final Info initialInfo = new Info(); final Comment initialComment = new Comment(); this.m_chunkSize = Math.min(8500, (int) length(this.m_vorbisStream)); final Page page = new Page(); final int[] testSerialno = {0}; final int ret = this.fetchHeaders(initialInfo, initialComment, testSerialno, null); final int serialno = testSerialno[0]; final int dataOffset = (int) this.m_offset; this.m_oggStreamState.clear(); if (ret < 0) { return false; } seek(this.m_vorbisStream, 0L, 1); this.m_offset = tell(this.m_vorbisStream); final long end = this.getPreviousPage(page); if (page.serialno() != serialno) { if (this.bisectForwardSerialno(0L, 0L, end + 1L, serialno, 0) < 0) { return false; } } else if (this.bisectForwardSerialno(0L, end, end + 1L, serialno, 0) < 0) { return false; } this.prefetchAllHeaders(initialInfo, initialComment, dataOffset); this.rawSeek(this.m_dataOffsets[0]); return true; }
/** * Update cache page * * @param p */ public void addPage(Page p) { Page existP = page.get(p.getNo()); if (existP != null) { existP.update(p); } else { page.put(p.getNo(), p); } }
/** * Set <code>Page</code> parent. Called from <code>Page</code> when added to <code>Page</code> * object. * * @param page Page */ public void setPage(Page page) { if (this.page != null) removePropertyChangeListener(this.page); this.page = page; addPropertyChangeListener(this.page); page.addComponentListener(this); page.addPropertyChangeListener(this); pageSize = page.getSize(); }