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

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

Introduction

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

Prototype

public static String remove(final String str, final char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

A null source string will return null .

Usage

From source file:co.runrightfast.core.utils.UUIDUtils.java

/**
 *
 * @return 32 char UUID
 */
static String uuid() {
    return StringUtils.remove(UUID.randomUUID().toString(), '-');
}

From source file:com.google.dart.ui.test.matchers.HasTextWidgetMatcher.java

/**
 * Normalizes given {@link String} by removing special characters.
 *///from   ww  w  .j  a  v a 2s . c  o m
private static String normalizeWidgetText(String s) {
    s = s.trim();
    s = StringUtils.remove(s, '&');
    s = StringUtils.substringBefore(s, "\t");
    return s;
}

From source file:com.ufukuzun.myth.dialect.util.ExpressionUtils.java

public static List<String> splitIdFragments(String value) {
    List<String> idFragments = new ArrayList<String>();

    if (StringUtils.isNotBlank(value)) {
        value = StringUtils.remove(value, "${}");
        Matcher matcher = DOLLAR_EXPRESSION_PATTERN.matcher(value);
        while (matcher.find()) {
            idFragments.add(matcher.group());
            value = StringUtils.remove(value, matcher.group());
        }/* ww w .  j av a2 s. co  m*/

        idFragments.addAll(Arrays.asList(StringUtils.split(value)));
    }

    return idFragments;
}

From source file:name.martingeisse.common.util.string.StringUtil.java

/**
 * Converts an underscored name to an upper-camel-case name like
 * this: "my_foo_bar" -> "MyFooBar"./*from w  w  w  . j av a2  s.  c  o  m*/
 * @param s the string to convert
 * @return the upper camel case string
 */
public static String convertUnderscoresToUpperCamelCase(String s) {
    return StringUtils.remove(WordUtils.capitalizeFully(s, UNDERSCORE_ARRAY), '_');
}

From source file:cz.lidinsky.editor.Action.java

protected static void setLabel(final Action action, final String label) {
    if (label != null) {
        int mnemonicIndex = label.indexOf('_');
        if (mnemonicIndex >= 0) {
            String text = StringUtils.remove(label, '_');
            int key = text.codePointAt(mnemonicIndex);
            action.putValue(Action.NAME, text);
            action.putValue(Action.MNEMONIC_KEY, key);
        } else {// w  w  w . j a v  a  2s .  c  o m
            action.putValue(Action.NAME, label);
        }
    }
}

From source file:com.cognifide.aet.executor.xmlparser.xml.utils.ValidationUtils.java

public static String validateNotHavingUnderscore(String value, String warnMessage) throws ParseException {
    String fixedValue = StringUtils.remove(value, "_");

    if (!StringUtils.equals(value, fixedValue)) {
        LOGGER.warn(warnMessage);//from www .j  ava2 s .  c  om
    }

    return fixedValue;
}

From source file:com.google.dart.tools.ui.internal.text.dart.DartDocAutoIndentStrategyTest.java

private static void assert_customizeDocumentCommand(String initial, String newText, String expected) {
    int initialOffset = initial.indexOf('!');
    int expectedOffset = expected.indexOf('!');
    assertTrue("No cursor position in initial: " + initial, initialOffset != -1);
    assertTrue("No cursor position in expected: " + expected, expectedOffset != -1);
    initial = StringUtils.remove(initial, '!');
    expected = StringUtils.remove(expected, '!');
    // prepare document
    IDocument document = new Document(initial);
    {/*from   w  ww  .jav  a  2s.c  om*/
        DartTextTools tools = DartToolsPlugin.getDefault().getDartTextTools();
        tools.setupDartDocumentPartitioner(document, DartPartitions.DART_PARTITIONING);
    }
    // handle command
    DocumentCommand command = new DocumentCommand() {
    };
    command.caretOffset = -1;
    command.doit = true;
    command.offset = initialOffset;
    command.text = newText;
    // execute command
    DartDocAutoIndentStrategy strategy = new DartDocAutoIndentStrategy(DartPartitions.DART_PARTITIONING);
    strategy.customizeDocumentCommand(document, command);
    // update document
    ReflectionUtils.invokeMethod(command, "execute(org.eclipse.jface.text.IDocument)", document);
    // check new content
    String actual = document.get();
    assertEquals(expected, actual);
    // check caret offset
    int actualOffset = command.caretOffset;
    if (actualOffset == -1) {
        actualOffset = initialOffset + command.text.length();
    }
    assertThat(actualOffset).isEqualTo(expectedOffset);
}

From source file:com.granita.contacticloudsync.log.ExternalFileLogger.java

public ExternalFileLogger(Context context, String fileName, boolean verbose) throws IOException {
    this.verbose = verbose;

    File dir = getDirectory(context);
    if (dir == null)
        throw new IOException("External media not available for log creation");

    name = StringUtils.remove(StringUtils.remove(fileName, File.pathSeparatorChar), File.separatorChar);

    File log = new File(dir, name);
    writer = new PrintWriter(log);
}

From source file:info.devbug.core.UnixCifsUrlConverter.java

@Override
public String convert(String windowsCifsUrl, boolean ignoreSpaces) {
    Pattern pattern = Pattern.compile(CIFS_URL_PATTERN);
    Matcher matcher = pattern.matcher(windowsCifsUrl);

    boolean isMatch = matcher.matches();

    if (isMatch) {
        String cifsPrefix = "smb://";

        // Windows cifs url starts from right slashes "//". We should remove them
        String url = StringUtils.remove(windowsCifsUrl, "\\\\");
        String unixUrl = StringUtils.replace(url, "\\", "/");

        if (!ignoreSpaces) {
            unixUrl = convertWithSpaces(unixUrl);
        }//from  w ww  .jav  a 2s  .c  om

        String finalUnixUrl = cifsPrefix + unixUrl;

        return finalUnixUrl;
    }
    return "Incorrect CIFS url";
}

From source file:name.martingeisse.common.util.string.StringUtil.java

/**
 * Converts an underscored name to an lower-camel-case name like
 * this: "my_foo_bar" -> "myFooBar"./*from   w w w  .  j  a v  a  2s. co m*/
 * @param s the string to convert
 * @return the lower camel case string
 */
public static String convertUnderscoresToLowerCamelCase(String s) {
    if (s.isEmpty()) {
        return s;
    }
    char firstCharacterLowerCase = Character.toLowerCase(s.charAt(0));
    return firstCharacterLowerCase
            + StringUtils.remove(WordUtils.capitalizeFully(s, UNDERSCORE_ARRAY), '_').substring(1);
}