FOSSology  4.4.0
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 
23  const COPYRIGHT = "C";
24  const URL = "U";
25  const EMAIL = "E";
26  const AUTHOR = "A";
27  const IPRA = "I";
28  const ECC = "X";
29  const KEYWORDOTHERS = "KW";
30  const UNDEFINED = "any";
31 
35  private $start;
39  private $end;
43  private $type;
47  private $licenseId;
51  private $refStart;
55  private $refEnd;
59  private $infoText;
63  private $htmlElement;
64 
74  function __construct($start, $end, $type, $refStart=-1, $refEnd=-1, $infoText = "", $htmlElement = null)
75  {
76  $this->start = $start;
77  $this->end = $end;
78  $this->type = $type;
79  $this->refStart = $refStart;
80  $this->refEnd = $refEnd;
81  $this->infoText = $infoText;
82  $this->htmlElement = $htmlElement;
83 
84  $this->licenseId = null;
85  }
86 
90  public function getStart()
91  {
92  return $this->start;
93  }
94 
98  public function getEnd()
99  {
100  return $this->end;
101  }
102 
106  public function getType()
107  {
108  return $this->type;
109  }
110 
115  public function setLicenseId($licenseId)
116  {
117  $this->licenseId = intval($licenseId);
118  }
119 
123  public function getLicenseId()
124  {
125  return $this->licenseId;
126  }
127 
131  public function hasLicenseId()
132  {
133  return $this->licenseId != null;
134  }
135 
139  public function isPersistent()
140  {
141  return $this->licenseId == null;
142  }
143 
144 
148  public function getRefStart()
149  {
150  return $this->refStart;
151  }
152 
153  private function hasRef()
154  {
155  return $this->getRefStart() >= 0;
156  }
157 
161  public function getRefEnd()
162  {
163  return $this->refEnd;
164  }
165 
169  public function getRefLength()
170  {
171  return max(0, $this->refEnd - $this->refStart);
172  }
173 
177  public function setInfoText($infoText)
178  {
179  $this->infoText = $infoText;
180  }
181 
185  public function getInfoText()
186  {
187  return $this->infoText;
188  }
189 
193  public function getHtmlElement()
194  {
195  return $this->htmlElement;
196  }
197 
202  public function getArray()
203  {
204  return array(
205  "start" => $this->start,
206  "end" => $this->end,
207  "type" => $this->type,
208  "licenseId" => $this->licenseId,
209  "refStart" => $this->refStart,
210  "refEnd" => $this->refEnd,
211  "infoText" => $this->infoText,
212  "htmlElement" => $this->htmlElement
213  );
214  }
215 
216  public function __toString()
217  {
218  return "Highlight("
219  . $this->start . "-" . $this->end
220  . ", type=" . $this->type
221  . ", id=" . $this->licenseId .
222  ($this->hasRef() ? ":". $this->refStart . "-" . $this->refEnd : "")
223  .")";
224  }
225 }
__construct($start, $end, $type, $refStart=-1, $refEnd=-1, $infoText="", $htmlElement=null)
Definition: Highlight.php:74
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