@Test public void testPaddedStringComparison(){ assertEquals(1, Constant.comparePadded("a", "")); assertEquals(0, Constant.comparePadded("a", "a ")); assertEquals(-24, Constant.comparePadded("ab ", "az ")); assertEquals(66, Constant.comparePadded("ab ", "a ")); assertEquals(0, Constant.comparePadded("a1 ", "a1")); }
final static int comparePadded(CharSequence s1, CharSequence s2) { int len1 = s1.length(); int len2 = s2.length(); int n = Math.min(len1, len2); int i = 0; int result = 0; for (; i < n; i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (c1 != c2) { return c1 - c2; } } result = len1 - len2; for (int j = i; j < len1; j++) { if (s1.charAt(j) != ' ') { return result; } } for (int j = i; j < len2; j++) { if (s2.charAt(j) != ' ') { return result; } } return 0; }
Constant implements Expression, Comparable<Constant> { final static int comparePadded(CharSequence s1, CharSequence s2) { int len1 = s1.length(); int len2 = s2.length(); int n = Math.min(len1, len2); int i = 0; int result = 0; for (; i < n; i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (c1 != c2) { return c1 - c2; } } result = len1 - len2; for (int j = i; j < len1; j++) { if (s1.charAt(j) != ' ') { return result; } } for (int j = i; j < len2; j++) { if (s2.charAt(j) != ' ') { return result; } } return 0; } }
Constant implements Expression, Comparable<Constant> { final static int comparePadded(CharSequence s1, CharSequence s2) { int len1 = s1.length(); int len2 = s2.length(); int n = Math.min(len1, len2); int i = 0; int result = 0; for (; i < n; i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (c1 != c2) { return c1 - c2; } } result = len1 - len2; for (int j = i; j < len1; j++) { if (s1.charAt(j) != ' ') { return result; } } for (int j = i; j < len2; j++) { if (s2.charAt(j) != ' ') { return result; } } return 0; } Constant(Object value, Class<?> type);  Constant(Object value); }
Constant implements Expression, Comparable<Constant> { final static int comparePadded(CharSequence s1, CharSequence s2) { int len1 = s1.length(); int len2 = s2.length(); int n = Math.min(len1, len2); int i = 0; int result = 0; for (; i < n; i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (c1 != c2) { return c1 - c2; } } result = len1 - len2; for (int j = i; j < len1; j++) { if (s1.charAt(j) != ' ') { return result; } } for (int j = i; j < len2; j++) { if (s2.charAt(j) != ' ') { return result; } } return 0; } Constant(Object value, Class<?> type);  Constant(Object value); Class<?> getType(); void setType(Class<?> type); Object getValue(); boolean isNull(); void setMultiValued(List<?> value); boolean isMultiValued(); void acceptVisitor(LanguageVisitor visitor); boolean equals(Object obj); int hashCode(); Object clone(); String toString(); @Override int compareTo(Constant o); boolean isBindEligible(); void setBindEligible(boolean bindEligible); }
Constant implements Expression, Comparable<Constant> { final static int comparePadded(CharSequence s1, CharSequence s2) { int len1 = s1.length(); int len2 = s2.length(); int n = Math.min(len1, len2); int i = 0; int result = 0; for (; i < n; i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (c1 != c2) { return c1 - c2; } } result = len1 - len2; for (int j = i; j < len1; j++) { if (s1.charAt(j) != ' ') { return result; } } for (int j = i; j < len2; j++) { if (s2.charAt(j) != ' ') { return result; } } return 0; } Constant(Object value, Class<?> type);  Constant(Object value); Class<?> getType(); void setType(Class<?> type); Object getValue(); boolean isNull(); void setMultiValued(List<?> value); boolean isMultiValued(); void acceptVisitor(LanguageVisitor visitor); boolean equals(Object obj); int hashCode(); Object clone(); String toString(); @Override int compareTo(Constant o); boolean isBindEligible(); void setBindEligible(boolean bindEligible); static final Constant NULL_CONSTANT; static final Comparator<Object> COMPARATOR; }