1 5 package org.h2.value; 6 7 import org.h2.engine.Constants; 8 import org.h2.util.ByteUtils; 9 10 13 public class ValueBytes extends ValueBytesBase { 14 15 private static final ValueBytes EMPTY = new ValueBytes(new byte[0]); 16 17 protected ValueBytes(byte[] v) { 18 super(v); 19 } 20 21 public static ValueBytes get(byte[] b) { 22 b = ByteUtils.cloneByteArray(b); 23 return getNoCopy(b); 24 } 25 26 public static ValueBytes getNoCopy(byte[] b) { 27 if (b.length == 0) { 28 return EMPTY; 29 } 30 ValueBytes obj = new ValueBytes(b); 31 if (b.length > Constants.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { 32 return obj; 33 } 34 return (ValueBytes) Value.cache(obj); 35 } 36 37 public int getType() { 38 return Value.BYTES; 39 } 40 41 } 42 | Popular Tags |