FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
Highlight.php
1 <?php
2 /*
3 Copyright (C) 2014, 2018 Siemens AG
4 Authors: Andreas Würl, Daniele Fognini
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\Data;
21 
23 
24 class Highlight
25 {
26  const MATCH = "M";
27  const CHANGED = "MC";
28  const ADDED = "MA";
29  const DELETED = "MD";
30  const SIGNATURE = "S";
31  const KEYWORD = "K";
32  const BULK = "B";
33 
34  const COPYRIGHT = "C";
35  const URL = "U";
36  const EMAIL = "E";
37  const AUTHOR = "A";
38  const IP = "I";
39  const ECC = "X";
40  const KEYWORDOTHERS = "KW";
41  const UNDEFINED = "any";
42 
46  private $start;
50  private $end;
54  private $type;
58  private $licenseId;
62  private $refStart;
66  private $refEnd;
70  private $infoText;
74  private $htmlElement;
75 
85  function __construct($start, $end, $type, $refStart=-1, $refEnd=-1, $infoText = "", $htmlElement = null)
86  {
87  $this->start = $start;
88  $this->end = $end;
89  $this->type = $type;
90  $this->refStart = $refStart;
91  $this->refEnd = $refEnd;
92  $this->infoText = $infoText;
93  $this->htmlElement = $htmlElement;
94 
95  $this->licenseId = null;
96  }
97 
101  public function getStart()
102  {
103  return $this->start;
104  }
105 
109  public function getEnd()
110  {
111  return $this->end;
112  }
113 
117  public function getType()
118  {
119  return $this->type;
120  }
121 
126  public function setLicenseId($licenseId)
127  {
128  $this->licenseId = $licenseId;
129  }
130 
134  public function getLicenseId()
135  {
136  return $this->licenseId;
137  }
138 
142  public function hasLicenseId()
143  {
144  return $this->licenseId != null;
145  }
146 
150  public function isPersistent()
151  {
152  return $this->licenseId == null;
153  }
154 
155 
159  public function getRefStart()
160  {
161  return $this->refStart;
162  }
163 
164  private function hasRef()
165  {
166  return $this->getRefStart() >= 0;
167  }
168 
172  public function getRefEnd()
173  {
174  return $this->refEnd;
175  }
176 
180  public function getRefLength()
181  {
182  return max(0, $this->refEnd - $this->refStart);
183  }
184 
188  public function setInfoText($infoText)
189  {
190  $this->infoText = $infoText;
191  }
192 
196  public function getInfoText()
197  {
198  return $this->infoText;
199  }
200 
204  public function getHtmlElement()
205  {
206  return $this->htmlElement;
207  }
208 
209 
210  public function __toString()
211  {
212  return "Highlight("
213  . $this->start . "-" . $this->end
214  . ", type=" . $this->type
215  . ", id=" . $this->licenseId .
216  ($this->hasRef() ? ":". $this->refStart . "-" . $this->refEnd : "")
217  .")";
218  }
219 }
__construct($start, $end, $type, $refStart=-1, $refEnd=-1, $infoText="", $htmlElement=null)
Definition: Highlight.php:85
start($application)
start the application Assumes application is restartable via /etc/init.d/<script>. The application passed in should match the script name in /etc/init.d
Definition: pkgConfig.php:1225
FUNCTION int max(int permGroup, int permPublic)
Get the maximum group privilege.
Definition: libfossagent.c:309