Search in sources :

Example 6 with ValueOutputToken

use of org.eclipse.scout.rt.server.jdbc.parsers.token.ValueOutputToken in project scout.rt by eclipse.

the class StatementProcessorTest method exec.

private String[] exec(final boolean checkForDuplicateBinds, final String statement, final Object... binds) {
    final Collection<String> duplicates = new ArrayList<>();
    final AbstractSqlService sqlService = new AbstractSqlService() {
    };
    new StatementProcessor(sqlService, statement, binds) {

        @Override
        protected boolean isBindDuplicateCheckEnabled() {
            return checkForDuplicateBinds;
        }

        @Override
        protected void onDuplicateBind(IToken token) {
            if (token instanceof ValueInputToken) {
                duplicates.add(((ValueInputToken) token).getName());
            } else if (token instanceof ValueOutputToken) {
                duplicates.add(((ValueOutputToken) token).getName());
            } else {
                throw new ProcessingException("Unexpected token: {}", token);
            }
        }
    }.simulate();
    return duplicates.toArray(new String[duplicates.size()]);
}
Also used : ValueOutputToken(org.eclipse.scout.rt.server.jdbc.parsers.token.ValueOutputToken) IToken(org.eclipse.scout.rt.server.jdbc.parsers.token.IToken) ArrayList(java.util.ArrayList) AbstractSqlService(org.eclipse.scout.rt.server.jdbc.AbstractSqlService) ValueInputToken(org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

ValueOutputToken (org.eclipse.scout.rt.server.jdbc.parsers.token.ValueOutputToken)6 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)2 ParsePosition (java.text.ParsePosition)1 ArrayList (java.util.ArrayList)1 AbstractSqlService (org.eclipse.scout.rt.server.jdbc.AbstractSqlService)1 IToken (org.eclipse.scout.rt.server.jdbc.parsers.token.IToken)1 ValueInputToken (org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken)1