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.quatico.base.aem.test.api.setup.Components.java

protected Resource createComponent(String path, ComponentType type, Object... properties) throws Exception {
    if (StringUtils.isBlank(path)) {
        path = StringUtils.EMPTY;
    }/* w  w w .ja v  a  2s  .  c o m*/
    return resources.aResource(path, new Properties(properties).append(RESOURCE_TYPE, type).toArray());
}

From source file:ch.cyberduck.core.sftp.auth.SFTPChallengeResponseAuthentication.java

@Override
public Boolean authenticate(final Host bookmark, final HostPasswordStore keychain, final LoginCallback callback,
        final CancelCallback cancel) throws BackgroundException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Login using challenge response authentication for %s", bookmark));
    }//from w  w w  . j  a  v a  2s  .co m
    try {
        session.getClient().auth(bookmark.getCredentials().getUsername(),
                new AuthKeyboardInteractive(new ChallengeResponseProvider() {
                    private String name = StringUtils.EMPTY;
                    private String instruction = StringUtils.EMPTY;

                    @Override
                    public List<String> getSubmethods() {
                        return Collections.emptyList();
                    }

                    @Override
                    public void init(final Resource resource, final String name, final String instruction) {
                        if (StringUtils.isNoneBlank(instruction)) {
                            this.instruction = instruction;
                        }
                        if (StringUtils.isNoneBlank(name)) {
                            this.name = name;
                        }
                    }

                    @Override
                    public char[] getResponse(final String prompt, final boolean echo) {
                        // For each prompt, the corresponding echo field indicates whether the user input should be echoed as characters are typed
                        if (log.isDebugEnabled()) {
                            log.debug(String.format("Reply to challenge name %s with instruction %s", name,
                                    instruction));
                        }
                        if (echo) {
                            return EMPTY_RESPONSE;
                        }
                        if (PasswordResponseProvider.DEFAULT_PROMPT_PATTERN.matcher(prompt).matches()) {
                            return bookmark.getCredentials().getPassword().toCharArray();
                        } else {
                            final StringAppender message = new StringAppender().append(instruction)
                                    .append(prompt);
                            // Properly handle an instruction field with embedded newlines.  They should also
                            // be able to display at least 30 characters for the name and prompts.
                            final Credentials additional;
                            try {
                                final StringAppender title = new StringAppender().append(name).append(
                                        LocaleFactory.localizedString("Provide additional login credentials",
                                                "Credentials"));
                                additional = callback.prompt(bookmark, bookmark.getCredentials().getUsername(),
                                        title.toString(), message.toString(),
                                        new LoginOptions(bookmark.getProtocol()).user(false).publickey(false)
                                                .keychain(false)
                                                .usernamePlaceholder(bookmark.getCredentials().getUsername()));
                            } catch (LoginCanceledException e) {
                                return EMPTY_RESPONSE;
                            }
                            // Responses are encoded in ISO-10646 UTF-8.
                            return additional.getPassword().toCharArray();
                        }
                    }

                    @Override
                    public boolean shouldRetry() {
                        return false;
                    }
                }));
    } catch (IOException e) {
        throw new SFTPExceptionMappingService().map(e);
    }
    return session.getClient().isAuthenticated();
}

From source file:com.github.fengtan.sophie.dialogs.EditListValueDialog.java

@Override
protected Control createDialogArea(final Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new RowLayout());

    // Create list widget.
    listViewer = new ListViewer(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER);
    for (Object value : defaultValue) {
        listViewer.add(Objects.toString(value, StringUtils.EMPTY));
    }/*from w  ww . j  a v  a  2s. c  o m*/

    // Create add/remove buttons.
    Composite buttonsComposite = new Composite(composite, SWT.NULL);
    buttonsComposite.setLayout(new FillLayout(SWT.VERTICAL));

    Button buttonAdd = new Button(buttonsComposite, SWT.PUSH);
    buttonAdd.setText("Add");
    buttonAdd.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            InputDialog input = new InputDialog(parent.getShell(), "Add value", "Add value:", null, null);
            input.open();
            if (input.getReturnCode() == IDialogConstants.OK_ID) {
                listViewer.add(input.getValue());
            }
        }
    });

    Button buttonRemove = new Button(buttonsComposite, SWT.PUSH);
    buttonRemove.setText("Remove");
    buttonRemove.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
            if (!selection.isEmpty()) {
                listViewer.remove(selection.toArray());
            }
        }
    });

    return composite;
}

From source file:ch.cyberduck.ui.cocoa.DuplicateFileController.java

@Override
protected void beginSheet(final NSWindow window) {
    final Path selected = this.getSelected();
    alert.setIcon(IconCacheFactory.<NSImage>get().fileIcon(selected, 64));
    String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("browser.duplicate.format"),
            FilenameUtils.getBaseName(selected.getName()),
            UserDateFormatterFactory.get().getShortFormat(System.currentTimeMillis(), false)
                    .replace(Path.DELIMITER, ':'),
            StringUtils.isNotEmpty(selected.getExtension()) ? "." + selected.getExtension()
                    : StringUtils.EMPTY);
    inputField.setStringValue(proposal);
    super.beginSheet(window);
}

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

