icegem-core/src/main/java/com/googlecode/icegem/utils/CacheUtils.java
public static String addQueryLimit(String queryString, int queryLimit) {
		int limitIndex = queryString.lastIndexOf("limit");

		if (limitIndex == -1) {
			limitIndex = queryString.lastIndexOf("LIMIT");
		}

		if (limitIndex == -1) {
			return queryString + " LIMIT " + (queryLimit + 1);
		}

		int limitNumber = Integer.parseInt(queryString
				.substring(limitIndex + 5).trim());

		return (limitNumber > queryLimit) ? queryString
				.substring(0, limitIndex) + " LIMIT " + (queryLimit + 1)
				: queryString;
	}
public static String addQueryLimit(String queryString, int queryLimit) {
		int limitIndex = queryString.lastIndexOf("limit");

		if (limitIndex == -1) {
			limitIndex = queryString.lastIndexOf("LIMIT");
		}

		if (limitIndex == -1) {
			return queryString + " LIMIT " + (queryLimit + 1);
		}

		int limitNumber = Integer.parseInt(queryString
				.substring(limitIndex + 5).trim());

		return (limitNumber > queryLimit) ? queryString
				.substring(0, limitIndex) + " LIMIT " + (queryLimit + 1)
				: queryString;
	}
public static String addQueryLimit ( String queryString , int queryLimit ) { int limitIndex = queryString . lastIndexOf ( "limit" ) ; if ( limitIndex == - 1 ) { limitIndex = queryString . lastIndexOf ( "LIMIT" ) ; } if ( limitIndex == - 1 ) { return queryString + " LIMIT " + ( queryLimit + 1 ) ; } int limitNumber = Integer . parseInt ( queryString . substring ( limitIndex + 5 ) . trim ( ) ) ; return ( limitNumber > queryLimit ) ? queryString . substring ( 0 , limitIndex ) + " LIMIT " + ( queryLimit + 1 ) : queryString ; }
Limits query results.

@param queryString
Query string.
@return Query string with injected "LIMIT" clause.
Limits query results .