public List<Integer> getItemTypeIds(Integer tenantId, Boolean visible) {
Preconditions.checkNotNull(tenantId, "missing constraints: missing 'tenantId'");
Object[] args = new Object[]{tenantId};
int[] argTypes = new int[]{Types.INTEGER};
StringBuilder sqlString = new StringBuilder("SELECT ");
sqlString.append(DEFAULT_ID_COLUMN_NAME);
sqlString.append(" FROM ");
sqlString.append(DEFAULT_TABLE_NAME);
sqlString.append(" WHERE ");
sqlString.append(DEFAULT_TENANT_COLUMN_NAME);
sqlString.append(" =?");
if (visible != null) {
sqlString.append(" AND ").append(DEFAULT_VISIBLE_COLUMN_NAME).append("=?");
args = ObjectArrays.concat(args, visible);
argTypes = Ints.concat(argTypes, new int[]{Types.BIT});
}
return getJdbcTemplate().queryForList(sqlString.toString(), args, argTypes, Integer.class);
}
java类com.google.common.collect.ObjectArrays的实例源码
ProfiledItemTypeDAOMysqlImpl.java 文件源码
项目:easyrec-PoC
阅读 29
收藏 0
点赞 0
评论 0
DynamicClassLoader.java 文件源码
项目:shaf
阅读 36
收藏 0
点赞 0
评论 0
/**
* Find the class for the specified name by using dynamic repository.
*/
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
try {
return Class.forName(name);
} catch (ClassNotFoundException exc1) {
URLClassLoader loader = newInstance(ObjectArrays.concat(
this.getURLs(),
this.urls.toArray(new URL[this.urls.size()]), URL.class),
this.getParent());
Class<?> cls = loader.loadClass(name);
try {
loader.close();
} catch (IOException exc2) {
LOG.error("Failed to close the URL class loader.", exc2);
}
return cls;
}
}
ExtractFragFunction.java 文件源码
项目:shaf
阅读 17
收藏 0
点赞 0
评论 0
/**
* Returns the fragment of text, which is matching the specified pattern,
* otherwise {@code null}.
*/
@Override
public String[] translate(String str) throws Exception {
Matcher matcher = super.pattern.matcher(str);
String[] fragments = new String[0];
while (matcher.find()) {
fragments = ObjectArrays.concat(fragments,
str.substring(matcher.start(), matcher.end()));
}
if (fragments.length > 0) {
return fragments;
} else {
return null;
}
}
LatestActionDAOMysqlImpl.java 文件源码
项目:easyrec
阅读 23
收藏 0
点赞 0
评论 0
public int getLatestRatingPageCount(int tenantId, int itemTypeId, Date since) {
final StringBuilder query = new StringBuilder("SELECT CEIL(count(*) / ?)");
query.append("\n");
query.append("FROM ").append(DEFAULT_TABLE_NAME).append("\n");
query.append("WHERE ");
query.append(DEFAULT_TENANT_COLUMN_NAME).append(" = ? AND ");
query.append(DEFAULT_ITEM_TYPE_COLUMN_NAME).append(" = ?");
Object[] args = new Object[]{PAGE_SIZE, tenantId, itemTypeId};
int[] argt = new int[]{Types.INTEGER, Types.INTEGER, Types.INTEGER};
if (since != null) {
query.append(" AND ").append(DEFAULT_ACTION_TIME_COLUMN_NAME).append(" > ?");
args = ObjectArrays.concat(args, since);
argt = Ints.concat(argt, new int[]{Types.TIMESTAMP});
}
int count = getJdbcTemplate().queryForInt(query.toString(), args, argt);
return count;
}
AbstractBaseRecommendationDAOMysqlImpl.java 文件源码
项目:easyrec
阅读 23
收藏 0
点赞 0
评论 0
protected String getRecommendationIteratorQueryString(TimeConstraintVO timeConstraints, ArgsAndTypesHolder holder) {
StringBuilder query = new StringBuilder("SELECT * FROM ");
query.append(DEFAULT_TABLE_NAME);
if (timeConstraints.getDateFrom() != null) {
query.append(" WHERE ");
query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
query.append(" >= ?");
holder.getArgs()[0] = timeConstraints.getDateFrom();
if (timeConstraints.getDateTo() != null) {
query.append(" AND ");
query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
query.append(" <= ?");
holder.setArgs(ObjectArrays.concat(holder.getArgs(), timeConstraints.getDateTo()));
holder.setArgTypes(Ints.concat(holder.getArgTypes(), new int[] { Types.TIMESTAMP }));
}
} else {
query.append(" WHERE ");
query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
query.append(" <= ?");
holder.getArgs()[0] = timeConstraints.getDateTo();
}
return query.toString();
}
ProfiledItemTypeDAOMysqlImpl.java 文件源码
项目:easyrec
阅读 19
收藏 0
点赞 0
评论 0
public List<Integer> getItemTypeIds(Integer tenantId, Boolean visible) {
Preconditions.checkNotNull(tenantId, "missing constraints: missing 'tenantId'");
Object[] args = new Object[]{tenantId};
int[] argTypes = new int[]{Types.INTEGER};
StringBuilder sqlString = new StringBuilder("SELECT ");
sqlString.append(DEFAULT_ID_COLUMN_NAME);
sqlString.append(" FROM ");
sqlString.append(DEFAULT_TABLE_NAME);
sqlString.append(" WHERE ");
sqlString.append(DEFAULT_TENANT_COLUMN_NAME);
sqlString.append(" =?");
if (visible != null) {
sqlString.append(" AND ").append(DEFAULT_VISIBLE_COLUMN_NAME).append("=?");
args = ObjectArrays.concat(args, visible);
argTypes = Ints.concat(argTypes, new int[]{Types.BIT});
}
return getJdbcTemplate().queryForList(sqlString.toString(), args, argTypes, Integer.class);
}
SimpleTimeLimiter.java 文件源码
项目:cnGuava
阅读 23
收藏 0
点赞 0
评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces)
throws Exception {
Throwable cause = e.getCause();
if (cause == null) {
throw e;
}
if (combineStackTraces) {
StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(),
e.getStackTrace(), StackTraceElement.class);
cause.setStackTrace(combined);
}
if (cause instanceof Exception) {
throw (Exception) cause;
}
if (cause instanceof Error) {
throw (Error) cause;
}
// The cause is a weird kind of Throwable, so throw the outer exception.
throw e;
}
MeldReader.java 文件源码
项目:jrecon
阅读 23
收藏 0
点赞 0
评论 0
protected <T> T[] readSignal(Class<T> t, OffsetLength offsetLength) throws ReconException {
if (offsetLength.getOffset() == 0 || offsetLength.getLength() == 0) {
throw new ReconException("Cannot read signal as offset and length invalid " + offsetLength);
}
try {
byte[] bytes = new byte[offsetLength.getLength()];
if (offsetLength.getLength() == resource.read(offsetLength.getOffset(), bytes)) {
if (isCompressed()) {
bytes = Compression.decompress(bytes);
}
BufferUnpacker unpacker = getMessagePack().createBufferUnpacker(bytes);
int arrayLength = unpacker.readArrayBegin();
T[] out = ObjectArrays.newArray(t, arrayLength);
for (int i = 0; i < arrayLength; i++) {
out[i] = (T) readObject(unpacker);
}
unpacker.readArrayEnd();
unpacker.close();
return out;
}
throw new ReconException("Failed to read signal at location");
} catch (IOException ex) {
throw new ReconException("Failed to read signal", ex);
}
}
SimpleTimeLimiter.java 文件源码
项目:org.openntf.domino
阅读 24
收藏 0
点赞 0
评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces)
throws Exception {
Throwable cause = e.getCause();
if (cause == null) {
throw e;
}
if (combineStackTraces) {
StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(),
e.getStackTrace(), StackTraceElement.class);
cause.setStackTrace(combined);
}
if (cause instanceof Exception) {
throw (Exception) cause;
}
if (cause instanceof Error) {
throw (Error) cause;
}
// The cause is a weird kind of Throwable, so throw the outer exception.
throw e;
}
AndSpec.java 文件源码
项目:Reer
阅读 23
收藏 0
点赞 0
评论 0
public AndSpec<T> and(Spec<? super T>... specs) {
if (specs.length == 0) {
return this;
}
Spec<? super T>[] thisSpecs = getSpecsArray();
int thisLength = thisSpecs.length;
if (thisLength == 0) {
return new AndSpec<T>(specs);
}
Spec<? super T>[] combinedSpecs = uncheckedCast(ObjectArrays.newArray(Spec.class, thisLength + specs.length));
System.arraycopy(thisSpecs, 0, combinedSpecs, 0, thisLength);
System.arraycopy(specs, 0, combinedSpecs, thisLength, specs.length);
return new AndSpec<T>(combinedSpecs);
}