public SimpleSqlFragment(Object source, String content) { this.source = source; this.content = Strings.trim(content); }
@Override public CriteriaQuery<T> where(String expression) { Args.notEmpty(expression = Strings.trim(expression), "where expression"); where = expression; return this; }
@Override public final String getElementTextAndEnd() { String text = doGetElementTextAndEnd(); return trimAll ? Strings.trim(text) : text; }
public String toSql() { StringBuilder sb = new StringBuilder(); for(int i=0;i<nodes.length;i++){ nodes[i].toSql(sb); } return Strings.trim(sb.toString()); }
@Override public String getAttributeOrNull(String localName) { String value = doGetAttribute(localName); return null == value ? null : (trimAll ? Strings.trim(value) : value); }
public String resolveDynamicSql(SqlContext context, Params params) throws IOException { StringBuilder sb = new StringBuilder(); for(int i=0;i<nodes.length;i++) { nodes[i].resolveDynamic(context, this, sb, params); } return Strings.trim(sb.toString()); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for(int i=0;i<nodes.length;i++){ nodes[i].toString(sb); } return Strings.trim(sb.toString()); }
@Override public final String getAttribute(QName name) { String value = doGetAttribute(name); return trimAll ? Strings.trim(value) : value; }
@Override public final String getAttribute(String localName) { String value = doGetAttribute(localName); return trimAll ? Strings.trim(value) : value; }
public String getAttributeOrNull(QName name) { String value = doGetAttribute(name); return null == value ? null : (trimAll ? Strings.trim(value) : value); }
public static <T> T get(Properties properties,String key,Class<T> targetType, T defaultValue) { if(null == properties || null == key){ return defaultValue; } String value = properties.getProperty(key); if(null == value || Strings.isEmpty((value = Strings.trim(value)))){ return defaultValue; } return Converts.convert(value, targetType); }
@Override public CriteriaQuery<T> where(String expression, Object... args) { Args.notEmpty(expression = Strings.trim(expression), "where expression"); where = expression; if (null != args && args.length > 0) { if (args.length == 1 && args[0] instanceof ArrayParams) { this.whereParameters = (ArrayParams) args[0]; } else { this.whereParameters = new ArrayParams(args); } } return this; }
public static void parse(MetaSecurity security, String expr) { expr = Strings.trim(expr); if(Strings.isEmpty(expr)) { return; } String[] rules = Strings.split(expr, '|'); if(rules.length > 2) { throw new IllegalStateException("Invalid security expr '" + expr + "'"); } for(String rule : rules) { parseRule(security, rule); } }
@Override protected final void buildStatement_(SqlContext context, Sql sql, SqlStatementBuilder stm, Params params) throws IOException { if(null != processor) { String expr = Strings.trim(processor.processTag(context, sql, this, params)); if(!Strings.isEmpty(expr)) { buildStatement(context, sql, stm, params, expr); } } }
public static Sql parse(String text) { Args.notEmpty(text,"sql text"); return new SqlParser(new Lexer(Strings.trim(text))).sql(); }
public static List<Sql> parseAll(String text) { Args.notEmpty(text,"sql text"); return new SqlParser(new Lexer(Strings.trim(text))).sqls(); }
public static SqlOrderBy parseOrderBy(String orderByExpression) { Args.notEmpty(orderByExpression,"orderByExpression"); return new SqlParser(new Lexer(Strings.trim(orderByExpression)),null).orderBy(); }
private boolean parseOperation(MetaApi api, MetaOperation op, String content) { OperationParser parser = new OperationParser(content, api, op); parser.parseComment(); if (parser.isIgnore()) { return false; } op.setScript(Strings.trim(parser.rest())); Boolean implemented = parser.getProperty(OperationParser.PROP_IMPLEMENTED); if (Boolean.TRUE.equals(implemented)) { op.setPrior(true); } return true; }
protected void writeOAuth2Scopes(WriteContext context, ApiMetadata m, JsonWriter w, MOAuth2ApiSecurityDef d, MApiPermission[] scopes) { w.property(SCOPES, () -> { w.startObject(); if(null != scopes) { for (MApiPermission scope : scopes) { w.property(scope.getValue(), Strings.trim(scope.getDescription())); } } w.endObject(); }); }
protected String generateOrGetKeyFileContent(){ FileResource userDir = Resources.createFileResource(System.getProperty("user.dir")); FileResource targetDir = userDir.createRelative("./target"); File keyFile = targetDir.exists() ? targetDir.createRelative("./.rsa_key").getFile() : userDir.createRelative("./.rsa_key").getFile(); if(keyFile.exists()){ String keyContent = Strings.trim(IO.readString(keyFile, Charsets.UTF_8)); if(Strings.isEmpty(keyContent)){ keyContent = writeKeyContent(keyFile); } return keyContent; } return writeKeyContent(keyFile); }