当前位置: 首页>>代码示例>>Java>>正文


Java Argument类代码示例

本文整理汇总了Java中org.skife.jdbi.v2.tweak.Argument的典型用法代码示例。如果您正苦于以下问题:Java Argument类的具体用法?Java Argument怎么用?Java Argument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Argument类属于org.skife.jdbi.v2.tweak包,在下文中一共展示了Argument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: locate

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public String locate(final String name, final StatementContext ctx) throws Exception {
    // Rewrite create to createBac, createBin, createBiia, etc.
    if ("create".equals(name)) {
        final Binding binding = ctx.getBinding();
        if (binding != null) {
            final Argument tableNameArgument = binding.forName("tableName");
            if (tableNameArgument != null) {
                // Lame, rely on toString (tableNameArgument will be a org.skife.jdbi.v2.StringArgument)
                final String tableName = CharMatcher.anyOf("'").removeFrom(tableNameArgument.toString());
                final String newQueryName = name + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName);
                return super.locate(newQueryName, ctx);
            }
        }
    }

    // Inspired from org.skife.jdbi.v2.ClasspathStatementLocator to allow real SQL to be executed
    if (looksLikeSql(name)) {
        return name;
    } else {
        return super.locate(name, ctx);
    }
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:24,代码来源:BusinessDBIProvider.java

示例2: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, Value<?> value, StatementContext ctx) {
    if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(jdbcDriver)) {
        return new MsSqlValueArgument(value);
    } else if ("oracle.jdbc.OracleDriver".equals(jdbcDriver)) {
        return new DefaultValueArgument(value, Types.NULL);
    }
    return new DefaultValueArgument(value);
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:10,代码来源:ValueArgumentFactory.java

示例3: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, Option<?> value, StatementContext ctx) {
    if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(jdbcDriver)) {
        return new MsSqlOptionArgument(value);
    } else if ("oracle.jdbc.OracleDriver".equals(jdbcDriver)) {
        return new DefaultOptionArgument(value, Types.NULL);
    }
    return new DefaultOptionArgument(value);
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:10,代码来源:OptionArgumentFactory.java

示例4: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, final LongCollectionSqlType value, StatementContext ctx) {
  return (int position, PreparedStatement statement, StatementContext ctx1) -> {
    try {
      Array sqlArray = ctx1.getConnection().createArrayOf("int", value.getValue().toArray());
      statement.setArray(position, sqlArray);
    } catch (SQLException e) {
      // H2 DB feature not supported: "createArray" error
      if (e.getErrorCode() != 50100) {
        throw e;
      }
      statement.setObject(position, value.getValue().toArray());
    }
  };
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:16,代码来源:LongCollectionSqlTypeArgumentFactory.java

示例5: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, final Collection<String> value, StatementContext ctx) {
  return (int position, PreparedStatement statement, StatementContext ctx1) -> {
    try {
      Array sqlArray = ctx1.getConnection().createArrayOf("text", value.toArray());
      statement.setArray(position, sqlArray);
    } catch (SQLException e) {
      // H2 DB feature not supported: "createArray" error
      if (e.getErrorCode() != 50100) {
        throw e;
      }
      statement.setObject(position, value.toArray());
    }
  };
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:16,代码来源:PostgresArrayArgumentFactory.java

示例6: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, Optional<Object> value, StatementContext ctx) {
    if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(jdbcDriver)) {
        return new MsSqlOptionalArgument(value);
    } else if ("oracle.jdbc.OracleDriver".equals(jdbcDriver)) {
        return new DefaultOptionalArgument(value, Types.NULL);
    }
    return new DefaultOptionalArgument(value);
}
 
开发者ID:dropwizard,项目名称:dropwizard-java8,代码行数:10,代码来源:OptionalArgumentFactory.java

示例7: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, final TenacityConfiguration value, StatementContext ctx) {
    return (position, statement, ctx1) -> {
        try {
            statement.setObject(position, objectMapper.writeValueAsString(value));
        } catch (JsonProcessingException err) {
            LOGGER.warn("Could not write as json: {}", value, err);
            throw new IllegalArgumentException(err);
        }
    };
}
 
开发者ID:yammer,项目名称:breakerbox,代码行数:12,代码来源:TenacityConfigurationArgumentFactory.java

