/** * Returns a 'cleaned' representation of the specified argument. 'Cleaned' is defined as the following: * <p/> * <ol> * <li>If the specified <code>String</code> is <code>null</code>, return <code>null</code></li> * <li>If not <code>null</code>, {@link String#trim() trim()} it.</li> * <li>If the trimmed string is equal to the empty String (i.e. ""), return <code>null</code></li> * <li>If the trimmed string is not the empty string, return the trimmed version</li>. * </ol> * <p/> * Therefore this method always ensures that any given string has trimmed text, and if it doesn't, <code>null</code> * is returned. * * @param in the input String to clean. * @return a populated-but-trimmed String or <code>null</code> otherwise */ public static String clean(String s) { if (s == null) { return null; } String value = trimWhitespace(s); if (value == null || "".equals(value)) { return null; } return value; }
/** * Return the {@link ServletContextClientFactory} implementation class to use, either the default {@link DefaultServletContextClientFactory} * or a custom class if specified. * * @param servletContext current servlet context * @return the WebEnvironment implementation class to use * @see #CLIENT_FACTORY_CLASS_PARAM * @see DefaultServletContextClientFactory */ protected Class<?> determineClientFactoryClass(ServletContext servletContext) { String className = servletContext.getInitParameter(CLIENT_FACTORY_CLASS_PARAM); className = Strings.trimWhitespace(className); if (className != null) { try { return Classes.forName(className); } catch (UnknownClassException ex) { throw new IllegalStateException("Failed to load custom ServletContextClientFactory class [" + className + "]", ex); } } else { return DefaultServletContextClientFactory.class; } }
/** * Return the {@link ConfigFactory} implementation class to use, either the default * {@link com.stormpath.sdk.servlet.config.impl.DefaultConfigFactory} or a custom class if specified. * * @param servletContext current servlet context * @return the ConfigFactory implementation class to use * @see #CONFIG_FACTORY_CLASS_PARAM_NAME * @see com.stormpath.sdk.servlet.config.impl.DefaultConfigFactory */ protected Class<?> determineConfigFactoryClass(ServletContext servletContext) { String className = servletContext.getInitParameter(CONFIG_FACTORY_CLASS_PARAM_NAME); className = Strings.trimWhitespace(className); if (className != null) { try { return Classes.forName(className); } catch (UnknownClassException ex) { throw new IllegalStateException("Failed to load custom ConfigFactory class [" + className + "]", ex); } } else { return DefaultConfigFactory.class; } }
/** * Return the {@link ConfigFactory} implementation class to use, either the default * {@link com.stormpath.sdk.servlet.config.impl.DefaultConfigFactory} or a custom class if specified. * * @param servletContext current servlet context * @return the ConfigFactory implementation class to use * @see #CONFIG_FACTORY_CLASS_PARAM_NAME * @see com.stormpath.sdk.servlet.config.impl.DefaultConfigFactory */ protected Class<?> determineConfigFactoryClass(ServletContext servletContext) { String className = servletContext.getInitParameter(CONFIG_FACTORY_CLASS_PARAM_NAME); className = Strings.trimWhitespace(className); if (className != null) { try { return Classes.forName(className); } catch (UnknownClassException ex) { throw new IllegalStateException("Failed to load custom ConfigFactory class [" + className + "]", ex); } } else { return DefaultConfigFactory.class; } }
/** * Return the {@link com.stormpath.sdk.servlet.application.ApplicationResolver} implementation class to use, either * the default {@link com.stormpath.sdk.servlet.application.DefaultApplicationResolver} or a custom class if * specified. * * @param servletContext current servlet context * @return the ApplicationResolver implementation class to use * @see #APP_RESOLVER_CLASS_PARAM_NAME * @see com.stormpath.sdk.servlet.application.DefaultApplicationResolver */ protected Class<?> determineApplicationResolverClass(ServletContext servletContext) { String className = servletContext.getInitParameter(APP_RESOLVER_CLASS_PARAM_NAME); className = Strings.trimWhitespace(className); if (className != null) { try { return Classes.forName(className); } catch (UnknownClassException ex) { String msg = "Failed to load custom ApplicationResolver class [" + className + "]"; throw new IllegalStateException(msg, ex); } } else { return DefaultApplicationResolver.class; } }
/** * Return the {@link com.stormpath.sdk.servlet.application.ApplicationResolver} implementation class to use, either * the default {@link com.stormpath.sdk.servlet.application.DefaultApplicationResolver} or a custom class if * specified. * * @param servletContext current servlet context * @return the ApplicationResolver implementation class to use * @see #APP_RESOLVER_CLASS_PARAM_NAME * @see com.stormpath.sdk.servlet.application.DefaultApplicationResolver */ protected Class<?> determineApplicationResolverClass(ServletContext servletContext) { String className = servletContext.getInitParameter(APP_RESOLVER_CLASS_PARAM_NAME); className = Strings.trimWhitespace(className); if (className != null) { try { return Classes.forName(className); } catch (UnknownClassException ex) { String msg = "Failed to load custom ApplicationResolver class [" + className + "]"; throw new IllegalStateException(msg, ex); } } else { return DefaultApplicationResolver.class; } }
/** * Return the {@link ServletContextClientFactory} implementation class to use, either the default {@link DefaultServletContextClientFactory} * or a custom class if specified. * * @param servletContext current servlet context * @return the WebEnvironment implementation class to use * @see #CLIENT_FACTORY_CLASS_PARAM * @see DefaultServletContextClientFactory */ protected Class<?> determineClientFactoryClass(ServletContext servletContext) { String className = servletContext.getInitParameter(CLIENT_FACTORY_CLASS_PARAM); className = Strings.trimWhitespace(className); if (className != null) { try { return Classes.forName(className); } catch (UnknownClassException ex) { throw new IllegalStateException("Failed to load custom ServletContextClientFactory class [" + className + "]", ex); } } else { return DefaultServletContextClientFactory.class; } }
@Override public String toEnvVarName(String dottedPropertyName) { Assert.hasText(dottedPropertyName, "dottedPropertyName argument cannot be null or empty."); dottedPropertyName = Strings.trimWhitespace(dottedPropertyName);
@Override public String toEnvVarName(String dottedPropertyName) { Assert.hasText(dottedPropertyName, "dottedPropertyName argument cannot be null or empty."); dottedPropertyName = Strings.trimWhitespace(dottedPropertyName);
@Override public String toDottedPropertyName(String envVarName) { Assert.hasText(envVarName, "envVarName argument cannot be null or empty."); envVarName = Strings.trimWhitespace(envVarName);
@Override public String toDottedPropertyName(String envVarName) { Assert.hasText(envVarName, "envVarName argument cannot be null or empty."); envVarName = Strings.trimWhitespace(envVarName);
line = Strings.trimWhitespace(line); required = true; line = line.substring(0, i); line = Strings.trimWhitespace(line);
line = Strings.trimWhitespace(line); required = true; line = line.substring(0, i); line = Strings.trimWhitespace(line);