Example usage for org.apache.commons.lang3 StringUtils EMPTY

List of usage examples for org.apache.commons.lang3 StringUtils EMPTY

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils EMPTY.

Prototype

String EMPTY

To view the source code for org.apache.commons.lang3 StringUtils EMPTY.

Click Source Link

Document

The empty String "" .

Usage

From source file:com.moviejukebox.tools.WebBrowser.java

private static String encodePassword() {
    if (PROXY_USERNAME != null) {
        return ("Basic " + new String(Base64.encodeBase64((PROXY_USERNAME + ":" + PROXY_PASSWORD).getBytes())));
    }/*from   w w  w  . j  a  v a  2 s.  c o m*/
    return StringUtils.EMPTY;
}

From source file:ch.cyberduck.core.BookmarkNameProviderTest.java

@Test
public void testToStringNoDefaultHostname() throws Exception {
    final TestProtocol protocol = new TestProtocol(Scheme.file) {
        @Override//  www.  j a v  a 2  s.c o m
        public String getName() {
            return "Disk";
        }

        @Override
        public String getDefaultHostname() {
            return "";
        }
    };
    assertEquals("Disk", BookmarkNameProvider.toString(new Host(protocol, StringUtils.EMPTY), true));
    assertEquals("Disk", BookmarkNameProvider.toString(new Host(protocol, StringUtils.EMPTY), false));
}

From source file:ch.cyberduck.core.dropbox.DropboxSearchFeature.java

@Override
public AttributedList<Path> search(final Path workdir, final Filter<Path> regex,
        final ListProgressListener listener) throws BackgroundException {
    try {/*from  w  ww  .  ja va  2  s  .c  om*/
        final AttributedList<Path> list = new AttributedList<>();
        long start = 0;
        SearchResult result;
        do {
            result = new DbxUserFilesRequests(session.getClient())
                    .searchBuilder(workdir.isRoot() ? StringUtils.EMPTY : workdir.getAbsolute(),
                            regex.toPattern().pattern())
                    .withMode(SearchMode.FILENAME).withStart(start).start();
            final List<SearchMatch> matches = result.getMatches();
            for (SearchMatch match : matches) {
                final Metadata metadata = match.getMetadata();
                final EnumSet<AbstractPath.Type> type;
                if (metadata instanceof FileMetadata) {
                    type = EnumSet.of(Path.Type.file);
                } else if (metadata instanceof FolderMetadata) {
                    type = EnumSet.of(Path.Type.directory);
                } else {
                    log.warn(String.format("Skip file %s", metadata));
                    return null;
                }
                list.add(new Path(metadata.getPathDisplay(), type, attributes.convert(metadata)));
                listener.chunk(workdir, list);
            }
            start = result.getStart();
        } while (result.getMore());
        return list;
    } catch (DbxException e) {
        throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e, workdir);
    }
}

From source file:fm.audiobox.core.exceptions.RemoteMessageException.java

/**
 * Transforms error mapping into strings.
 *
 * @param errors the errors mapping/*from  ww w.  j a va2 s  .c  o  m*/
 *
 * @return the string
 */
public static String errorsToString(Errors errors) {
    String msg = errors.toString();
    if (StringUtils.EMPTY.equals(msg)) {
        for (Map.Entry<String, Object> error : errors.getUnknownKeys().entrySet()) {
            msg += errorToString(error) + "\n";
        }
    }
    return msg;
}

From source file:info.magnolia.ui.form.field.transformer.basic.NotNullInitialStringValueTransformer.java

/**
 * If the initial property do not exist, do not return a Null.
 *//*from ww  w .j a v a 2  s.  c  o  m*/
@Override
public String readFromItem() {
    String value = super.readFromItem();
    return (StringUtils.isBlank(value)) ? StringUtils.EMPTY : value;
}

From source file:com.googlecode.jsendnsca.MessagePayloadTest.java

@Test
public void shouldThrowIllegalArgumentExceptionOnEmptyHostName() throws Exception {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("hostname cannot be null or an empty String");

    final MessagePayload payload = new MessagePayload();

    payload.setHostname(StringUtils.EMPTY);
}

From source file:com.neocotic.blingaer.common.IOUtils.java

/**
 * Gets the contents of the {@code Reader} provided as a {@code String}.
 * /*w  w w . j  a  v  a 2 s. co  m*/
 * @param input
 *            the {@code Reader} to be read
 * @return the {@code String} contents of the {@code Reader}
 * @throws IOException
 *             If an I/O error occurs.
 * @throws NullPointerException
 *             If {@code input} is {@code null}.
 */
public static String toString(Reader input) throws IOException {
    return StringUtils.join(readLines(input), StringUtils.EMPTY);
}

From source file:ch.cyberduck.core.sds.SDSReadFeature.java

