@Nonnull
@Syntax("SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName)
{
if(isValue)
{
if(data != null && data.getClass().isArray())
{
if(((Object[])data).length == 0)
{
//Matching item to empty list is not supported by SQL
return "(NULL)";
}
//see: https://stackoverflow.com/questions/178479/preparedstatement-in-clause-alternatives
return "("+Arrays.stream( (Object[])data).map( (final Object o) -> "?").collect( Collectors.joining( ", "))+")";
}
return "?";
}
if(data instanceof SQLFunction)
{
return ((SQLFunction)data).toSQL( driver, tableName );
}
return (String)(tableName != null ? tableName + "." + data : data);
}
java类javax.annotation.Syntax的实例源码
SimpleCondition.java 文件源码
项目:jactiverecord
阅读 23
收藏 0
点赞 0
评论 0
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 43
收藏 0
点赞 0
评论 0
/**
* NOTE: If the specified {@link IndexType} is not supported by the driver,
* fallback to the {@link IndexType#DEFAULT default} index-type is allowed
*
* @param indexType the index-type to translate to driver-specific keyword
* @return the keyword for the given index-type
* @since 0.6
*/
@Nonnull
@Syntax(value = "SQL")
public String getIndexKeyword(@Nonnull final IndexType indexType)
{
switch(indexType)
{
case DEFAULT:
return "";
case UNIQUE:
return "UNIQUE";
case CLUSTERED:
return "CLUSTERED";
default:
throw new AssertionError( indexType.name() );
}
}
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 32
收藏 0
点赞 0
评论 0
/**
* @param offset the offset to start at
* @param limit the maximum number of results
* @return the SQL-clause to limit the amount of retrieved results
*/
@Nonnull
@Syntax(value = "SQL")
public String getLimitClause(@Nonnegative final int offset, @Signed final int limit)
{
return (offset > 0 ? "OFFSET " + offset + " " : "") + (limit > 0 ? "FETCH FIRST " + limit + " ROWS ONLY" : "");
}
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 29
收藏 0
点赞 0
评论 0
/**
* @param sqlFunction the SQL-function to apply
* @param column the column to aggregate
* @return the SQL function for the given column
*/
@Nonnull
@Syntax(value = "SQL")
public String getSQLFunction(@Nonnull final String sqlFunction, @Nonnull final String column)
{
return sqlFunction.replaceAll( "%column%", column);
}
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 35
收藏 0
点赞 0
评论 0
/**
* For the default-implementation, see: https://en.wikibooks.org/wiki/SQL_Dialects_Reference/Data_structure_definition/Auto-increment_column
*
* @param primaryKeyKeywords the previously set keywords
* @return the keywords for an auto-incremental primary-key column
*/
@Nonnull
@Syntax(value = "SQL")
public String getPrimaryKeyKeywords(@Nonnull final String primaryKeyKeywords)
{
return primaryKeyKeywords + " GENERATED ALWAYS AS IDENTITY PRIMARY KEY";
}
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 30
收藏 0
点赞 0
评论 0
/**
* The default implementation provides a 4kB string-column
*
* @return the default data-type for strings
*/
@Nonnull
@Syntax(value = "SQL")
public String getStringDataType()
{
return "VARCHAR("+JDBCDriver.STRING_TYPE_LENGTH+")";
}
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 30
收藏 0
点赞 0
评论 0
/**
* The default implementation inserts a <code>NULL</code>-value for the <code>primaryColumn</code>
*
* @param primaryColumn the primaryColumn
* @return the columns-and-values string for an empty row
*/
@Nonnull
@Syntax(value = "SQL")
public String getInsertDataForEmptyRow(@Nonnull final String primaryColumn)
{
return "(" + primaryColumn + ") VALUES (NULL)";
}
CodecJackson.java 文件源码
项目:codec
阅读 40
收藏 0
点赞 0
评论 0
/**
* Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
* {@link #decodeObject(String, Config)} with the resultant config and the passed in category. Pretty much just
* a convenience function for simple use cases that don't want to care about how ConfigFactory works.
*/
public <T> T decodeObject(@Nonnull String category, @Syntax("HOCON") String configText)
throws JsonProcessingException, IOException {
PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
"could not find anything about the category %s", category);
Config config = ConfigFactory.parseString(configText).resolve();
return (T) decodeObject(pluginMap.baseClass(), config);
}
CodecJackson.java 文件源码
项目:codec
阅读 42
收藏 0
点赞 0
评论 0
/**
* Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
* {@link #decodeObject(Class, Config)} with the resultant config and the passed in type. Pretty much just
* a convenience function for simple use cases that don't want to care about how ConfigFactory works.
*/
public <T> T decodeObject(@Nonnull Class<T> type, @Syntax("HOCON") String configText)
throws JsonProcessingException, IOException {
Config config = ConfigFactory.parseString(configText).resolve();
return decodeObject(type, config);
}
CodecJackson.java 文件源码
项目:codec
阅读 39
收藏 0
点赞 0
评论 0
public <T> T decodeObject(@Nonnull TypeReference<T> type, @Syntax("HOCON") String configText)
throws JsonProcessingException, IOException {
Config config = ConfigFactory.parseString(configText).resolve();
return decodeObject(type, config);
}
ValueFactory.java 文件源码
项目:bundle
阅读 46
收藏 0
点赞 0
评论 0
public static ValueMap decodeMap(@Syntax("HOCON") String config) throws IOException {
return Configs.decodeObject(ValueMap.class, config);
}
MapBundle.java 文件源码
项目:bundle
阅读 41
收藏 0
点赞 0
评论 0
public static MapBundle decode(@Syntax("HOCON") String config) throws IOException {
return Configs.decodeObject(MapBundle.class, config);
}
Bundles.java 文件源码
项目:bundle
阅读 85
收藏 0
点赞 0
评论 0
@Scaling(SETUP)
public static Bundle decode(@Syntax("HOCON") String config) throws IOException {
return Configs.decodeObject(Bundle.class, config);
}
Order.java 文件源码
项目:jactiverecord
阅读 40
收藏 0
点赞 0
评论 0
/**
* @param driver the driver for the underlying RDBMS
* @param tableName the name to use to uniquely identify the table
* @return a SQL representation of this Order
*/
@Syntax(value = "SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName);
SQLFunction.java 文件源码
项目:jactiverecord
阅读 34
收藏 0
点赞 0
评论 0
/**
* @param driver the driver to be used for vendor-specific commands
* @param tableName the name of the table to apply this function to
* @return the SQL representation of this function
*/
@Nonnull
@Syntax(value = "SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName);
Condition.java 文件源码
项目:jactiverecord
阅读 36
收藏 0
点赞 0
评论 0
/**
* @param driver the vendor-specific driver
* @param tableName the name to use to uniquely identify the table
* @return the SQL representation of this condition
*/
@Nonnull
@Syntax(value = "SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName);
SimpleOrder.java 文件源码
项目:jactiverecord
阅读 32
收藏 0
点赞 0
评论 0
/**
* @return the SQL-representation of this order
*/
@Syntax(value = "SQL")
public abstract String toSQL();
Configs.java 文件源码
项目:codec
阅读 41
收藏 0
点赞 0
评论 0
/**
* Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
* {@link #decodeObject(Class, Config)} with the resultant config and the passed in type. Pretty much just
* a convenience function for simple use cases that don't want to care about how ConfigFactory works.
*/
public static <T> T decodeObject(@Nonnull Class<T> type, @Syntax("HOCON") @Nonnull String configText)
throws IOException {
return Jackson.defaultCodec().decodeObject(type, configText);
}
Configs.java 文件源码
项目:codec
阅读 27
收藏 0
点赞 0
评论 0
/**
* Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
* {@link #decodeObject(TypeReference, Config)} with the resultant config and the passed in type. Pretty much just
* a convenience function for simple use cases that don't want to care about how ConfigFactory works.
*/
public static <T> T decodeObject(@Nonnull TypeReference<T> type, @Syntax("HOCON") @Nonnull String configText)
throws IOException {
return Jackson.defaultCodec().decodeObject(type, configText);
}
Configs.java 文件源码
项目:codec
阅读 42
收藏 0
点赞 0
评论 0
/**
* Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
* {@link #decodeObject(String, Config)} with the resultant config and the passed in category. Pretty much just
* a convenience function for simple use cases that don't want to care about how ConfigFactory works.
*/
public static <T> T decodeObject(@Nonnull String category, @Syntax("HOCON") @Nonnull String configText)
throws IOException {
return Jackson.defaultCodec().decodeObject(category, configText);
}
Configs.java 文件源码
项目:codec
阅读 44
收藏 0
点赞 0
评论 0
/**
* Instantiate an object without a compile time expected type. This expects a config of the
* form "{plugin-category: {...}}". ie. there should be exactly one top level key and that
* key should be a valid, loaded, plug-in category.
*/
public static <T> T decodeObject(@Syntax("HOCON") String configText) throws IOException {
return Jackson.defaultCodec().decodeObject(configText);
}
CodecJackson.java 文件源码
项目:codec
阅读 32
收藏 0
点赞 0
评论 0
/**
* Instantiate an object without a compile time expected type. This expects a config of the
* form "{plugin-category: {...}}". ie. there should be exactly one top level key and that
* key should be a valid, loaded, plug-in category.
*/
public <T> T decodeObject(@Syntax("HOCON") String configText) throws JsonProcessingException, IOException {
Config config = ConfigFactory.parseString(configText).resolve();
return decodeObject(config);
}