use of org.rx.core.StringBuilder in project rxlib by RockyLOMO.
the class DataTable method toString.
@Override
public String toString() {
StringBuilder txt = new StringBuilder();
for (DataColumn<?> column : getColumns()) {
txt.append(column.getColumnName()).append("\t");
}
txt.appendLine();
Iterator<DataRow> rows = getRows();
while (rows.hasNext()) {
for (Object item : rows.next().items) {
txt.append(item).append("\t");
}
txt.appendLine();
}
return txt.toString();
}
use of org.rx.core.StringBuilder in project rxlib by RockyLOMO.
the class EntityQueryLambda method resolve.
static <T> String resolve(ArrayList<BiTuple<Serializable, Operator, ?>> conditions, List<Object> params, List<Tuple<BiFunc<T, ?>, Order>> orders, boolean autoUnderscoreColumnName, Integer limit, Integer offset) {
StringBuilder b = new StringBuilder(128);
boolean isParam = params != null;
for (BiTuple<Serializable, Operator, ?> condition : conditions) {
Operator op = condition.middle;
switch(op) {
case EQ:
case NE:
case GT:
case LT:
case GE:
case LE:
case LIKE:
case NOT_LIKE:
{
String colName = resolveColumnName(condition.left, autoUnderscoreColumnName);
if (!b.isEmpty()) {
b.append(OP_AND);
}
String valHold;
if (isParam) {
params.add(condition.right);
valHold = PARAM_HOLD;
} else {
valHold = toValueString(condition.right);
}
b.append(op.format, colName, valHold);
}
break;
case IN:
case NOT_IN:
{
String colName = resolveColumnName(condition.left, autoUnderscoreColumnName);
if (!b.isEmpty()) {
b.append(OP_AND);
}
String valHold;
if (isParam) {
params.add(condition.right);
valHold = PARAM_HOLD;
} else {
valHold = NQuery.of((Object[]) condition.right).toJoinString(",", EntityQueryLambda::toValueString);
}
b.append(op.format, colName, valHold);
}
break;
case BETWEEN:
case NOT_BETWEEN:
{
String colName = resolveColumnName(condition.left, autoUnderscoreColumnName);
Object[] p = (Object[]) condition.right;
if (!b.isEmpty()) {
b.append(OP_AND);
}
String valHold0, valHold1;
if (isParam) {
params.add(p[0]);
params.add(p[1]);
valHold0 = PARAM_HOLD;
valHold1 = PARAM_HOLD;
} else {
valHold0 = toValueString(p[0]);
valHold1 = toValueString(p[1]);
}
b.append(op.format, colName, valHold0, valHold1);
}
break;
case AND:
case OR:
ArrayList<BiTuple<Serializable, Operator, ?>> l = (ArrayList<BiTuple<Serializable, Operator, ?>>) condition.left;
EntityQueryLambda<T> r = (EntityQueryLambda<T>) condition.right;
if (!b.isEmpty()) {
b.append(OP_AND);
}
b.append(op.format, resolve(l, params, null, autoUnderscoreColumnName, limit, offset), r.toString(params));
break;
}
}
if (!CollectionUtils.isEmpty(orders)) {
b.append(ORDER_BY);
for (Tuple<BiFunc<T, ?>, Order> bi : orders) {
String colName = resolveColumnName(bi.left, autoUnderscoreColumnName);
b.append("%s %s,", colName, bi.right);
}
b.setLength(b.length() - 1);
}
if (limit != null) {
b.append(LIMIT);
if (offset != null) {
b.append("%s,", offset);
}
b.append(limit);
}
return b.toString();
}
use of org.rx.core.StringBuilder in project rxlib by RockyLOMO.
the class Files method concatPath.
public static String concatPath(@NonNull String root, String... paths) {
StringBuilder p = new StringBuilder(CURD_FILE.padDirectoryPath(root));
if (!Arrays.isEmpty(paths)) {
int l = paths.length - 1;
for (int i = 0; i < l; i++) {
p.append(CURD_FILE.padDirectoryPath(paths[i]));
}
p.append(paths[l]);
}
return p.toString();
}
use of org.rx.core.StringBuilder in project rxlib by RockyLOMO.
the class IOStream method readString.
@SneakyThrows
public static String readString(@NonNull InputStream in, Charset charset) {
if (charset == null) {
charset = StandardCharsets.UTF_8;
}
StringBuilder result = new StringBuilder();
byte[] buffer = Bytes.arrayBuffer();
int read;
while ((read = in.read(buffer)) > 0) {
result.append(new String(buffer, 0, read, charset));
}
return result.toString();
}
use of org.rx.core.StringBuilder in project rxlib by RockyLOMO.
the class AuthenticEndpoint method toString.
@Override
public String toString() {
StringBuilder s = new StringBuilder();
if (!Strings.isEmpty(username)) {
s.append(username);
}
if (!Strings.isEmpty(password)) {
s.append(":%s", password);
}
s.append("@%s", Sockets.toString(endpoint));
if (!MapUtils.isEmpty(parameters)) {
s.append(HttpClient.buildUrl(null, (Map) parameters));
}
return s.toString();
}
Aggregations