FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
PagedResult.php
1 <?php
2 /*
3 Copyright (C) 2014, Siemens AG
4 Author: Andreas Würl
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 version 2 as published by the Free Software Foundation.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 namespace Fossology\Lib\View;
21 
22 
23 abstract class PagedResult
24 {
25  const TARGET_CHARSET = "UTF-8";
26 
30  private $text;
31 
35  private $startOffset;
36 
40  private $currentOffset;
41 
42  public function __construct($startOffset)
43  {
44  $this->text = "";
45  $this->startOffset = $startOffset;
46  $this->currentOffset = $startOffset;
47  $this->empty = true;
48  }
49 
53  public function appendMetaText($text)
54  {
55  $this->text .= $text;
56  }
57 
61  public function appendContentText($text)
62  {
63  $this->empty = false;
64  $this->currentOffset += strlen($text);
65  $this->appendMetaText($this->renderContentText($text));
66  }
67 
71  public function getStartOffset()
72  {
73  return $this->startOffset;
74  }
75 
79  public function getCurrentOffset()
80  {
81  return $this->currentOffset;
82  }
83 
87  public function getText()
88  {
89  return $this->text;
90  }
91 
95  public function isEmpty()
96  {
97  return $this->empty;
98  }
99 
104  protected abstract function renderContentText($text);
105 }