KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > value > ValueJavaObject


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.value;
6
7 import org.h2.engine.Constants;
8
9 public class ValueJavaObject extends ValueBytesBase {
10     
11     private static final ValueJavaObject EMPTY = new ValueJavaObject(new byte[0]);
12
13     protected ValueJavaObject(byte[] v) {
14         super(v);
15     }
16     
17     public static ValueJavaObject getNoCopy(byte[] b) {
18         if (b.length == 0) {
19             return EMPTY;
20         }
21         ValueJavaObject obj = new ValueJavaObject(b);
22         if (b.length > Constants.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) {
23             return obj;
24         }
25         return (ValueJavaObject) Value.cache(obj);
26     }
27     
28     public int getType() {
29         return Value.JAVA_OBJECT;
30     }
31
32 }
33
Popular Tags