List of usage examples for org.apache.commons.lang3 StringUtils EMPTY
String EMPTY
To view the source code for org.apache.commons.lang3 StringUtils EMPTY.
Click Source Link
From source file:com.aqnote.app.wifianalyzer.vendor.model.RemoteCallTest.java
@Test public void testDoInBackgroundWithNull() throws Exception { // execute//from w ww .j a v a2 s .c o m String actual = fixture.doInBackground((String) null); // validate assertEquals(StringUtils.EMPTY, actual); }
From source file:com.nridge.ds.solr.SolrTransform.java
/** * Convenience method that returns the value of an application * manager configuration property using the concatenation of * the property prefix and suffix values. * * @param aSuffix Property name suffix./*w w w . j a v a 2s. co m*/ * * @return Matching property values in a string array. */ public String[] getCfgStrings(String aSuffix) { String[] cfgValues; String propertyName; if (StringUtils.startsWith(aSuffix, ".")) propertyName = mCfgPropertyPrefix + aSuffix; else propertyName = mCfgPropertyPrefix + "." + aSuffix; if (mAppMgr.isPropertyMultiValue(propertyName)) cfgValues = mAppMgr.getStringArray(propertyName); else { cfgValues = new String[1]; String cfgValue = mAppMgr.getString(propertyName); if (StringUtils.isEmpty(cfgValue)) cfgValue = StringUtils.EMPTY; cfgValues[0] = cfgValue; } return cfgValues; }
From source file:info.magnolia.ui.framework.action.OpenLocationActionTest.java
@Test public void testExecuteWithShellApp() throws Exception { // GIVEN/* ww w . j a v a 2s .c om*/ definition.setAppName("appLauncher"); definition.setAppType(Location.LOCATION_TYPE_SHELL_APP); definition.setParameter("someParameter"); action = new OpenLocationAction(definition, locationController); // WHEN action.execute(); // THEN ArgumentCaptor<Location> argument = ArgumentCaptor.forClass(Location.class); verify(locationController).goTo(argument.capture()); Location argumentValue = argument.getValue(); assertThat(argumentValue.getAppName(), equalTo("appLauncher")); assertThat(argumentValue.getAppType(), equalTo(Location.LOCATION_TYPE_SHELL_APP)); assertThat(argumentValue.getSubAppId(), equalTo(StringUtils.EMPTY)); assertThat(argumentValue.getParameter(), equalTo("someParameter")); }
From source file:kr.co.generic.wifianalyzer.wifi.AccessPointDetailTest.java
@Test public void testMakeViewFullWithConfiguredImageVisible() throws Exception { // setup// w w w . j a v a 2 s. co m WiFiDetail wiFiDetail = withWiFiDetail(SSID, new WiFiAdditional(StringUtils.EMPTY, true)); // execute View actual = fixture.makeView(null, null, wiFiDetail, false); // validate assertEquals(View.VISIBLE, actual.findViewById(kr.co.generic.wifianalyzer.R.id.configuredImage).getVisibility()); }
From source file:ch.cyberduck.core.PathNormalizer.java
/** * Return a context-relative path, beginning with a "/", that represents * the canonical version of the specified path after ".." and "." elements * are resolved out./*from ww w .ja va 2s . c o m*/ * * @param path The path to parse * @param absolute If the path is absolute * @return the normalized path. */ public static String normalize(final String path, final boolean absolute) { if (null == path) { return String.valueOf(Path.DELIMITER); } String normalized = path; if (PreferencesFactory.get().getBoolean("path.normalize")) { if (absolute) { while (!normalized.startsWith(String.valueOf(Path.DELIMITER))) { normalized = Path.DELIMITER + normalized; } } while (!normalized.endsWith(String.valueOf(Path.DELIMITER))) { normalized += Path.DELIMITER; } // Resolve occurrences of "/./" in the normalized path while (true) { int index = normalized.indexOf("/./"); if (index < 0) { break; } normalized = normalized.substring(0, index) + normalized.substring(index + 2); } // Resolve occurrences of "/../" in the normalized path while (true) { int index = normalized.indexOf("/../"); if (index < 0) { break; } if (index == 0) { // The only left path is the root. return String.valueOf(Path.DELIMITER); } normalized = normalized.substring(0, normalized.lastIndexOf(Path.DELIMITER, index - 1)) + normalized.substring(index + 3); } StringBuilder n = new StringBuilder(); if (normalized.startsWith("//")) { // see #972. Omit leading delimiter n.append(Path.DELIMITER); n.append(Path.DELIMITER); } else if (absolute) { // convert to absolute path n.append(Path.DELIMITER); } else if (normalized.startsWith(String.valueOf(Path.DELIMITER))) { // Keep absolute path n.append(Path.DELIMITER); } // Remove duplicated Path.DELIMITERs final String[] segments = normalized.split(String.valueOf(Path.DELIMITER)); for (String segment : segments) { if (segment.equals(StringUtils.EMPTY)) { continue; } n.append(segment); n.append(Path.DELIMITER); } normalized = n.toString(); while (normalized.endsWith(String.valueOf(Path.DELIMITER)) && normalized.length() > 1) { //Strip any redundant delimiter at the end of the path normalized = normalized.substring(0, normalized.length() - 1); } } if (PreferencesFactory.get().getBoolean("path.normalize.unicode")) { return new NFCNormalizer().normalize(normalized).toString(); } // Return the normalized path that we have completed return normalized; }
From source file:kr.co.generic.wifianalyzer.vendor.model.RemoteCallTest.java
@Test public void testDoInBackgroundWithEmpty() throws Exception { // execute/*w w w .ja v a 2s . c o m*/ RemoteResult actual = fixture.doInBackground(StringUtils.EMPTY); // validate assertEquals(RemoteResult.EMPTY, actual); }
From source file:com.adobe.acs.commons.reports.internal.datasources.DynamicSelectDataSource.java
@Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { final ResourceResolver resolver = request.getResourceResolver(); final ValueMap properties = request.getResource().getValueMap(); final List<DataSourceOption> options = new ArrayList<>(); try {/*from w w w . j a v a 2 s . c o m*/ // The query language property final String queryLanguage = properties.get(PN_DROP_DOWN_QUERY_LANGUAGE, JCR_SQL2); // The query statement (this must match the queryLanguage else the query will fail) final String queryStatement = properties.get(PN_DROP_DOWN_QUERY, String.class); // The property names to extract; these are specified as a String[] property final String[] allowedPropertyNames = properties.get(PN_ALLOW_PROPERTY_NAMES, new String[0]); if (StringUtils.isNotBlank(queryStatement)) { // perform the query final List<Resource> results = queryHelper.findResources(resolver, queryLanguage, queryStatement, StringUtils.EMPTY); final List<String> distinctOptionValues = new ArrayList<>(); for (final Resource resource : results) { // For each result... // - ensure the property value is a String // - ensure either no properties have been specified (which means ALL properties are eligible) OR the property is in the list of enumerated propertyNames // - ensure this property value has not already been processed // -- if the above criteria is satisfied, add to the options resource.getValueMap().entrySet().stream().filter(entry -> entry.getValue() instanceof String) .filter(entry -> ArrayUtils.isEmpty(allowedPropertyNames) || ArrayUtils.contains(allowedPropertyNames, entry.getKey())) .filter(entry -> !distinctOptionValues.contains(entry.getValue().toString())) .forEach(entry -> { String value = entry.getValue().toString(); distinctOptionValues.add(value); options.add(new DataSourceOption(value, value)); }); } } // Create a datasource from the collected options, even if there are 0 options. dataSourceBuilder.addDataSource(request, options); } catch (Exception e) { log.error( "Unable to collect the information to populate the ACS Commons Report Builder dynamic-select drop-down.", e); response.sendError(SlingHttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:de.blizzy.documentr.TestUtil.java
public static String removeTextRange(String html) { return html.replaceAll(" data-text-range=\"[0-9]+,[0-9]+\"", StringUtils.EMPTY); //$NON-NLS-1$ }
From source file:cop.raml.processor.RestApi.java
private static String findLongestPrefix(String basePath, String path) { basePath = StringUtils.trimToEmpty(basePath); path = StringUtils.trimToEmpty(path); if (basePath.isEmpty() || path.isEmpty()) return StringUtils.EMPTY; String[] baseParts = Utils.splitPath(basePath); String[] pathParts = Utils.splitPath(path); int total = getEqualPartsAmount(baseParts, pathParts); if (total > 0) { String str = StringUtils.join(ArrayUtils.subarray(baseParts, 0, total), "/"); return path.startsWith("/") ? '/' + str : str; } else// w w w . ja va2 s . c o m return StringUtils.EMPTY; }
From source file:com.aqnote.app.wifianalyzer.wifi.AccessPointsAdapterDataTest.java
private List<WiFiDetail> withWiFiDetails() { WiFiDetail wiFiDetail1 = new WiFiDetail("SSID1", "BSSID1", StringUtils.EMPTY, WiFiSignal.EMPTY); wiFiDetail1.addChild(new WiFiDetail("SSID1-1", "BSSID1-1", StringUtils.EMPTY, WiFiSignal.EMPTY)); wiFiDetail1.addChild(new WiFiDetail("SSID1-2", "BSSID1-2", StringUtils.EMPTY, WiFiSignal.EMPTY)); wiFiDetail1.addChild(new WiFiDetail("SSID1-3", "BSSID1-3", StringUtils.EMPTY, WiFiSignal.EMPTY)); return Arrays.asList(wiFiDetail1, new WiFiDetail("SSID2", "BSSID2", StringUtils.EMPTY, WiFiSignal.EMPTY), new WiFiDetail("SSID3", "BSSID3", StringUtils.EMPTY, WiFiSignal.EMPTY)); }