List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:gemlite.core.util.CommandBase.java
/** * /*from w w w. j ava 2 s . c o m*/ * * @param f * @return */ protected String setValue(CmdField f) { Object value = null; f.field.setAccessible(true); try { f.field.set(this, ""); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return StringUtils.trim("" + value); }
From source file:hydrograph.ui.joblogger.JobLogger.java
/** * /* w ww. j a v a2 s. c om*/ * log message * * @param message */ public void logMessage(String message) { for (AbstractJobLogger jobLogger : loggers) { if (StringUtils.isNotBlank(message)) { message = StringUtils.trim(message); jobLogger.log(message); } logger.debug("Logged message {} on {}", message, jobLogger.getClass().getName()); } }
From source file:jp.ikedam.jenkins.plugins.ldap_sasl.SearchGroupResolver.java
/** * Constructor instantiating with parameters in the configuration page. * //from w w w. ja va 2 s .c o m * When instantiating from the saved configuration, * the object is directly serialized with XStream, * and no constructor is used. * * @param searchBase the base DN to search for groups. * @param prefix the prefix added to the Jenkins group name */ @DataBoundConstructor public SearchGroupResolver(String searchBase, String prefix) { this.searchBase = StringUtils.trim(searchBase); this.prefix = StringUtils.trim(prefix); }
From source file:com.doculibre.constellio.entities.Record.java
/** * Convenience method/*from w ww . j ava2 s . co m*/ * * @return */ @Transient public String getDisplayTitle() { List<RecordMeta> titleMetas = getMetas(SpiConstants.PROPNAME_TITLE); if (titleMetas.isEmpty()) { // Just in case... titleMetas = getMetas("title"); } if (!titleMetas.isEmpty()) { RecordMeta meta = titleMetas.get(0); if (meta != null) { return StringUtils.trim(meta.getContent()); } } return null; }
From source file:com.edgenius.wiki.PageTheme.java
public String getWelcome() { return StringUtils.trim(welcome); }
From source file:com.leacox.pusher.Pusher.java
/** * Delivers a message to the Pusher API//from w w w. j a va2 s.c o m */ @Override public String triggerPush(String channel, String event, String jsonData, String socketId) { if (log.isDebugEnabled()) log.debug(String.format("Sending pusher.com push to channel %s with event %s and socketId %s", channel, event, socketId)); try { // Build URI path String uriPath = buildURIPath(channel); // Build query String query = buildQuery(event, jsonData, socketId); // Generate signature String signature = buildAuthenticationSignature(uriPath, query); // Build URI String url = buildURI(uriPath, query, signature); DefaultHttpClient httpClient = new DefaultHttpClient(); if (proxyAutodetector != null) { proxyAutodetector.setProxyForHttpClient(httpClient, url); } HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Content-Type", "application/json"); httpPost.setEntity(new StringEntity(jsonData)); org.apache.http.HttpResponse httpResponse = httpClient.execute(httpPost); log.info(String.format("Sent pusher.com event and got back response '%s'.", httpResponse.getStatusLine())); if (!((httpResponse.getStatusLine().getStatusCode() >= 200) && (httpResponse.getStatusLine().getStatusCode() < 300))) { throw new PusherRemoteException( String.format("Remote error from pusher.com: [%s] (%s)", httpResponse.getStatusLine(), StringUtils.trim(EntityUtils.toString(httpResponse.getEntity())))); } return EntityUtils.toString(httpResponse.getEntity()); } catch (PusherRemoteException e) { log.error("pusher.com remote exception", e); throw e; } catch (Exception e) { log.error("pusher.com general exception", e); throw new RuntimeException("Error triggering pusher.com: " + e.getMessage(), e); } }
From source file:com.ms.commons.test.classloader.util.SimpleAntxLoader.java
protected List<String> getSvnUrlList(Properties p) { List<String> svnUrlList = new ArrayList<String>(); String mark = p.getProperty(ANTX_PROPERTIES); if (StringUtils.trimToNull(mark) == null) { mark = ANTX_PROPERTIES_DEFAULT;/*from ww w . j a v a 2s .co m*/ } if (StringUtils.isNotBlank(mark)) { String plusMark = ANTX_PROPERTIES + "." + StringUtils.trim(mark); for (Object key : p.keySet()) { String k = (key == null) ? "" : key.toString(); if (k.startsWith(plusMark)) { String svnUrl = StringUtils.trimToNull(p.getProperty(k)); svnUrlList.add(svnUrl); } } } if (!svnUrlList.isEmpty()) { System.err.println("Load svn urls: " + svnUrlList); } return svnUrlList; }
From source file:jp.ikedam.jenkins.plugins.updatesitesmanager.ManagedUpdateSite.java
/** * Create a new instance/*from w w w . ja va 2 s. co m*/ * * @param id * @param url * @param useCaCertificate * @param caCertificate * @param note * @param disabled */ @DataBoundConstructor public ManagedUpdateSite(String id, String url, boolean useCaCertificate, String caCertificate, String note, boolean disabled) { super(id, url); this.caCertificate = useCaCertificate ? StringUtils.trim(caCertificate) : null; this.note = note; this.disabled = disabled; }
From source file:ch.entwine.weblounge.common.impl.testing.IntegrationTestParser.java
/** * Initializes an integration test object from the given test definition. * /*from w w w . j a v a2s. com*/ * @param config * the test node * @param xpathProcessor * xpath processor to use * @throws IllegalStateException * if the test cannot be parsed */ public static IntegrationTestGroup fromXml(Node config, XPath xpathProcessor) throws IllegalStateException { // Create the test group IntegrationTestGroup testGroup = null; String name = XPathHelper.valueOf(config, "m:name", xpathProcessor); if (name == null) throw new IllegalStateException("Unable to create test without a name"); testGroup = new IntegrationTestGroup(name); // Get the test cases NodeList testCaseNodes = XPathHelper.selectList(config, "m:test-case", xpathProcessor); if (testCaseNodes == null || testCaseNodes.getLength() == 0) { logger.warn("Found test definition without test cases"); return testGroup; } for (int i = 0; i < testCaseNodes.getLength(); i++) { Node testCaseNode = testCaseNodes.item(i); // Name, url and query String testCaseName = XPathHelper.valueOf(testCaseNode, "m:name", xpathProcessor); String url = XPathHelper.valueOf(testCaseNode, "m:url", xpathProcessor); // Parameters Map<String, String[]> parameters = new HashMap<String, String[]>(); NodeList parameterNodes = XPathHelper.selectList(testCaseNode, "m:parameter", xpathProcessor); if (parameterNodes != null) { for (int j = 0; j < parameterNodes.getLength(); j++) { Node parameterNode = parameterNodes.item(j); String parameterName = XPathHelper.valueOf(parameterNode, "@name", xpathProcessor); String parameterValue = XPathHelper.valueOf(parameterNode, "text()", xpathProcessor); String[] values = parameters.get(parameterName); if (values == null) { parameters.put(parameterName, new String[] { parameterValue }); } else { String[] newValues = new String[values.length + 1]; for (int v = 0; v < values.length; v++) newValues[v] = values[v]; newValues[newValues.length - 1] = parameterValue; } } } IntegrationTestCase testCase = new IntegrationTestCase(testCaseName, url, parameters); // Status codes String expectedCodes = XPathHelper.valueOf(testCaseNode, "m:assertions/m:status", xpathProcessor); if (StringUtils.isNotBlank(expectedCodes)) { String[] codeTexts = expectedCodes.split("\\s"); int[] codes = new int[codeTexts.length]; int v = 0; for (String code : codeTexts) { codes[v++] = Integer.parseInt(StringUtils.trim(code)); } testCase.assertResponseStatus(codes); } // Assert existence NodeList existenceNodes = XPathHelper.selectList(testCaseNode, "m:assertions/m:exists", xpathProcessor); if (existenceNodes != null) { for (int j = 0; j < existenceNodes.getLength(); j++) { Node node = existenceNodes.item(j); String path = XPathHelper.valueOf(node, "m:path", xpathProcessor); testCase.assertExists(path); } } // Assert non-existence NodeList missingNodes = XPathHelper.selectList(testCaseNode, "m:assertions/m:not-exists", xpathProcessor); if (missingNodes != null) { for (int j = 0; j < missingNodes.getLength(); j++) { Node node = missingNodes.item(j); String path = XPathHelper.valueOf(node, "m:path", xpathProcessor); testCase.assertNotExists(path); } } // Assert equality NodeList matchNodes = XPathHelper.selectList(testCaseNode, "m:assertions/m:equals", xpathProcessor); if (matchNodes != null) { for (int j = 0; j < matchNodes.getLength(); j++) { Node node = matchNodes.item(j); String path = XPathHelper.valueOf(node, "m:path", xpathProcessor); String value = XPathHelper.valueOf(node, "m:value", xpathProcessor); String whitespace = XPathHelper.valueOf(node, "@ignorewhitespace", xpathProcessor); String casesensitivity = XPathHelper.valueOf(node, "@ignorecase", xpathProcessor); String regex = XPathHelper.valueOf(node, "@regularexpression", xpathProcessor); boolean ignoreWhitespace = ConfigurationUtils.isTrue(whitespace); boolean ignoreCase = ConfigurationUtils.isTrue(casesensitivity); boolean regularExpression = ConfigurationUtils.isTrue(regex); testCase.assertEquals(path, value, ignoreWhitespace, ignoreCase, regularExpression); } } // Assert non-equality NodeList mismatchNodes = XPathHelper.selectList(testCaseNode, "m:assertions/m:not-equals", xpathProcessor); if (mismatchNodes != null) { for (int j = 0; j < mismatchNodes.getLength(); j++) { Node node = mismatchNodes.item(j); String path = XPathHelper.valueOf(node, "m:path", xpathProcessor); String value = XPathHelper.valueOf(node, "m:value", xpathProcessor); String whitespace = XPathHelper.valueOf(node, "@ignorewhitespace", xpathProcessor); String casesensitivity = XPathHelper.valueOf(node, "@ignorecase", xpathProcessor); String regex = XPathHelper.valueOf(node, "@regularexpression", xpathProcessor); boolean ignoreWhitespace = ConfigurationUtils.isTrue(whitespace); boolean ignoreCase = ConfigurationUtils.isTrue(casesensitivity); boolean regularExpression = ConfigurationUtils.isTrue(regex); testCase.assertNotEquals(path, value, ignoreWhitespace, ignoreCase, regularExpression); } } testGroup.addTestCase(testCase); } return testGroup; }
From source file:com.bstek.dorado.data.config.ConfigurableDataConfigManager.java
public void addConfigLocation(String configLocation) { if (this.configLocations == null) { this.configLocations = new ArrayList<String>(); }//w ww . ja v a 2 s . c o m this.configLocations.add(StringUtils.trim(configLocation)); configLocationArray = null; }