@Override public String toString() { return Strings.join(values," "); } }
public DbSchemaObjectName(String catalog, String schema, String name, boolean quoted) { super(catalog,schema,name); this.quoted = quoted; this.qualifiedName = Strings.join(new String[]{catalog,schema,name},".",true); }
public static String join(Iterable<?> iterable, char separator) { if (iterable == null) { return EMPTY; } return join(iterable.iterator(), separator); }
public static String join(Iterable<?> iterable, String separator) { if (iterable == null) { return EMPTY; } return join(iterable.iterator(), separator); }
private String toPaths(List<File> dirs) { List<String> paths = new ArrayList<>(); for(File dir : dirs) { paths.add(dir.getPath()); } return Strings.join(paths, ","); }
protected String getAuthorizationDenyMessage(Authentication authc, SimpleSecurity[] securities) { StringBuilder s = new StringBuilder(); s.append("Expected one of authorizations [ "); for(int i=0;i<securities.length;i++) { SimpleSecurity sec = securities[i]; if(i > 0) { s.append(" , "); } s.append("("); s.append(" perms: ").append(Strings.join(sec.getPermissions(), ' ')); s.append(", roles: ").append(Strings.join(sec.getRoles(), ' ')); s.append(")"); } s.append(" ], Actual "); s.append("("); s.append("perms: ").append(Strings.join(authc.getPermissions(), ' ')); s.append(", roles: ").append(Strings.join(authc.getRoles(), ' ')); s.append(")"); return s.toString(); }
public static String join(Object[] array,String separator,boolean ignoreEmpty){ if(!ignoreEmpty){ return join(array,separator); } if (array == null) { return EMPTY; } int len = array.length; StringBuilder buf = new StringBuilder(len * 16); int j=0; for (int i = 0; i < len; i++) { Object value = array[i]; if(!Objects2.isEmpty(value)){ if (j > 0 && separator != null) { buf.append(separator); } buf.append(value); j++; } } return buf.toString(); }
@Override public int[] executeBatchUpdate(String... sqls) throws NestedSQLException { if(null == sqls || sqls.length == 0) { return Arrays2.EMPTY_INT_ARRAY; } SqlExecutionContext.setup(SqlExcutionType.Write, Strings.join(sqls, ";")); return executeWithResult((conn) -> { Statement stmt = conn.createStatement(); for(String sql : sqls) { if(Strings.isEmpty(sql)) { throw new IllegalArgumentException("Sql content must not be empty in the sql array"); } stmt.addBatch(sql); } return stmt.executeBatch(); }); }
return prefix + Strings.join(pathElements, UNIX_SEPARATOR_STR);
return Strings.join((Iterable)value,",");
@Override public void process(int rownum, String[] values) throws Exception { if(rownum == 1){ String[] cols = data.cols(); if(null == cols){ data.setCols(values); }else if(!Arrays2.equals(cols, values, true)){ throw new IllegalStateException("Headers in resource '" + resource.getClasspath() + "' should be '" + Strings.join(cols,",")); } return; } String[] cols = data.cols(); if(values.length > cols.length){ throw new IllegalStateException("Column size '" + values.length + "' exceed the header size '" + cols.length + " in row " + rownum + " : " + Strings.join(values,",") + ", check the source : " + resource.getClasspath()); } if(values.length < cols.length){ values = Arrays.copyOf(values, cols.length); } data.addRow(locale,values); } });
public SimpleValidator(String name, boolean required, MetaObjValidated validated) { super(name, required); this.validated = validated; this.formatValidator = null == validated.getResolvedFormat() ? null : new SimpleValidator(name, false, validated.getResolvedFormat()); this.maximum = null == validated.getMaximum() ? null : new BigDecimal(validated.getMaximum().toString()); this.minimum = null == validated.getMinimum() ? null : new BigDecimal(validated.getMinimum().toString()); this.stringEnums = validated.hasEnumValidation() ? Strings.join(validated.getEnums(), ",") : null; }
/** * Returns true if the path allows the authorization. */ @Override public Boolean tryCheckAuthorization(SecurityContextHolder context) { //Check roles if(!checkRoles(context, roles)) { context.setDenyMessage("Roles [" + Strings.join(roles, ',') + "] required"); return false; } //Check permissions if(!checkPermissions(context, permissions)) { context.setDenyMessage("Permissions [" + Strings.join(permissions, ',') + "] required"); return false; } //check secured object SecuredObject so = context.getSecuredObject(); return null == so ? true : so.checkAuthorization(context); }
protected final SqlParserBase expects(Token... tokens) { boolean in = false; for(Token token : tokens){ if (lexer.token() == token) { in = true; break; } } if(!in){ throw new SqlParserException("Syntax error, expect [" + Strings.join(tokens,",") + "], actual " + lexer.token() + " : " + lexer.describePosition()); } return this; }
protected boolean validateString(Validation validation, String name, Object value) { if(validated.hasStringValidation()) { String s = Converts.toString(value); if(null != validated.getMaxLength() && s.length() > validated.getMaxLength()) { validation.addError(name, "The string's length must be <= " + validated.getMaxLength()); return false; } if(null != validated.getMinLength() && s.length() < validated.getMinLength()) { validation.addError(name, "The string's length must be >= " + validated.getMinLength()); return false; } if(null != validated.getEnums() && !Arrays2.contains(validated.getEnums(), s)) { validation.addError(name, "The value must be one of [" + Strings.join(validated.getEnums(), ',') + "]"); return false; } if(null != validated.getPattern()) { if(!validated.getPattern().matcher(value.toString()).matches()){ validation.addError(name, "The value did not matches the pattern!"); return false; } } } return true; }
MetaRelation inverse = target.findRelationByLocalFields(relation.getInverseFields()); if(null == inverse) { throw new IllegalStateException("No inverse relation with local fields[" + Strings.join(relation.getInverseFields(), ',') + "] at target entity '" + target.getName() + "'");
@Override public Boolean tryCheckAuthorization(SecurityContextHolder context) { //Check roles if(!checkRoles(context, route.getRoles())) { context.setDenyMessage("Roles [" + Strings.join(route.getRoles(), ',') + "] required"); return false; } //Check permissions if(!checkPermissions(context, route.getPermissions())) { context.setDenyMessage("Permissions [" + Strings.join(route.getPermissions(), ',') + "] required"); return false; } SimpleSecurity[] securities = context.getSecurities(); if(null != securities && securities.length > 0) { for(SimpleSecurity security : securities) { if(checkPermissions(context, security.getPermissions()) && checkRoles(context, security.getRoles())) { return true; } } context.setDenyMessage(getAuthorizationDenyMessage(context.getAuthentication(), securities)); return false; } return null; }