use of org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken in project scout.rt by eclipse.
the class BindModel method getFilteredStatement.
public String getFilteredStatement() {
StringBuilder b = new StringBuilder();
for (int i = 0; i < m_allTokens.length; i++) {
if (m_allTokens[i] instanceof ValueInputToken) {
ValueInputToken valueInputToken = (ValueInputToken) m_allTokens[i];
if (valueInputToken.getParsedAttribute() != null) {
b.append(valueInputToken.getParsedAttribute());
b.append(" ");
}
if (valueInputToken.getParsedOp() != null) {
b.append(valueInputToken.getParsedOp());
b.append(" ");
}
}
b.append(m_allTokens[i].getReplaceToken());
}
return b.toString();
}
use of org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken in project scout.rt by eclipse.
the class BindParser method parseExtendedBind.
private IToken parseExtendedBind() {
if (LOG.isTraceEnabled()) {
trace("parseExtendedBind");
}
int index = m_pos.getIndex();
String attribute = null;
String op = null;
IToken token = null;
if ((attribute = parseAttribute()) == null || !parseWhitespace(0) || (op = parseOp()) == null || !parseWhitespace(0)) {
m_pos.setIndex(index);
attribute = null;
op = null;
if ((op = parseOp()) == null || !parseWhitespace(0)) {
m_pos.setIndex(index);
}
}
int indexAfterOp = m_pos.getIndex();
if ((token = parseBind()) != null) {
if (token instanceof ValueInputToken) {
addTextTokenUntil(index);
((ValueInputToken) token).setParsedAttribute(attribute);
((ValueInputToken) token).setParsedOp(op);
} else {
addTextTokenUntil(indexAfterOp);
}
addToken(token, m_pos.getIndex());
return token;
} else {
m_pos.setIndex(index);
return null;
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken in project scout.rt by eclipse.
the class BindParserTest method testInListAttribute.
/**
* Column starts with "IN"
*/
@Test
public void testInListAttribute() {
String sql = "SELECT INT_COLUMN_ID FROM TABLE1 WHERE INT_COLUMN_ID != :refId";
BindModel bindModel = new BindParser(sql).parse();
IToken[] tokens = bindModel.getIOTokens();
ValueInputToken tok = (ValueInputToken) tokens[0];
assertEquals("INT_COLUMN_ID", tok.getParsedAttribute());
assertEquals("!=", tok.getParsedOp());
assertEquals(":refId", tok.getParsedToken());
assertEquals("refId", tok.getName());
}
use of org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken in project scout.rt by eclipse.
the class StatementProcessor method createPlainText.
/*
* (non-Javadoc)
* @seeorg.eclipse.scout.rt.server.services.common.sql.internal.exec.
* IStatementProcessor#createPlainText()
*/
@Override
public String createPlainText() {
for (IToken t : m_ioTokens) {
if (t instanceof ValueInputToken) {
ValueInputToken vt = (ValueInputToken) t;
if (vt.isPlainSql()) {
// ok
} else if (vt.isPlainValue()) {
// ok
} else {
vt.setPlainValue(true);
}
} else if (t instanceof FunctionInputToken) {
FunctionInputToken ft = (FunctionInputToken) t;
ft.setPlainValue(true);
}
}
if (hasNextInputBatch()) {
nextInputBatch();
prepareInputStatementAndBinds();
resetInputBatch();
}
return m_currentInputStm;
}
use of org.eclipse.scout.rt.server.jdbc.parsers.token.ValueInputToken in project scout.rt by eclipse.
the class StatementProcessor method createInput.
private IBindInput createInput(IToken bindToken, Object[] bindBases) {
if (bindToken instanceof ValueInputToken) {
final ValueInputToken valueInputToken = (ValueInputToken) bindToken;
final String[] path = REGEX_DOT.split(valueInputToken.getName());
IBindInput result = null;
for (final Object bindBase : bindBases) {
Class nullType = null;
if (bindBase instanceof NVPair) {
nullType = ((NVPair) bindBase).getNullType();
}
final IBindInput in = createInputRec(valueInputToken, path, bindBase, nullType);
if (in != null) {
// bind found
if (isBindDuplicateCheckEnabled()) {
if (result == null) {
// first match found for the bind -> remember
result = in;
} else {
// second match found
onDuplicateBind(valueInputToken);
return result;
}
} else {
// no duplicate check necessary: directly return the first match
return in;
}
}
}
if (result == null) {
throw new ProcessingException("Cannot find input for '{}' in bind bases.", valueInputToken);
}
return result;
} else if (bindToken instanceof FunctionInputToken) {
return new FunctionInput(m_callerService, m_bindBases, (FunctionInputToken) bindToken);
}
throw new ProcessingException("Cannot find input for {}", bindToken.getClass());
}
Aggregations