List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY
String[] EMPTY_STRING_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.
Click Source Link
String
array. From source file:org.sonar.plugins.qualityprofileprogression.server.ProfileProgressedNotificationDispatcher.java
public final String[] getStringArray(String value) { String separator = ","; if (value != null) { String[] strings = StringUtils.splitByWholeSeparator(value, separator); String[] result = new String[strings.length]; for (int index = 0; index < strings.length; index++) { result[index] = StringUtils.trim(strings[index]); }/*w w w.ja v a 2 s .com*/ return result; } return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:org.sonar.scanner.config.DefaultConfiguration.java
@Override public String[] getStringArray(String key) { String effectiveKey = definitions.validKey(key); PropertyDefinition def = definitions.get(effectiveKey); if (def != null && !def.multiValues() && def.fields().isEmpty()) { LOG.warn(/* ww w . j a va2 s . co m*/ "Property '{}' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.", key); } Optional<String> value = getInternal(effectiveKey); if (value.isPresent()) { return parseAsCsv(effectiveKey, value.get()); } return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:org.sonar.scanner.config.DefaultConfiguration.java
public static String[] parseAsCsv(String key, String value) { List<String> result = new ArrayList<>(); try (CSVParser csvParser = CSVFormat.RFC4180.withHeader((String) null).withIgnoreEmptyLines() .withIgnoreSurroundingSpaces().parse(new StringReader(value))) { List<CSVRecord> records = csvParser.getRecords(); if (records.isEmpty()) { return ArrayUtils.EMPTY_STRING_ARRAY; }/*from w ww .j a v a 2 s . c o m*/ processRecords(result, records); return result.toArray(new String[result.size()]); } catch (IOException e) { throw new IllegalStateException( "Property: '" + key + "' doesn't contain a valid CSV value: '" + value + "'", e); } }
From source file:org.springbyexample.mvc.method.annotation.ServiceHandlerMapping.java
/** * Register handler.//from w w w . j a va 2 s.co m */ private void registerHandler(Class<?> marshallingServiceClass, Method method) { ApplicationContext ctx = getApplicationContext(); RestResource restResource = AnnotationUtils.findAnnotation(marshallingServiceClass, RestResource.class); Class<?> serviceClass = restResource.service(); RestRequestResource restRequestResource = AnnotationUtils.findAnnotation(method, RestRequestResource.class); boolean export = (restRequestResource != null ? restRequestResource.export() : true); boolean relative = (restRequestResource != null ? restRequestResource.relative() : true); if (export) { Class<?> handlerServiceClass = serviceClass; String methodName = method.getName(); Class<?>[] paramTypes = method.getParameterTypes(); if (restRequestResource != null) { // explicit service specified if (restRequestResource.service() != ServiceValueConstants.DEFAULT_SERVICE_CLASS) { handlerServiceClass = restRequestResource.service(); } // explicit method name specified if (StringUtils.hasText(restRequestResource.methodName())) { methodName = restRequestResource.methodName(); } } Object handler = ctx.getBean(handlerServiceClass); Method serviceMethod = ClassUtils.getMethod(handlerServiceClass, methodName, paramTypes); RequestMappingInfo mapping = getMappingForMethod(method, marshallingServiceClass); if (relative) { List<String> patterns = new ArrayList<String>(); for (String pattern : mapping.getPatternsCondition().getPatterns()) { // add REST resource path prefix to URI, // if relative path is just '/' add an empty string patterns.add(restResource.path() + (!"/".equals(pattern) ? pattern : "")); } // create a new mapping based on the patterns (patterns are unmodifiable in existing RequestMappingInfo) mapping = new RequestMappingInfo( new PatternsRequestCondition(patterns.toArray(ArrayUtils.EMPTY_STRING_ARRAY), getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(), useTrailingSlashMatch()), mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); } // need to set param types to use in createHandlerMethod before calling registerHandlerMethod restBridgedMethod = BridgeMethodResolver.findBridgedMethod(method); // mapping is key, HandlerMethod is value registerHandlerMethod(handler, serviceMethod, mapping); processConverters(restRequestResource, mapping, serviceMethod); } }
From source file:org.springbyexample.mvc.method.annotation.ServiceHandlerMapping.java
/** * Process and setup any converter handlers if one is configured on <code>RestRequestResource</code>. *///from w w w . ja v a 2 s .c om private void processConverters(RestRequestResource restRequestResource, RequestMappingInfo mapping, Method serviceMethod) { ApplicationContext ctx = getApplicationContext(); Class<?> converterClass = (restRequestResource != null ? restRequestResource.converter() : null); if (converterClass != null && converterClass != ServiceValueConstants.DEFAULT_CONVERTER_CLASS) { @SuppressWarnings("rawtypes") ListConverter converter = (ListConverter) ctx.getBean(converterClass); String[] pathPatterns = mapping.getPatternsCondition().getPatterns() .toArray(ArrayUtils.EMPTY_STRING_ARRAY); String methodSuffix = StringUtils.capitalize(converterHandlerInfo.getPropertyName()); String getterMethodName = "get" + methodSuffix; final String setterMethodName = "set" + methodSuffix; final Class<?> returnTypeClass = serviceMethod.getReturnType(); Method getResultsMethod = ReflectionUtils.findMethod(returnTypeClass, getterMethodName); final Class<?> resultReturnTypeClass = getResultsMethod.getReturnType(); Method setResultsMethod = ReflectionUtils.findMethod(returnTypeClass, setterMethodName, resultReturnTypeClass); final AtomicReference<Method> altSetResultsMethod = new AtomicReference<Method>(); // issue with ReflectionUtils, setterResultsMethod sometimes null from the command line (not getter?) if (setResultsMethod == null) { ReflectionUtils.doWithMethods(returnTypeClass, new MethodCallback() { @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { if (setterMethodName.equals(method.getName())) { altSetResultsMethod.set(method); logger.debug( "Unable to use ReflectionUtils to find setter. returnTypeClass={} method={} resultReturnTypeClass={}", new Object[] { returnTypeClass, method, resultReturnTypeClass }); } } }); } HandlerInterceptor interceptor = new ConverterHandlerInterceptor(converter, returnTypeClass, getResultsMethod, (setResultsMethod != null ? setResultsMethod : altSetResultsMethod.get())); MappedInterceptor mappedInterceptor = new MappedInterceptor(pathPatterns, interceptor); setInterceptors(new Object[] { mappedInterceptor }); logger.info("Registered converter post handler for {} with {}.", pathPatterns, converterClass.getCanonicalName()); } }
From source file:org.tinygroup.commons.tools.CollectionUtil.java
public static String[] toNoNullStringArray(Collection collection) { if (collection == null) { return ArrayUtils.EMPTY_STRING_ARRAY; }//ww w .j a va2 s. c o m return toNoNullStringArray(collection.toArray()); }
From source file:org.tinygroup.commons.tools.CollectionUtil.java
static String[] toNoNullStringArray(Object[] array) { ArrayList list = new ArrayList(array.length); for (int i = 0; i < array.length; i++) { Object e = array[i];//w w w.ja va 2 s . c o m if (e != null) { list.add(e.toString()); } } return (String[]) list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); }
From source file:org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser.java
private String[] getLocalRoles() { if (idp == null || FrameworkConstants.LOCAL.equals(idp)) { RealmService realmService = FrameworkServiceDataHolder.getInstance().getRealmService(); int usersTenantId = IdentityTenantUtil.getTenantId(getWrapped().getTenantDomain()); try {//w w w. j a v a 2 s.com String usernameWithDomain = UserCoreUtil.addDomainToName(getWrapped().getUserName(), getWrapped().getUserStoreDomain()); UserRealm userRealm = realmService.getTenantUserRealm(usersTenantId); return userRealm.getUserStoreManager().getRoleListOfUser(usernameWithDomain); } catch (UserStoreException e) { LOG.error("Error when getting role list of user: " + getWrapped(), e); } } return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:org.wso2.carbon.identity.application.mgt.ui.client.ConditionalAuthMgtClient.java
public String[] listAvailableFunctions() { try {//from ww w .j a v a 2s .c o m return stub.getAllAvailableFunctions(); } catch (RemoteException e) { LOG.error("Error occured when listing conditional authentication functions.", e); } return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:org.wso2.carbon.identity.core.model.SAMLSSOServiceProviderDO.java
/** * @return the requestedClaims/*from w w w.j ava 2 s . c o m*/ */ public String[] getRequestedClaims() { if (requestedClaims != null) { return requestedClaims.clone(); } else { return ArrayUtils.EMPTY_STRING_ARRAY; } }