1 package com.daffodilwoods.daffodildb.utils.parser; 2 3 public class StringProductionRulesWithoutSpace extends StringProductionRules implements java.io.Serializable { 4 5 StringProductionRulesWithoutSpace(ClassLoader classLoader0){ 6 super(classLoader0); 7 } 8 9 Object parsePart(ParseElements pe){ 10 11 if(pe.position >= pe.query.length() || pe.recursiveObject != null){ 12 pe.parseException.setPosition(pe.getIndexPosition(pe.position)); 13 return pe.parseException; 14 } 15 16 int cmp = checkString(pe.queryArray,string,pe.position); 17 if ( cmp == 0 ) { 18 pe.position += ((String )result).length(); 19 if ( pe.position <= pe.queryArray.length - 1) 20 return new Object []{result}; 21 if ( pe.position == pe.queryArray.length ) 22 return new Object []{result}; 23 } 24 cmp = cmp > 0 ? 1 : cmp < 0 ? -1 : 0; 25 pe.parseException.setReturnType(cmp); 26 pe.parseException.setPosition(pe.getIndexPosition(pe.position)); 27 return pe.parseException; 28 } 29 30 private int checkString(char []source, char[] target,int position){ 31 int compare = 0; 32 int i = position; 33 for(int j = 0; i < source.length && j < target.length && compare == 0; ++j,++i) 34 compare = source[i] - target[j]; 35 return compare; 36 } 37 38 public String toString(){ 39 return new StringBuffer (" STRING PROD RULE WITHOUT SPACE ").append(result).toString(); 40 } 41 42 } 43 | Popular Tags |