@Override
public String getFileid(final Path file, final ListProgressListener listener) throws BackgroundException {
    if (StringUtils.isNotBlank(file.attributes().getVersionId())) {
        if (log.isInfoEnabled()) {
            log.info(// w  w w  .  j a va2  s. c  o m
                    String.format("Return cached node %s for file %s", file.attributes().getVersionId(), file));
        }
        return file.attributes().getVersionId();
    }
    if (file.isRoot()) {
        return ROOT_NODE_ID;
    }
    try {
        final String type;
        if (file.isDirectory()) {
            if (containerService.isContainer(file)) {
                type = "room";
            } else {
                type = "folder";
            }
        } else {
            type = "file";
        }
        // Top-level nodes only
        final NodeList nodes = new NodesApi(session.getClient()).getFsNodes(StringUtils.EMPTY, null, 0,
                Long.parseLong(this.getFileid(file.getParent(), new DisabledListProgressListener())), null,
                String.format("type:eq:%s|name:cn:%s", type, file.getName()), null, null, null);
        for (Node node : nodes.getItems()) {
            if (node.getName().equals(file.getName())) {
                if (log.isInfoEnabled()) {
                    log.info(String.format("Return node %s for file %s", node.getId(), file));
                }
                return node.getId().toString();
            }
        }
        throw new NotfoundException(file.getAbsolute());
    } catch (ApiException e) {
        throw new SDSExceptionMappingService().map("Failure to read attributes of {0}", e, file);
    }
}

From source file:com.veight.mail.template.MailTemplateLocal.java

public String makeContent(String templateName, Map<String, String> root) {
    Writer out = null;//from  w w w.  ja  v  a2 s .c om
    try {
        Template template = configuration.getTemplate(templateName);
        out = new StringWriter();
        template.process(root, out);

        out.flush();
        return out.toString();
    } catch (IOException | TemplateException ex) {
        logger.error("Fail to get content from freemaker. [mailTemplate={}][mail={}]", templateName, ex);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException ex) {
                logger.error("Fail to close StringWriter.", ex);
            }
        }
    }
    return StringUtils.EMPTY;
}

From source file:com.github.haixing_hu.csl.Info.java

public Info() {
    id = StringUtils.EMPTY;
    title = StringUtils.EMPTY;/*from w w  w  .j  a  va 2s . c  o m*/
    titleShort = null;
    summary = null;
    authors = null;
    contributors = null;
    categories = null;
    issns = null;
    eissns = null;
    issnls = null;
    links = null;
    rights = null;
    published = null;
    updated = new Date(0);
}

From source file:com.tojc.ormlite.android.framework.MimeTypeVndTest.java

public void testIsValid_returns_false_if_mime_type_has_null_or_empty_type() {
    // given//from  w  w w  .j  av a 2s  . c om
    mimeTypeVnd = new MimeTypeVnd(SubType.ITEM, new ContentMimeTypeVndInfo(CONTENT_MIME_TYPE_VND_NAME, null));
    // when

    // then
    assertFalse(mimeTypeVnd.isValid());

    // --
    // given
    mimeTypeVnd = new MimeTypeVnd(SubType.ITEM,
            new ContentMimeTypeVndInfo(CONTENT_MIME_TYPE_VND_NAME, StringUtils.EMPTY));
    // when

    // then
    assertFalse(mimeTypeVnd.isValid());
}

From source file:com.beginner.core.utils.PropertyUtil.java

/**
 * java.util.ResourceBundle?classpathproperties??TestResourcesUtil
 * @param key         key/*from   w  w w  .  j  a va 2s.  c o m*/
 * @param fileName      +????.properties??
 * @return String      keyvalue
 */
public static String getProperty(String key, String fileName) {

    if (StringUtils.isBlank(key))
        throw new IllegalArgumentException("The key cannot be null and cannot be empty.");

    if (StringUtils.isBlank(fileName))
        throw new IllegalArgumentException("The fileName cannot be null and cannot be empty.");

    Locale locale = Locale.getDefault();

    ResourceBundle resource = ResourceBundle.getBundle(fileName, locale);
    String value = StringUtils.EMPTY;
    try {
        value = resource.getString(key);
    } catch (Exception e) {
        return value;
    }
    return value;
}

From source file:com.github.haixing_hu.ilibrary.model.DocumentTemplateBuilder.java

public DocumentTemplateBuilder reset() {
    name = StringUtils.EMPTY;
    type = DocumentType.ARTICLE;//www .  jav a2  s . com
    kinds.clear();
    defaultKind = StringUtils.EMPTY;
    fieldGroups.clear();
    variableMapping.clear();
    return this;
}