FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Highlight.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014, 2018 Siemens AG
4  Authors: Andreas Würl, Daniele Fognini
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\Lib\Data;
10 
12 
13 class Highlight
14 {
15  const MATCH = "M";
16  const CHANGED = "MC";
17  const ADDED = "MA";
18  const DELETED = "MD";
19  const SIGNATURE = "S";
20  const KEYWORD = "K";
21  const BULK = "B";
22  const KOTOBA = "KB";
23 
24  const COPYRIGHT = "C";
25  const URL = "U";
26  const EMAIL = "E";
27  const AUTHOR = "A";
28  const IPRA = "I";
29  const ECC = "X";
30  const KEYWORDOTHERS = "KW";
31  const UNDEFINED = "any";
32 
36  private $start;
40  private $end;
44  private $type;
48  private $licenseId;
52  private $refStart;
56  private $refEnd;
60  private $infoText;
64  private $htmlElement;
65 
75  function __construct($start, $end, $type, $refStart=-1, $refEnd=-1, $infoText = "", $htmlElement = null)
76  {
77  $this->start = $start;
78  $this->end = $end;
79  $this->type = $type;
80  $this->refStart = $refStart;
81  $this->refEnd = $refEnd;
82  $this->infoText = $infoText;
83  $this->htmlElement = $htmlElement;
84 
85  $this->licenseId = null;
86  }
87 
91  public function getStart()
92  {
93  return $this->start;
94  }
95 
99  public function getEnd()
100  {
101  return $this->end;
102  }
103 
107  public function getType()
108  {
109  return $this->type;
110  }
111 
116  public function setLicenseId($licenseId)
117  {
118  $this->licenseId = intval($licenseId);
119  }
120 
124  public function getLicenseId()
125  {
126  return $this->licenseId;
127  }
128 
132  public function hasLicenseId()
133  {
134  return $this->licenseId != null;
135  }
136 
140  public function isPersistent()
141  {
142  return $this->licenseId == null;
143  }
144 
145 
149  public function getRefStart()
150  {
151  return $this->refStart;
152  }
153 
154  private function hasRef()
155  {
156  return $this->getRefStart() >= 0;
157  }
158 
162  public function getRefEnd()
163  {
164  return $this->refEnd;
165  }
166 
170  public function getRefLength()
171  {
172  return max(0, $this->refEnd - $this->refStart);
173  }
174 
178  public function setInfoText($infoText)
179  {
180  $this->infoText = $infoText;
181  }
182 
186  public function getInfoText()
187  {
188  return $this->infoText;
189  }
190 
194  public function getHtmlElement()
195  {
196  return $this->htmlElement;
197  }
198 
203  public function getArray()
204  {
205  return array(
206  "start" => intval($this->start),
207  "end" => intval($this->end),
208  "type" => $this->type == null ? Highlight::UNDEFINED : $this->type,
209  "licenseId" => $this->licenseId,
210  "refStart" => $this->refStart == -1 ? 0 : $this->refStart,
211  "refEnd" => $this->refEnd == -1 ? 0 : $this->refEnd,
212  "infoText" => $this->infoText,
213  "htmlElement" => $this->htmlElement
214  );
215  }
216 
217  public function __toString()
218  {
219  return "Highlight("
220  . $this->start . "-" . $this->end
221  . ", type=" . $this->type
222  . ", id=" . $this->licenseId .
223  ($this->hasRef() ? ":". $this->refStart . "-" . $this->refEnd : "")
224  .")";
225  }
226 }
__construct($start, $end, $type, $refStart=-1, $refEnd=-1, $infoText="", $htmlElement=null)
Definition: Highlight.php:75
FUNCTION int max(int permGroup, int permPublic)
Get the maximum group privilege.
Definition: libfossagent.c:295
start($application)
start the application Assumes application is restartable via /etc/init.d/<script>....
Definition: pkgConfig.php:1214