1 5 package org.h2.value; 6 7 import org.h2.engine.Constants; 8 import org.h2.util.StringCache; 9 10 13 public class ValueString extends ValueStringBase { 14 15 private static final ValueString EMPTY = new ValueString(""); 16 17 protected ValueString(String value) { 18 super(value); 19 } 20 21 public int getType() { 22 return Value.STRING; 23 } 24 25 protected int compareSecure(Value o, CompareMode mode) { 26 ValueString v = (ValueString) o; 27 return mode.compareString(value, v.value, false); 28 } 29 30 public int hashCode() { 31 return value.hashCode(); 33 34 56 } 57 58 public static ValueString get(String s) { 59 if (s.length() == 0) { 60 return EMPTY; 61 } 62 ValueString obj = new ValueString(StringCache.get(s)); 63 if (s.length() > Constants.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { 64 return obj; 65 } 66 return (ValueString) Value.cache(obj); 67 } 70 71 } 72 | Popular Tags |