All pastes #370307 Raw Edit

Someone

public text v1 · immutable
#370307 ·published 2007-02-24 13:22 UTC
rendered paste body
/**
	 * Test if a string is a valid expression of the query language.
	 * @param expression The expression to test
	 * @return Whether the string validates or not
	 */
	public boolean validate(String expression) {
		
		try {
			
			new query(new StringReader(expression));
			query.Start();
			
			//No errors; the string is valid.
			
			return true;
			
		} catch (Throwable e) { 
			
			//An error indicates failure. Not that exception cannot be used here as TokenMgrError is an /error/, not an exception.
		
			return false;
		
		}

	}