Trim Keywords Followed By Whitespace Other Than The Character ' '
Modify `removeKeyWord(...)` such that the keyword is removed regardless of what kind of whitespace follows. This is especially useful for those who read in SQL from a file which has been formatted such that keywords live on their own lines. Added unit tests for trimming whitespace. Resolves #765
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
6103fe7306
commit
7f01bf78cf
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2018 the original author or authors.
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Dave Syer
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Benjamin Hetz
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvider {
|
||||
@@ -242,9 +243,9 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi
|
||||
|
||||
private String removeKeyWord(String keyWord, String clause) {
|
||||
String temp = clause.trim();
|
||||
String keyWordString = keyWord + " ";
|
||||
if (temp.toLowerCase().startsWith(keyWordString) && temp.length() > keyWordString.length()) {
|
||||
return temp.substring(keyWordString.length());
|
||||
int length = keyWord.length();
|
||||
if (temp.toLowerCase().startsWith(keyWord) && Character.isWhitespace(temp.charAt(length)) && temp.length() > length + 1) {
|
||||
return temp.substring(length + 1);
|
||||
}
|
||||
else {
|
||||
return temp;
|
||||
|
||||
Reference in New Issue
Block a user