01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.value;
07:
08: import org.h2.constant.SysProperties;
09: import org.h2.util.ByteUtils;
10:
11: /**
12: * Implementation of the BINARY data type.
13: */
14: public class ValueBytes extends ValueBytesBase {
15:
16: private static final ValueBytes EMPTY = new ValueBytes(new byte[0]);
17:
18: protected ValueBytes(byte[] v) {
19: super (v);
20: }
21:
22: public static ValueBytes get(byte[] b) {
23: b = ByteUtils.cloneByteArray(b);
24: return getNoCopy(b);
25: }
26:
27: public static ValueBytes getNoCopy(byte[] b) {
28: if (b.length == 0) {
29: return EMPTY;
30: }
31: ValueBytes obj = new ValueBytes(b);
32: if (b.length > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) {
33: return obj;
34: }
35: return (ValueBytes) Value.cache(obj);
36: }
37:
38: public int getType() {
39: return Value.BYTES;
40: }
41:
42: }
|