FOSSology  4.4.0
Open Source License Compliance by Open Source Software
PagedResult.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014 Siemens AG
4  Author: Andreas Würl
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 namespace Fossology\Lib\View;
9 
10 
11 abstract class PagedResult
12 {
13  const TARGET_CHARSET = "UTF-8";
14 
18  private $text;
19 
23  private $startOffset;
24 
28  private $currentOffset;
29 
30  public function __construct($startOffset)
31  {
32  $this->text = "";
33  $this->startOffset = $startOffset;
34  $this->currentOffset = $startOffset;
35  $this->empty = true;
36  }
37 
41  public function appendMetaText($text)
42  {
43  $this->text .= $text;
44  }
45 
49  public function appendContentText($text)
50  {
51  $this->empty = false;
52  $this->currentOffset += strlen($text);
53  $this->appendMetaText($this->renderContentText($text));
54  }
55 
59  public function getStartOffset()
60  {
61  return $this->startOffset;
62  }
63 
67  public function getCurrentOffset()
68  {
69  return $this->currentOffset;
70  }
71 
75  public function getText()
76  {
77  return $this->text;
78  }
79 
83  public function isEmpty()
84  {
85  return $this->empty;
86  }
87 
92  protected abstract function renderContentText($text);
93 }