|
3 | 3 | Bytes is a utility library that makes it easy to **create**, **parse**, **transform**, |
4 | 4 | **validate** and **convert** byte arrays in Java. It's main class `Bytes` is |
5 | 5 | a collections of bytes and the main API. It supports [endianness](https://en.wikipedia.org/wiki/Endianness) |
6 | | -as well as **immutability** and **mutability**, so the caller may decide to favor |
| 6 | +as well as **immutable** and **mutable** access, so the caller may decide to favor |
7 | 7 | performance. This can be seen as combination of the features provided by |
8 | 8 | [`BigInteger`](https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html), |
9 | 9 | [`ByteBuffer`](https://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html) but |
@@ -147,7 +147,9 @@ For parsing binary-text-encoded strings, see below. |
147 | 147 |
|
148 | 148 | Transformer transform the internal byte array. It is possible to create |
149 | 149 | custom transformers if a specific feature is not provided by the default |
150 | | - implementation (see `BytesTransformer`). |
| 150 | + implementation (see `BytesTransformer`). Depending on the type (mutable vs |
| 151 | + immutable) and transformer it will overwrite the internal byte array |
| 152 | + or always create a copy first. |
151 | 153 |
|
152 | 154 | ```java |
153 | 155 | Bytes result = Bytes.wrap(array1).transform(myCustomTransformer); |
@@ -387,6 +389,13 @@ b.wipe() //fills with zeros |
387 | 389 | b.secureWipe() //fills with random data |
388 | 390 | ``` |
389 | 391 |
|
| 392 | +*Note:* a copy will inherit mutability/read-only properties: |
| 393 | + |
| 394 | +```java |
| 395 | +Bytes b = Bytes.from(array).mutable().copy(); |
| 396 | +assertTrue(b.isMutable()); |
| 397 | +``` |
| 398 | + |
390 | 399 | #### Readonly Bytes |
391 | 400 |
|
392 | 401 | On the other hand, if you want a export a instance with limited access, |
|
0 commit comments