@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback)
        throws BackgroundException {
    try {//from  www  .  java  2  s  .c o m
        final SDSApiClient client = session.getClient();
        final HttpUriRequest request = new HttpGet(
                String.format("%s/nodes/files/%s/downloads", client.getBasePath(),
                        new SDSNodeIdProvider(session).getFileid(file, new DisabledListProgressListener())));
        request.addHeader("X-Sds-Auth-Token", StringUtils.EMPTY);
        if (status.isAppend()) {
            final HttpRange range = HttpRange.withStatus(status);
            final String header;
            if (-1 == range.getEnd()) {
                header = String.format("bytes=%d-", range.getStart());
            } else {
                header = String.format("bytes=%d-%d", range.getStart(), range.getEnd());
            }
            if (log.isDebugEnabled()) {
                log.debug(String.format("Add range header %s for file %s", header, file));
            }
            request.addHeader(new BasicHeader(HttpHeaders.RANGE, header));
            // Disable compression
            request.addHeader(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "identity"));
        }
        final HttpResponse response = client.getClient().execute(request);
        switch (response.getStatusLine().getStatusCode()) {
        case HttpStatus.SC_OK:
        case HttpStatus.SC_PARTIAL_CONTENT:
            return new HttpMethodReleaseInputStream(response);
        default:
            throw new HttpResponseExceptionMappingService().map(new HttpResponseException(
                    response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()));
        }
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Download {0} failed", e, file);
    }
}

From source file:ch.cyberduck.core.sds.SDSListService.java

public AttributedList<Path> list(final Path directory, final ListProgressListener listener, final int chunksize)
        throws BackgroundException {
    final AttributedList<Path> children = new AttributedList<Path>();
    try {//from   w ww  . j ava  2  s  .co m
        Integer offset = 0;
        final SDSAttributesFinderFeature feature = new SDSAttributesFinderFeature(session);
        NodeList nodes;
        do {
            nodes = new NodesApi(session.getClient()).getFsNodes(
                    StringUtils.EMPTY, null, 0, Long.parseLong(new SDSNodeIdProvider(session)
                            .getFileid(directory, new DisabledListProgressListener())),
                    null, null, "name:asc", offset, chunksize);
            for (Node node : nodes.getItems()) {
                final PathAttributes attributes = feature.toAttributes(node);
                final EnumSet<AbstractPath.Type> type;
                switch (node.getType()) {
                case ROOM:
                    type = EnumSet.of(Path.Type.directory, Path.Type.volume);
                    if (node.getIsEncrypted()) {
                        type.add(Path.Type.vault);
                    }
                    break;
                case FOLDER:
                    type = EnumSet.of(Path.Type.directory);
                    if (node.getIsEncrypted()) {
                        type.add(Path.Type.decrypted);
                    }
                    break;
                default:
                    type = EnumSet.of(Path.Type.file);
                    if (node.getIsEncrypted()) {
                        type.add(Path.Type.decrypted);
                    }
                }
                final Map<String, String> custom = new HashMap<>();
                if (null != node.getCntDownloadShares()) {
                    custom.put(SDSAttributesFinderFeature.KEY_CNT_DOWNLOADSHARES,
                            String.valueOf(node.getCntDownloadShares()));
                }
                if (null != node.getCntUploadShares()) {
                    custom.put(SDSAttributesFinderFeature.KEY_CNT_UPLOADSHARES,
                            String.valueOf(node.getCntUploadShares()));
                }
                attributes.setCustom(custom);
                final Path file = new Path(directory, node.getName(), type, attributes);
                children.add(file);
                listener.chunk(directory, children);
            }
            offset += chunksize;
        } while (nodes.getItems().size() == chunksize);
    } catch (ApiException e) {
        throw new SDSExceptionMappingService().map("Listing directory {0} failed", e, directory);
    }
    return children;
}

From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java

/**
 * ?map???map.//from  w  w w  . j av  a  2s .  co m
 * 
 * <p style="color:green">
 *  {@link TreeMap},key?
 * </p>
 *
 * @param arrayValueMap
 *            the array value map
 * @return {@link TreeMap}
 * @since 1.4.0
 */
public static Map<String, String> toSingleValueMap(Map<String, String[]> arrayValueMap) {// TreeMap log 
    if (Validator.isNullOrEmpty(arrayValueMap)) {
        return Collections.emptyMap();
    }

    Map<String, String> singleValueMap = new TreeMap<String, String>();
    for (Map.Entry<String, String[]> entry : arrayValueMap.entrySet()) {
        String key = entry.getKey();
        String[] values = entry.getValue();
        String singleValue = Validator.isNotNullOrEmpty(values) ? values[0] : StringUtils.EMPTY;
        singleValueMap.put(key, singleValue);
    }
    return singleValueMap;
}