1 34 package smallsql.database; 35 36 37 40 public class ExpressionFunctionLTrim extends ExpressionFunctionReturnP1StringAndBinary { 41 42 final int getFunction() { 43 return SQLTokenizer.LTRIM; 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 start = 0; 56 int length = bytes.length; 57 while(start<length && bytes[start]==0){ 58 start++; 59 } 60 length -= start; 61 byte[] b = new byte[length]; 62 System.arraycopy(bytes, start, b, 0, length); 63 return b; 64 } 65 66 67 final String getString() throws Exception { 68 if(isNull()) return null; 69 String str = param1.getString(); 70 int start = 0; 71 while(start<str.length() && str.charAt(start)==' '){ 72 start++; 73 } 74 return str.substring(start); 75 } 76 77 78 } 79 | Popular Tags |