/** * Enforce the char length. */ protected String getPaddedString(String value) { return HiveBaseChar.getPaddedValue(value, length); }
/** * Enforce the max legnth of varchar or char. */ protected String enforceMaxLength(String value) { return HiveBaseChar.enforceMaxLength(value, length); }
public static boolean doesPrimitiveMatchTypeParams(HiveBaseChar value, BaseCharTypeInfo typeInfo) { return typeInfo.getLength() == value.getCharacterLength(); } }
/** * Set char value, padding or truncating the value to the size of len parameter. */ @Override public void setValue(String val, int len) { super.setValue(HiveBaseChar.getPaddedValue(val, len), -1); }
@Override public String toString() { return getValue(); } }
/** * Set the new value */ public void setValue(String val) { super.setValue(val, -1); }
/** * Set char value, padding or truncating the value to the size of len parameter. */ public void setValue(String val, int len) { super.setValue(HiveBaseChar.getPaddedValue(val, len), -1); }
@Override public int hashCode() { return getValue().hashCode(); }
public void setValue(HiveBaseChar val, int maxLength) { setValue(val.value, maxLength); }
/** * Sets the string value to a new value, obeying the max length defined for this object. * @param val new value */ public void setValue(String val, int maxLength) { value = HiveBaseChar.enforceMaxLength(val, maxLength); }
public void set(String val, int maxLength) { value.set(HiveBaseChar.getPaddedValue(val, maxLength)); }
/** * Set char value, padding or truncating the value to the size of len parameter. */ public void setValue(String val, int len) { super.setValue(HiveBaseChar.getPaddedValue(val, len), -1); }
public static boolean doesPrimitiveMatchTypeParams(HiveBaseChar value, BaseCharTypeInfo typeInfo) { return typeInfo.getLength() == value.getCharacterLength(); } }
@Override public String toString() { return getValue(); } }
public void setValue(HiveVarchar hc) { super.setValue(hc.getValue(), -1); }
public void set(String val, int maxLength) { value.set(HiveBaseChar.enforceMaxLength(val, maxLength)); }
public void testGetPaddedValue() { int strLen = 20; int[] lengths = { 15, 20, 25 }; for (int idx1 = 0; idx1 < lengths.length; ++idx1) { int curLen = lengths[idx1]; // Random test string String testString = createRandomSupplementaryCharString(curLen); assertEquals(curLen, testString.codePointCount(0, testString.length())); String paddedString = HiveBaseChar.getPaddedValue(testString, strLen); assertEquals(strLen, paddedString.codePointCount(0, paddedString.length())); } assertEquals("abc ", HiveBaseChar.getPaddedValue("abc", 10)); assertEquals("abc ", HiveBaseChar.getPaddedValue("abc ", 10)); assertNull(HiveBaseChar.getPaddedValue(null, 0)); } }
public static boolean doesPrimitiveMatchTypeParams(HiveBaseChar value, BaseCharTypeInfo typeInfo) { return typeInfo.getLength() == value.getCharacterLength(); } }
@Override public String toString() { return getValue(); } }
/** * Set the new value */ public void setValue(String val) { super.setValue(val, -1); }