1 34 package smallsql.database; 35 36 37 40 public class ExpressionFunctionRTrim extends ExpressionFunctionReturnP1StringAndBinary { 41 42 final int getFunction() { 43 return SQLTokenizer.RTRIM; 44 } 45 46 47 final boolean isNull() throws Exception { 48 return param1.isNull(); 49 } 50 51 52 final byte[] getBytes() throws Exception { 53 if(isNull()) return null; 54 byte[] bytes = param1.getBytes(); 55 int length = bytes.length; 56 while(length>0 && bytes[length-1]==0){ 57 length--; 58 } 59 byte[] b = new byte[length]; 60 System.arraycopy(bytes, 0, b, 0, length); 61 return b; 62 } 63 64 65 final String getString() throws Exception { 66 if(isNull()) return null; 67 String str = param1.getString(); 68 int length = str.length(); 69 while(length>0 && str.charAt(length-1)==' '){ 70 length--; 71 } 72 return str.substring(0,length); 73 } 74 75 76 } 77 | Popular Tags |