test_class.file: dal-jdbc/src/test/java/org/unidal/dal/jdbc/query/token/resolver/ValueTokenResolverTest.java
test_class.identifier: ValueTokenResolverTest
test_class.superclass: extends AbstractTokenResolverTest
test_case.body: @Test
     public void testUserName() throws Exception {
        QueryDef query = new QueryDef("test", UserEntity.class, QueryType.INSERT, "<value name='user-name'/>");
        User user = new User();
        QueryContext ctx = getSelectContext(query, user, null);
  
        user.setUserName("test");
        m_queryResolver.resolve(ctx);
        Assert.assertEquals("?", ctx.getSqlStatement());
        Assert.assertEquals("[${user-name}]", ctx.getParameters().toString());
     }
test_case.class_method_signature: ValueTokenResolverTest.testUserName()
test_case.full_signature: @Test public void testUserName()
test_case.identifier: testUserName
test_case.invocations: getSelectContext setUserName resolve assertEquals getSqlStatement assertEquals toString getParameters
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUserName()
focal_class.declarator: m_expressionResolver
focal_class.modifier: @Inject
     private
focal_class.original_string: @Inject
     private ExpressionResolver m_expressionResolver;
focal_class.type: ExpressionResolver
focal_class.var_name: m_expressionResolver
focal_class.file: dal-jdbc/src/main/java/org/unidal/dal/jdbc/query/token/resolver/ValueTokenResolver.java
focal_class.identifier: ValueTokenResolver
focal_class.interfaces: implements TokenResolver
focal_class.class_method_signature: ValueTokenResolver.resolve(Token token, QueryContext ctx)
focal_class.full_signature: public String resolve(Token token, QueryContext ctx)
focal_class.identifier: resolve
focal_class.modifiers: public
focal_class.parameters: (Token token, QueryContext ctx)
focal_class.return: String
focal_class.signature: String resolve(Token token, QueryContext ctx)
focal_method.body: public String resolve(Token token, QueryContext ctx) {
        if (token.getType() != TokenType.VALUE) {
           throw new DalRuntimeException("Internal error: only VALUE token is supported by " + getClass());
        }
  
        EntityInfo entityInfo = ctx.getEntityInfo();
        StringBuilder sb = new StringBuilder(1024);
        String fieldName = ((SimpleTagToken) token).getAttribute("name", null);
        DataField field = ctx.getEntityInfo().getFieldByName(fieldName);
  
        if (field != null) {
           switch (ctx.getQuery().getType()) {
           case SELECT:
              throw new DalRuntimeException("VALUE token does not support query type: " + ctx.getQuery().getType());
           case INSERT:
              DataObject proto = ctx.getProto();
              Attribute attribute = entityInfo.getAttribute(field);
  
              if (!proto.isFieldUsed(field) && attribute.insertExpr().length() > 0) {
                 sb.append(m_expressionResolver.resolve(ctx, attribute.insertExpr()));
              } else {
                 ctx.addParameter(new Parameter(field));
                 sb.append('?');
              }
  
              break;
           case UPDATE:
              throw new DalRuntimeException("VALUES token does not support query type: " + ctx.getQuery().getType());
           case DELETE:
              throw new DalRuntimeException("VALUES token does not support query type: " + ctx.getQuery().getType());
           default:
              throw new DalRuntimeException("VALUES token does not support query type: " + ctx.getQuery().getType());
           }
        } else {
           throw new DalRuntimeException("DataField(" + fieldName + ") is not defined in "
                 + ctx.getQuery().getEntityClass() + ". Query: " + ctx.getQuery());
        }
  
        return sb.toString();
     }
focal_method.class_method_signature: ValueTokenResolver.resolve(Token token, QueryContext ctx)
focal_method.full_signature: public String resolve(Token token, QueryContext ctx)
focal_method.identifier: resolve
focal_method.invocations: getType getClass getEntityInfo getAttribute getFieldByName getEntityInfo getType getQuery getType getQuery getProto getAttribute isFieldUsed length insertExpr append resolve insertExpr addParameter append getType getQuery getType getQuery getType getQuery getEntityClass getQuery getQuery toString
focal_method.modifiers: public
focal_method.parameters: (Token token, QueryContext ctx)
focal_method.return: String
focal_method.signature: String resolve(Token token, QueryContext ctx)