1 package org
.argeo
.api
.uuid
;
6 * A name UUID whose binary data used for its construction is known. A new byte
7 * array is created and it is copied when retrieved, so this would be
8 * inefficient and memory consuming for big data amounts. This rather meant to
9 * be used for small binary data, such as certificates, etc.
11 public class BinaryNameUuid
extends BasicNameUuid
{
12 private static final long serialVersionUID
= APM
.SERIAL
;
14 protected final TypedUuid namespace
;
15 protected final byte[] bytes
;
17 /** Static builder (a {@link TypedUuidFactory} may be more efficient). */
18 public BinaryNameUuid(TypedUuid namespace
, byte[] bytes
, boolean sha1
) {
19 this(sha1 ? AbstractUuidFactory
.createNameUUIDv5Static(namespace
.uuid
, bytes
)
20 : AbstractUuidFactory
.createNameUUIDv5Static(namespace
.uuid
, bytes
), namespace
, bytes
);
24 * Since no check is performed, the constructor is protected so that the object
25 * can only be built by the default methods of {@link TypedUuidFactory} (in this
26 * package) or by extending the class.
28 protected BinaryNameUuid(UUID uuid
, TypedUuid namespace
, byte[] bytes
) {
30 this.namespace
= namespace
;
31 this.bytes
= new byte[bytes
.length
];
32 System
.arraycopy(bytes
, 0, this.bytes
, 0, bytes
.length
);
35 /** The namespace used to build this UUID. */
36 public final TypedUuid
getNamespace() {
41 * A <strong>copy</strong> of the bytes which have been hashed. In order to
42 * access the byte array directly, the class must be extended.
44 public final byte[] getBytes() {
45 byte[] bytes
= new byte[this.bytes
.length
];
46 System
.arraycopy(this.bytes
, 0, bytes
, 0, this.bytes
.length
);
50 /** Always returns <code>false</code> since the construction value is known. */
52 public final boolean isOpaque() {