public String[] resolveMessageCodes( String errorCode, String objectName, String field, Class<?> fieldType) { List<String> codeList = new ArrayList<String>(); List<String> fieldList = new ArrayList<String>(); buildFieldList(field, fieldList); for (String fieldInList : fieldList) { if (StringUtils.hasText(fieldInList)) { codeList.add( postProcessMessageCode( objectName + CODE_SEPARATOR + fieldInList + CODE_SEPARATOR + errorCode)); } else { codeList.add(postProcessMessageCode(objectName + CODE_SEPARATOR + errorCode)); } } int dotIndex = field.lastIndexOf('.'); if (dotIndex != -1) { buildFieldList(field.substring(dotIndex + 1), fieldList); } for (String fieldInList : fieldList) { if (StringUtils.hasText(fieldInList)) { codeList.add(postProcessMessageCode(fieldInList + CODE_SEPARATOR + errorCode)); } } if (fieldType != null) { codeList.add(postProcessMessageCode(fieldType.getName() + CODE_SEPARATOR + errorCode)); } codeList.add(postProcessMessageCode(errorCode)); return StringUtils.toStringArray(codeList); }
/** * Check and prepare the given request and response according to the settings of this generator. * Checks for supported methods and a required session, and applies the given number of cache * seconds. * * @param request current HTTP request * @param response current HTTP response * @param cacheSeconds positive number of seconds into the future that the response should be * cacheable for, 0 to prevent caching * @param lastModified if the mapped handler provides Last-Modified support * @throws ServletException if the request cannot be handled because a check failed */ protected final void checkAndPrepare( HttpServletRequest request, HttpServletResponse response, int cacheSeconds, boolean lastModified) throws ServletException { // Check whether we should support the request method. String method = request.getMethod(); if (this.supportedMethods != null && !this.supportedMethods.contains(method)) { throw new HttpRequestMethodNotSupportedException( method, StringUtils.toStringArray(this.supportedMethods)); } // Check whether a session is required. if (this.requireSession) { if (request.getSession(false) == null) { throw new HttpSessionRequiredException("Pre-existing session required but none found"); } } // Do declarative cache control. // Revalidate if the controller supports last-modified. applyCacheSeconds(response, cacheSeconds, lastModified); }
private static String[] processActiveProfiles(String[] activeProfiles) { if (activeProfiles == null) { return EMPTY_STRING_ARRAY; } // Active profiles must be unique Set<String> profilesSet = new LinkedHashSet<>(Arrays.asList(activeProfiles)); return StringUtils.toStringArray(profilesSet); }
/** * Check name and aliases of the given bean for URLs, detected by starting with "/". * * <p><strong>Copied from BeanNameUrlHandlerMapping</strong> */ private String[] checkForUrl(String beanName) { List<String> urls = new ArrayList<String>(); if (isMapping(beanName)) { urls.add(beanName); } String[] aliases = getApplicationContext().getAliases(beanName); for (String alias : aliases) { if (isMapping(alias)) { urls.add(alias); } } return StringUtils.toStringArray(urls); }
/** * Parse the given property name into the corresponding property name tokens. * * @param propertyName the property name to parse * @return representation of the parsed property tokens */ private PropertyTokenHolder getPropertyNameTokens(String propertyName) { PropertyTokenHolder tokens = new PropertyTokenHolder(); String actualName = null; List<String> keys = new ArrayList<String>(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); searchIndex = -1; if (keyStart != -1) { int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length()); if (keyEnd != -1) { if (actualName == null) { actualName = propertyName.substring(0, keyStart); } String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd); if ((key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) { key = key.substring(1, key.length() - 1); } keys.add(key); searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length(); } } } tokens.actualName = (actualName != null ? actualName : propertyName); tokens.canonicalName = tokens.actualName; if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString( keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys); } return tokens; }
public String[] getAttributeNames(int scope) { return StringUtils.toStringArray(getAttributeMap(scope).entrySet()); }
/** Return the HTTP methods that this content generator supports. */ public final String[] getSupportedMethods() { return StringUtils.toStringArray(this.supportedMethods); }
@Override public String[] getPropertyNames() { return StringUtils.toStringArray(this.source.getInitParameterNames()); }