示例8: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(Class<?> expectedType, Object value, StatementContext ctx) {
  if (expectedType.equals(Instant.class)) {
    return new InstantArgument((Instant) value);
  } else if (expectedType.equals(Duration.class)) {
    return new DurationArgument((Duration) value);
  } else {
    return ToStringArgument.of(value);
  }
}
 
开发者ID:robfletcher,项目名称:jdbi-time,代码行数:11,代码来源:TimeTypesArgumentFactory.java

示例9: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(final Class<?> expectedType, final Optional<?> value,
    final StatementContext sctx) {
  return (pos, stmt, ctx) -> {
    if (value.isPresent()) {
      stmt.setObject(pos, value.get());
    } else {
      stmt.setNull(pos, Types.OTHER);
    }
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:12,代码来源:OptionalArgumentFactory.java

示例10: empty

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Test
public void empty() throws Exception {
  new MockUnit(StatementContext.class, PreparedStatement.class)
      .expect(unit -> {
        PreparedStatement stmt = unit.get(PreparedStatement.class);
        stmt.setNull(1, Types.OTHER);
      })
      .run(unit -> {
        Argument arg = new OptionalArgumentFactory()
            .build(Optional.class, Optional.empty(), unit.get(StatementContext.class));
        assertNotNull(arg);
        arg.apply(1, unit.get(PreparedStatement.class), unit.get(StatementContext.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:OptionaArgumentFactoryTest.java

示例11: value

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Test
public void value() throws Exception {
  new MockUnit(StatementContext.class, PreparedStatement.class)
      .expect(unit -> {
        PreparedStatement stmt = unit.get(PreparedStatement.class);
        stmt.setObject(1, "x");
      })
      .run(unit -> {
        Argument arg = new OptionalArgumentFactory()
            .build(Optional.class, Optional.of("x"), unit.get(StatementContext.class));
        assertNotNull(arg);
        arg.apply(1, unit.get(PreparedStatement.class), unit.get(StatementContext.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:OptionaArgumentFactoryTest.java

示例12: build

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Override
public Argument build(final Class<?> expectedType, final SqlArray<?> value, final StatementContext ctx) {
    return (position, statement, ctx1) -> {
        final Array elements = ctx.getConnection().createArrayOf(getTypeName(value), value.getElements());
        statement.setArray(position, elements);
    };
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:8,代码来源:PostgresArrayArgumentFactory.java

示例13: testBuildInteger

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Test
public void testBuildInteger() throws Exception {
    Integer[] intArray = {1, 2, 3};
    List<Integer> ints = Arrays.asList(intArray);
    SqlArray<Integer> value = new SqlArray<>(Integer.class, ints);
    given(connection.createArrayOf("integer", intArray)).willReturn(array);
    Argument result = sut.build(Integer.class, value, ctx);
    result.apply(1, preparedStatement, ctx);
    verify(preparedStatement).setArray(1, array);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:11,代码来源:PostgresArrayArgumentFactoryTest.java

示例14: testBuildLong

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Test
public void testBuildLong() throws Exception {
    Long[] longArray = {1L, 2L, 3L};
    List<Long> longs = Arrays.asList(longArray);
    SqlArray<Long> value = new SqlArray<>(Long.class, longs);
    given(connection.createArrayOf("bigint", longArray)).willReturn(array);
    Argument result = sut.build(Long.class, value, ctx);
    result.apply(1, preparedStatement, ctx);
    verify(preparedStatement).setArray(1, array);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:11,代码来源:PostgresArrayArgumentFactoryTest.java

示例15: testBuildFloat

import org.skife.jdbi.v2.tweak.Argument; //导入依赖的package包/类
@Test
public void testBuildFloat() throws Exception {
    Float[] floatArray = {1.1F, 2.2F, 3.3F};
    List<Float> floats = Arrays.asList(floatArray);
    SqlArray<Float> value = new SqlArray<>(Float.class, floats);
    given(connection.createArrayOf("float4", floatArray)).willReturn(array);
    Argument result = sut.build(Float.class, value, ctx);
    result.apply(1, preparedStatement, ctx);
    verify(preparedStatement).setArray(1, array);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:11,代码来源:PostgresArrayArgumentFactoryTest.java


注:本文中的org.skife.jdbi.v2.tweak.Argument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。