22namespace PHPJava \Kernel \Structures ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Exceptions \ReadOnlyException ;
56use PHPJava \Utilities \BinaryTool ;
67
78class _Utf8 implements StructureInterface
@@ -12,6 +13,7 @@ class _Utf8 implements StructureInterface
1213
1314 private $ length = 0 ;
1415 private $ string = '' ;
16+ private $ isWritable = false ;
1517
1618 /**
1719 * @var \PHPJava\Packages\java\lang\_String $stringObject
@@ -32,6 +34,31 @@ public function getLength()
3234 return $ this ->length ;
3335 }
3436
37+ /**
38+ * @param bool $enable
39+ * @return _Utf8
40+ */
41+ public function enableWrite (bool $ enable ): self
42+ {
43+ $ this ->isWritable = $ enable ;
44+ return $ this ;
45+ }
46+
47+ /**
48+ * @param string $string
49+ * @return _Utf8
50+ * @throws ReadOnlyException
51+ */
52+ public function setString (string $ string ): self
53+ {
54+ if ($ this ->isWritable ) {
55+ $ this ->string = $ string ;
56+ return $ this ;
57+ }
58+
59+ throw new ReadOnlyException ('You cannot overwrite constant. ' );
60+ }
61+
3562 public function getString ()
3663 {
3764 return $ this ->string ;
@@ -42,6 +69,12 @@ public function __toString(): string
4269 return $ this ->getString ();
4370 }
4471
72+ public function setStringObject (\PHPJava \Packages \java \lang \_String $ stringObject ): self
73+ {
74+ $ this ->stringObject = $ stringObject ;
75+ return $ this ;
76+ }
77+
4578 public function getStringObject (): \PHPJava \Packages \java \lang \_String
4679 {
4780 return $ this ->stringObject ;
0 commit comments