-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathFieldPool.php
More file actions
94 lines (83 loc) Β· 1.98 KB
/
FieldPool.php
File metadata and controls
94 lines (83 loc) Β· 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
declare(strict_types=1);
namespace PHPJava\Core\JVM;
use PHPJava\Core\Stream\Reader\ReaderInterface;
use PHPJava\Exceptions\ReadOnlyException;
use PHPJava\Kernel\Structures\FieldInfo;
use PHPJava\Utilities\DebugTool;
class FieldPool implements \ArrayAccess, \Countable, \IteratorAggregate
{
/**
* @var FieldInfo[]
*/
private $entries = [];
/**
* @var ReaderInterface
*/
private $reader;
public function __construct(
ReaderInterface $reader,
int $entries,
ConstantPool $constantPool,
DebugTool $debugTool
) {
$this->reader = $reader;
for ($i = 0; $i < $entries; $i++) {
$this->entries[$i] = new FieldInfo($reader);
$this->entries[$i]->setConstantPool($constantPool);
$this->entries[$i]->setDebugTool($debugTool);
$this->entries[$i]->execute();
}
}
/**
* @return FieldInfo[]
*/
public function getEntries()
{
return $this->entries;
}
/**
* @param int $offset
* @return bool
*/
public function offsetExists($offset)
{
return isset($this->entries[$offset]);
}
/**
* @param int $offset
* @return FieldInfo
*/
public function offsetGet($offset)
{
return $this->entries[$offset];
}
/**
* @return int
*/
public function count()
{
return count($this->entries);
}
/**
* @throws ReadOnlyException
*/
public function offsetSet($offset, $value)
{
throw new ReadOnlyException('You cannot rewrite datum. The Field Pool is read-only.');
}
/**
* @throws ReadOnlyException
*/
public function offsetUnset($offset)
{
throw new ReadOnlyException('You cannot rewrite datum. The Field Pool is read-only.');
}
/**
* @return \ArrayIterator<FieldInfo>
*/
public function getIterator()
{
return new \ArrayIterator($this->entries);
}
}